|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +source experiment/run-library.sh |
| 4 | + |
| 5 | +organization="${PARAM_organization:-Default Organization}" |
| 6 | +manifest="${PARAM_manifest:-conf/contperf/manifest_SCA.zip}" |
| 7 | +inventory="${PARAM_inventory:-conf/contperf/inventory.ini}" |
| 8 | + |
| 9 | +cdn_url_full="${PARAM_cdn_url_full:-https://cdn.redhat.com/}" |
| 10 | + |
| 11 | +repo_sat_client_6="${PARAM_repo_sat_client_6:-http://mirror.example.com/Satellite_Client_6_x86_64/}" |
| 12 | +repo_sat_client_7="${PARAM_repo_sat_client_7:-http://mirror.example.com/Satellite_Client_7_x86_64/}" |
| 13 | +repo_sat_client_8="${PARAM_repo_sat_client_8:-http://mirror.example.com/Satellite_Client_8_x86_64/}" |
| 14 | +repo_sat_client_9="${PARAM_repo_sat_client_9:-http://mirror.example.com/Satellite_Client_9_x86_64/}" |
| 15 | + |
| 16 | +lces="${PARAM_lces:-Test Pre Prod}" |
| 17 | + |
| 18 | +initial_index="${PARAM_initial_index:-0}" |
| 19 | + |
| 20 | +dl='Default Location' |
| 21 | + |
| 22 | +opts="--forks 100 -i $inventory" |
| 23 | +opts_adhoc="$opts" |
| 24 | + |
| 25 | + |
| 26 | +section "Checking environment" |
| 27 | +generic_environment_check |
| 28 | + |
| 29 | + |
| 30 | +section "Upload manifest" |
| 31 | +h_out "--no-headers --csv organization list --fields name" | grep --quiet "^$organization$" \ |
| 32 | + || h capsync-10-ensure-org.log "organization create --name '$organization'" |
| 33 | +h_out "--no-headers --csv location list --fields name" | grep --quiet '^$dl$' \ |
| 34 | + || h capsync-10-ensure-loc-in-org.log "organization add-location --name '$organization' --location '$dl'" |
| 35 | +a capsync-10-manifest-deploy.log \ |
| 36 | + -m copy \ |
| 37 | + -a "src=$manifest dest=/root/manifest-auto.zip force=yes" satellite6 |
| 38 | +h capsync-10-manifest-upload.log "subscription upload --file '/root/manifest-auto.zip' --organization '$organization'" |
| 39 | + |
| 40 | + |
| 41 | +section "Sync from CDN" |
| 42 | +h capsync-20-set-cdn-stage.log "organization update --name '$organization' --redhat-repository-url '$cdn_url_full'" |
| 43 | + |
| 44 | +h capsync-21-manifest-refresh.log "subscription refresh-manifest --organization '$organization'" |
| 45 | + |
| 46 | +# RHEL 6 |
| 47 | +rel='rhel6' |
| 48 | + |
| 49 | +h capsync-22-reposet-enable-${rel}.log "repository-set enable --organization '$organization' --product 'Red Hat Enterprise Linux Server' --name 'Red Hat Enterprise Linux 6 Server (RPMs)' --releasever '6Server' --basearch 'x86_64'" |
| 50 | +h capsync-23-repo-sync-${rel}.log "repository synchronize --organization '$organization' --product 'Red Hat Enterprise Linux Server' --name 'Red Hat Enterprise Linux 6 Server RPMs x86_64 6Server'" |
| 51 | + |
| 52 | +# RHEL 7 |
| 53 | +rel='rhel7' |
| 54 | + |
| 55 | +h capsync-22-reposet-enable-${rel}.log "repository-set enable --organization '$organization' --product 'Red Hat Enterprise Linux Server' --name 'Red Hat Enterprise Linux 7 Server (RPMs)' --releasever '7Server' --basearch 'x86_64'" |
| 56 | +h capsync-23-repo-sync-${rel}.log "repository synchronize --organization '$organization' --product 'Red Hat Enterprise Linux Server' --name 'Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server'" |
| 57 | + |
| 58 | +h capsync-22-reposet-enable-${rel}extras.log "repository-set enable --organization '$organization' --product 'Red Hat Enterprise Linux Server' --name 'Red Hat Enterprise Linux 7 Server - Extras (RPMs)' --releasever '7Server' --basearch 'x86_64'" |
| 59 | +h capsync-23-repo-sync-${rel}extras.log "repository synchronize --organization '$organization' --product 'Red Hat Enterprise Linux Server' --name 'Red Hat Enterprise Linux 7 Server - Extras RPMs x86_64'" |
| 60 | + |
| 61 | +# RHEL 8 |
| 62 | +rel='rhel8' |
| 63 | + |
| 64 | +h capsync-22-reposet-enable-${rel}baseos.log "repository-set enable --organization '$organization' --product 'Red Hat Enterprise Linux for x86_64' --name 'Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)' --releasever '8' --basearch 'x86_64'" |
| 65 | +h capsync-23-repo-sync-${rel}baseos.log "repository synchronize --organization '$organization' --product 'Red Hat Enterprise Linux for x86_64' --name 'Red Hat Enterprise Linux 8 for x86_64 - BaseOS RPMs 8'" |
| 66 | + |
| 67 | +h capsync-22-reposet-enable-${rel}appstream.log "repository-set enable --organization '$organization' --product 'Red Hat Enterprise Linux for x86_64' --name 'Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)' --releasever '8' --basearch 'x86_64'" |
| 68 | +h capsync-23-repo-sync-${rel}appstream.log "repository synchronize --organization '$organization' --product 'Red Hat Enterprise Linux for x86_64' --name 'Red Hat Enterprise Linux 8 for x86_64 - AppStream RPMs 8'" |
| 69 | + |
| 70 | +# RHEL 9 |
| 71 | +rel='rhel9' |
| 72 | + |
| 73 | +h capsync-22-reposet-enable-${rel}baseos.log "repository-set enable --organization '$organization' --product 'Red Hat Enterprise Linux for x86_64' --name 'Red Hat Enterprise Linux 9 for x86_64 - BaseOS (RPMs)' --releasever '9' --basearch 'x86_64'" |
| 74 | +h capsync-23-repo-sync-${rel}baseos.log "repository synchronize --organization '$organization' --product 'Red Hat Enterprise Linux for x86_64' --name 'Red Hat Enterprise Linux 9 for x86_64 - BaseOS RPMs 9'" |
| 75 | + |
| 76 | +h capsync-22-reposet-enable-${rel}appstream.log "repository-set enable --organization '$organization' --product 'Red Hat Enterprise Linux for x86_64' --name 'Red Hat Enterprise Linux 9 for x86_64 - AppStream (RPMs)' --releasever '9' --basearch 'x86_64'" |
| 77 | +h capsync-23-repo-sync-${rel}appstream.log "repository synchronize --organization '$organization' --product 'Red Hat Enterprise Linux for x86_64' --name 'Red Hat Enterprise Linux 9 for x86_64 - AppStream RPMs 9'" |
| 78 | + |
| 79 | + |
| 80 | +section "Sync Satellite Client repos" |
| 81 | +h capsync-27-client-product-create.log "product create --organization '$organization' --name SatClientProduct" |
| 82 | + |
| 83 | +# Satellite Client for RHEL 6 |
| 84 | +h capsync-28-repository-create-sat-client_6.log "repository create --organization '$organization' --product SatClientProduct --name SatClient6Repo --content-type yum --url '$repo_sat_client_6'" |
| 85 | +h capsync-29-repository-sync-sat-client_6.log "repository synchronize --organization '$organization' --product SatClientProduct --name SatClient6Repo" |
| 86 | + |
| 87 | +# Satellite Client for RHEL 7 |
| 88 | +h capsync-28-repository-create-sat-client_7.log "repository create --organization '$organization' --product SatClientProduct --name SatClient7Repo --content-type yum --url '$repo_sat_client_7'" |
| 89 | +h capsync-29-repository-sync-sat-client_7.log "repository synchronize --organization '$organization' --product SatClientProduct --name SatClient7Repo" |
| 90 | + |
| 91 | +# Satellite Client for RHEL 8 |
| 92 | +h capsync-28-repository-create-sat-client_8.log "repository create --organization '$organization' --product SatClientProduct --name SatClient8Repo --content-type yum --url '$repo_sat_client_8'" |
| 93 | +h capsync-29-repository-sync-sat-client_8.log "repository synchronize --organization '$organization' --product SatClientProduct --name SatClient8Repo" |
| 94 | + |
| 95 | +# Satellite Client for RHEL 9 |
| 96 | +h capsync-28-repository-create-sat-client_9.log "repository create --organization '$organization' --product SatClientProduct --name SatClient9Repo --content-type yum --url '$repo_sat_client_9'" |
| 97 | +h capsync-29-repository-sync-sat-client_9.log "repository synchronize --organization '$organization' --product SatClientProduct --name SatClient9Repo" |
| 98 | + |
| 99 | + |
| 100 | +section "Create LCEs" |
| 101 | +prior='Library' |
| 102 | +for lce in $lces; do |
| 103 | + h capsync-30-${lce}-lce-create.log "lifecycle-environment create --organization '$organization' --prior '$prior' --name '$lce'" |
| 104 | + prior="${lce}" |
| 105 | +done |
| 106 | + |
| 107 | + |
| 108 | +section "Create, publish and promote Operating System related content" |
| 109 | +# RHEL 6 |
| 110 | +rel='rhel6' |
| 111 | +cv="CV_$rel" |
| 112 | +rids="$( get_repo_id 'Red Hat Enterprise Linux Server' 'Red Hat Enterprise Linux 6 Server RPMs x86_64 6Server' )" |
| 113 | + |
| 114 | +h capsync-31-${rel}-cv-create.log "content-view create --organization '$organization' --repository-ids '$rids' --name '$cv'" |
| 115 | +h capsync-32-${rel}-cv-publish.log "content-view publish --organization '$organization' --name '$cv'" |
| 116 | + |
| 117 | +tmp="$( mktemp )" |
| 118 | +h_out "--no-headers --csv content-view version list --organization '$organization' --content-view '$cv'" | grep '^[0-9]\+,' >$tmp |
| 119 | +version="$( head -n1 $tmp | cut -d ',' -f 3 | tr '\n' ',' | sed 's/,$//' )" |
| 120 | +rm -f $tmp |
| 121 | +to_lces='' |
| 122 | +for lce in $lces; do |
| 123 | + to_lces="${to_lces} --to-lifecycle-environment '$lce'" |
| 124 | +done |
| 125 | +h capsync-33-${rel}-${lce}-lce-promote.log "content-view version promote --organization '$organization' --content-view '$cv' --version '$version' $to_lces --force" |
| 126 | + |
| 127 | +# RHEL 7 |
| 128 | +rel='rhel7' |
| 129 | +cv="CV_$rel" |
| 130 | +rids="$( get_repo_id 'Red Hat Enterprise Linux Server' 'Red Hat Enterprise Linux 7 Server RPMs x86_64 7Server' )" |
| 131 | +rids="$rids,$( get_repo_id 'Red Hat Enterprise Linux Server' 'Red Hat Enterprise Linux 7 Server - Extras RPMs x86_64' )" |
| 132 | + |
| 133 | +h capsync-31-${rel}-cv-create.log "content-view create --organization '$organization' --repository-ids '$rids' --name '$cv'" |
| 134 | +h capsync-32-${rel}-cv-publish.log "content-view publish --organization '$organization' --name '$cv'" |
| 135 | + |
| 136 | +tmp="$( mktemp )" |
| 137 | +h_out "--no-headers --csv content-view version list --organization '$organization' --content-view '$cv'" | grep '^[0-9]\+,' >$tmp |
| 138 | +version="$( head -n1 $tmp | cut -d ',' -f 3 | tr '\n' ',' | sed 's/,$//' )" |
| 139 | +rm -f $tmp |
| 140 | +to_lces='' |
| 141 | +for lce in $lces; do |
| 142 | + to_lces="${to_lces} --to-lifecycle-environment '$lce'" |
| 143 | +done |
| 144 | +h capsync-33-${rel}-${lce}-lce-promote.log "content-view version promote --organization '$organization' --content-view '$cv' --version '$version' $to_lces --force" |
| 145 | + |
| 146 | +# RHEL 8 |
| 147 | +rel='rhel8' |
| 148 | +cv="CV_$rel" |
| 149 | +rids="$( get_repo_id 'Red Hat Enterprise Linux for x86_64' 'Red Hat Enterprise Linux 8 for x86_64 - BaseOS RPMs 8' )" |
| 150 | +rids="$rids,$( get_repo_id 'Red Hat Enterprise Linux for x86_64' 'Red Hat Enterprise Linux 8 for x86_64 - AppStream RPMs 8' )" |
| 151 | + |
| 152 | +h capsync-31-${rel}-cv-create.log "content-view create --organization '$organization' --repository-ids '$rids' --name '$cv'" |
| 153 | +h capsync-32-${rel}-cv-publish.log "content-view publish --organization '$organization' --name '$cv'" |
| 154 | + |
| 155 | +tmp="$( mktemp )" |
| 156 | +h_out "--no-headers --csv content-view version list --organization '$organization' --content-view '$cv'" | grep '^[0-9]\+,' >$tmp |
| 157 | +version="$( head -n1 $tmp | cut -d ',' -f 3 | tr '\n' ',' | sed 's/,$//' )" |
| 158 | +rm -f $tmp |
| 159 | +to_lces='' |
| 160 | +for lce in $lces; do |
| 161 | + to_lces="${to_lces} --to-lifecycle-environment '$lce'" |
| 162 | +done |
| 163 | +h capsync-33-${rel}-${lce}-lce-promote.log "content-view version promote --organization '$organization' --content-view '$cv' --version '$version' $to_lces --force" |
| 164 | + |
| 165 | +# RHEL 9 |
| 166 | +rel='rhel9' |
| 167 | +cv="CV_$rel" |
| 168 | +rids="$( get_repo_id 'Red Hat Enterprise Linux for x86_64' 'Red Hat Enterprise Linux 9 for x86_64 - BaseOS RPMs 9' )" |
| 169 | +rids="$rids,$( get_repo_id 'Red Hat Enterprise Linux for x86_64' 'Red Hat Enterprise Linux 9 for x86_64 - AppStream RPMs 9' )" |
| 170 | + |
| 171 | +h capsync-31-${rel}-cv-create.log "content-view create --organization '$organization' --repository-ids '$rids' --name '$cv'" |
| 172 | +h capsync-32-${rel}-cv-publish.log "content-view publish --organization '$organization' --name '$cv'" |
| 173 | + |
| 174 | +tmp="$( mktemp )" |
| 175 | +h_out "--no-headers --csv content-view version list --organization '$organization' --content-view '$cv'" | grep '^[0-9]\+,' >$tmp |
| 176 | +version="$( head -n1 $tmp | cut -d ',' -f 3 | tr '\n' ',' | sed 's/,$//' )" |
| 177 | +rm -f $tmp |
| 178 | +to_lces='' |
| 179 | +for lce in $lces; do |
| 180 | + to_lces="${to_lces} --to-lifecycle-environment '$lce'" |
| 181 | +done |
| 182 | +h capsync-33-${rel}-${lce}-lce-promote.log "content-view version promote --organization '$organization' --content-view '$cv' --version '$version' $to_lces --force" |
| 183 | + |
| 184 | + |
| 185 | +section "Add, publish and promote Satellite Client related content" |
| 186 | +# RHEL 6 |
| 187 | +rel='rhel6' |
| 188 | +cv="CV_$rel" |
| 189 | +rid="$( get_repo_id 'SatClientProduct' 'SatClient6Repo' )" |
| 190 | + |
| 191 | +h capsync-34-${rel}-cv-add-repository.log "content-view add-repository --organization '$organization' --repository-id '$rid' --name '$cv'" |
| 192 | +h capsync-35-${rel}-cv-republish.log "content-view publish --organization '$organization' --name '$cv'" |
| 193 | + |
| 194 | +tmp="$( mktemp )" |
| 195 | +h_out "--no-headers --csv content-view version list --organization '$organization' --content-view '$cv'" | grep '^[0-9]\+,' >$tmp |
| 196 | +version="$( head -n1 $tmp | cut -d ',' -f 3 | tr '\n' ',' | sed 's/,$//' )" |
| 197 | +rm -f $tmp |
| 198 | +to_lces='' |
| 199 | +for lce in $lces; do |
| 200 | + to_lces="${to_lces} --to-lifecycle-environment '$lce'" |
| 201 | +done |
| 202 | +h capsync-36-${rel}-${lce}-lce-promote.log "content-view version promote --organization '$organization' --content-view '$cv' --version '$version' $to_lces --force" |
| 203 | + |
| 204 | +# RHEL 7 |
| 205 | +rel='rhel7' |
| 206 | +cv="CV_$rel" |
| 207 | +rid="$( get_repo_id 'SatClientProduct' 'SatClient7Repo' )" |
| 208 | + |
| 209 | +h capsync-34-${rel}-cv-add-repository.log "content-view add-repository --organization '$organization' --repository-id '$rid' --name '$cv'" |
| 210 | +h capsync-35-${rel}-cv-republish.log "content-view publish --organization '$organization' --name '$cv'" |
| 211 | + |
| 212 | +tmp="$( mktemp )" |
| 213 | +h_out "--no-headers --csv content-view version list --organization '$organization' --content-view '$cv'" | grep '^[0-9]\+,' >$tmp |
| 214 | +version="$( head -n1 $tmp | cut -d ',' -f 3 | tr '\n' ',' | sed 's/,$//' )" |
| 215 | +rm -f $tmp |
| 216 | +to_lces='' |
| 217 | +for lce in $lces; do |
| 218 | + to_lces="${to_lces} --to-lifecycle-environment '$lce'" |
| 219 | +done |
| 220 | +h capsync-36-${rel}-${lce}-lce-promote.log "content-view version promote --organization '$organization' --content-view '$cv' --version '$version' $to_lces --force" |
| 221 | + |
| 222 | +# RHEL 8 |
| 223 | +rel='rhel8' |
| 224 | +cv="CV_$rel" |
| 225 | +rid="$( get_repo_id 'SatClientProduct' 'SatClient8Repo' )" |
| 226 | + |
| 227 | +h capsync-34-${rel}-cv-add-repository.log "content-view add-repository --organization '$organization' --repository-id '$rid' --name '$cv'" |
| 228 | +h capsync-35-${rel}-cv-republish.log "content-view publish --organization '$organization' --name '$cv'" |
| 229 | + |
| 230 | +tmp="$( mktemp )" |
| 231 | +h_out "--no-headers --csv content-view version list --organization '$organization' --content-view '$cv'" | grep '^[0-9]\+,' >$tmp |
| 232 | +version="$( head -n1 $tmp | cut -d ',' -f 3 | tr '\n' ',' | sed 's/,$//' )" |
| 233 | +rm -f $tmp |
| 234 | +to_lces='' |
| 235 | +for lce in $lces; do |
| 236 | + to_lces="${to_lces} --to-lifecycle-environment '$lce'" |
| 237 | +done |
| 238 | +h capsync-36-${rel}-${lce}-lce-promote.log "content-view version promote --organization '$organization' --content-view '$cv' --version '$version' $to_lces --force" |
| 239 | + |
| 240 | +# RHEL 9 |
| 241 | +rel='rhel9' |
| 242 | +cv="CV_$rel" |
| 243 | +rid="$( get_repo_id 'SatClientProduct' 'SatClient9Repo' )" |
| 244 | + |
| 245 | +h capsync-34-${rel}-cv-add-repository.log "content-view add-repository --organization '$organization' --repository-id '$rid' --name '$cv'" |
| 246 | +h capsync-35-${rel}-cv-republish.log "content-view publish --organization '$organization' --name '$cv'" |
| 247 | + |
| 248 | +tmp="$( mktemp )" |
| 249 | +h_out "--no-headers --csv content-view version list --organization '$organization' --content-view '$cv'" | grep '^[0-9]\+,' >$tmp |
| 250 | +version="$( head -n1 $tmp | cut -d ',' -f 3 | tr '\n' ',' | sed 's/,$//' )" |
| 251 | +rm -f $tmp |
| 252 | +to_lces='' |
| 253 | +for lce in $lces; do |
| 254 | + to_lces="${to_lces} --to-lifecycle-environment '$lce'" |
| 255 | +done |
| 256 | +h capsync-36-${rel}-${lce}-lce-promote.log "content-view version promote --organization '$organization' --content-view '$cv' --version '$version' $to_lces --force" |
| 257 | + |
| 258 | + |
| 259 | +section "Push content to capsules" |
| 260 | +num_capsules="$(ansible -i $inventory --list-hosts capsules 2>/dev/null | grep -vc '^ hosts ')" |
| 261 | + |
| 262 | +for (( iter=0, last=-1; last < (num_capsules - 1); iter++ )); do |
| 263 | + if (( initial_index == 0 && iter == 0 )); then |
| 264 | + continue |
| 265 | + else |
| 266 | + first="$(( last + 1 ))" |
| 267 | + incr="$(( initial_index + iter - 1 ))" |
| 268 | + last="$(( first + incr ))" |
| 269 | + if (( last >= num_capsules )); then |
| 270 | + last="$(( num_capsules - 1 ))" |
| 271 | + fi |
| 272 | + limit="${first}:${last}" |
| 273 | + num_concurrent_capsules="$(( last - first + 1 ))" |
| 274 | + ap capsync-40-populate-${iter}.log \ |
| 275 | + --limit capsules["$limit"] \ |
| 276 | + -e "organization='$organization'" \ |
| 277 | + -e "lces='$lces'" \ |
| 278 | + -e "num_concurrent_capsules='$num_concurrent_capsules'" \ |
| 279 | + playbooks/satellite/capsules-populate.yaml |
| 280 | + fi |
| 281 | +done |
| 282 | + |
| 283 | + |
| 284 | +section "Sosreport" |
| 285 | +skip_measurement='true' ap sosreporter-gatherer.log \ |
| 286 | + -e "sosreport_gatherer_local_dir='../../$logs/sosreport/'" \ |
| 287 | + playbooks/satellite/sosreport_gatherer.yaml |
| 288 | + |
| 289 | + |
| 290 | +junit_upload |
0 commit comments