From 5266e37f8eb8298a1a2ec2d774aa77e094f1d45e Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Mon, 15 May 2017 16:31:10 +0200 Subject: [PATCH 01/23] echo -> info when checking MODIFIED_CONTENT_FILE --- publishcv.sh | 2 +- puppetpush.sh | 2 +- rpmpush.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/publishcv.sh b/publishcv.sh index 68986df..4a58f50 100755 --- a/publishcv.sh +++ b/publishcv.sh @@ -14,7 +14,7 @@ # has anything changed? If yes, then MODIFIED_CONTENT_FILE is not 0 bytes if [[ ! -s "${MODIFIED_CONTENT_FILE}" ]] then - echo "No entries in ${MODIFIED_CONTENT_FILE} no need to continue with $0" + info "No entries in ${MODIFIED_CONTENT_FILE} no need to continue with $0" exit 0 fi diff --git a/puppetpush.sh b/puppetpush.sh index 931446c..8aaa9c2 100755 --- a/puppetpush.sh +++ b/puppetpush.sh @@ -17,7 +17,7 @@ fi # has anything changed? If yes, then MODIFIED_CONTENT_FILE is not 0 bytes if [[ ! -s "${MODIFIED_CONTENT_FILE}" ]] then - echo "No entries in ${MODIFIED_CONTENT_FILE} no need to continue with $0" + info "No entries in ${MODIFIED_CONTENT_FILE} no need to continue with $0" exit 0 fi diff --git a/rpmpush.sh b/rpmpush.sh index 0ccbb82..559e388 100755 --- a/rpmpush.sh +++ b/rpmpush.sh @@ -11,7 +11,7 @@ # has anything changed? If yes, then MODIFIED_CONTENT_FILE is not 0 bytes if [[ ! -s "${MODIFIED_CONTENT_FILE}" ]] then - echo "No entries in ${MODIFIED_CONTENT_FILE} no need to continue with $0" + info "No entries in ${MODIFIED_CONTENT_FILE} no need to continue with $0" exit 0 fi From 74ca304b7f56a62674d5728066cbd87d1e2bd4b8 Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Mon, 15 May 2017 16:51:35 +0200 Subject: [PATCH 02/23] fold at 240 columns instead of 80 --- common.sh | 2 +- pushtests.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common.sh b/common.sh index 83a7adf..a3074dd 100755 --- a/common.sh +++ b/common.sh @@ -12,7 +12,7 @@ SRPMBUILD_ERR=6 MODBUILD_ERR=7 function tell() { - echo "${@} [$(date)]" | fold -s + echo "${@} [$(date)]" | fold --spaces --width=240 } function info() { diff --git a/pushtests.sh b/pushtests.sh index e606cdc..8ad301d 100755 --- a/pushtests.sh +++ b/pushtests.sh @@ -22,7 +22,7 @@ do info "Waiting 10 seconds" for I in "${vmcopy[@]}" do - echo -n "Checking if test server $I has rebuilt... (Sat 6.2 style)" + info "Checking if test server $I has rebuilt... (Sat 6.2 style)" status=$(ssh -q -l ${PUSH_USER} -i ${RSA_ID} ${SATELLITE} \ "hammer host info --name $I | \ grep -e \"Managed.*yes\" -e \"Enabled.*yes\" -e \"Build.*no\" \ From e134fe6fe84082876c3f5d7fb5a346c738bdd2e2 Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Sun, 14 May 2017 21:34:51 +0200 Subject: [PATCH 03/23] copy of config.xml but with RPM part removed --- config-puppet-only.xml | 240 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 240 insertions(+) create mode 100644 config-puppet-only.xml diff --git a/config-puppet-only.xml b/config-puppet-only.xml new file mode 100644 index 0000000..ce9162a --- /dev/null +++ b/config-puppet-only.xml @@ -0,0 +1,240 @@ + + + + Generic plan to create puppet module environments + false + + + + 7 + 100 + -1 + -1 + + + + + + PUSH_USER + The username to use when pushing artefacts to the satellite. The build job will need to be able to ssh to the satellite as this user so you need to have keys set up. + jenkins + + + RSA_ID + RSA ID of the Jenkins user. + /var/lib/jenkins/.ssh/id_rsa + + + KNOWN_HOSTS + Known hosts file of the Jenkins user. + /var/lib/jenkins/.ssh/known_hosts + + + SATELLITE + The FQDN of the Red Hat Satellite. + satellite.example.com + + + ORG + This is the name of the organisation you are using on the Red Hat Satellite. + Default_Organization + + + PUPPET_REPO_ID + The numeric ID of the puppet module repository on the Red Hat Satellite that you want to use for your custom puppet modules. + + + + TESTVM_HOSTCOLLECTION + The name of the Satellite 6 host collection containing your test machines. + Test Servers puppet only + + + TESTVM_ENV + The numeric ID of the environment you want to promote CI builds to. This will typically be a 'Crash' or 'EngTest' environment. + +You can find the IDs of your environments using: +hammer lifecycle-environment list --organization "Default_Organization" + + + + TEST_ROOT + This is the root password of your test machines, as set in your hostgroup definition. + redhat + + + MODAUTHOR + This is the authorname for your puppet modules. + acme + + + PUPPET_REPO + This is the location of the puppet repository on the Jenkins server used to export puppet modules to the satellite server. + /var/www/html/pub/soe-puppet-only + + + CV + This is the name of the Content View on the satellite that you want to publish your build into. + cv-puppet-only + + + CV_PASSIVE_LIST + A comma separated list of content view names to publish and optionally promote as part of the build. +Those CVs won't get new Puppet Modules assigned to them, meaning you must (and are free to) assign (and unassign) them yourself directly in Satellite. + + + + CCV_NAME_PATTERN + Enter here a name pattern if you want Composite Content Views using the given CV(s) to be updated with the latest version and as well published and promoted. +CCVs respecting the pattern but not containing any CV will not be touched. +Example of pattern: "ccv-test-*" + + + + CONDITIONAL_VM_BUILD + If this parameter is true/set, only the hosts existing in Satellite with a comment matching +the modified Puppet module, RPM package or kickstart file, each surrounded by hashes (#), will be built and tested. +<br/> +Examples: <code>#ssh#bats#kickstart.erb#</code> +<br/> +<b>CAUTION:</b> be aware that in this case, no host will be tested if only the scripts have been modified. +<br/> +If unset/false, all existing hosts, within the given Host Collection, will be rebuilt independent of changes done in Git. + true + + + MOCK_CONFIG + This will be passed to mock --root +e.g. mock --root rhel-6-x86_64 +needed to ensure we can build RPMs against more then just the default mock chroot. + rhel-7-x86_64 + + + + + + + + 2 + + + git@localhost:soe-ci.git + + + + + */master + + + false + + + + scripts + + + + + 2 + + + git@localhost:acme-soe.git + + + + + */master + + + false + + + + soe + + + + + + true + false + false + false + + + * * * * * + false + + + false + + + echo "#####################################################" +echo "# BUILDING PUPPET MODULES #" +echo "#####################################################" +/bin/bash -x ${WORKSPACE}/scripts/puppetbuild.sh ${WORKSPACE}/soe/puppet + + + + echo "#####################################################" +echo "# PUSH PUPPET MODULES TO SATELLITE #" +echo "#####################################################" +/bin/bash -x ${WORKSPACE}/scripts/puppetpush.sh ${WORKSPACE}/artefacts +echo "#####################################################" +echo "# REPUBLISH CONTENT VIEW #" +echo "#####################################################" +/bin/bash -x ${WORKSPACE}/scripts/publishcv.sh + + + echo "#####################################################" +echo "# NOT REBUILDING TEST VMS #" +echo "#####################################################" + +### +### do a puppety apply though +### +#/bin/bash -x ${WORKSPACE}/scripts/buildtestvms.sh + + + + echo "#####################################################" +echo "# PUSHING TESTS to TEST VMS #" +echo "#####################################################" +/bin/bash -x ${WORKSPACE}/scripts/pushtests.sh + + + + + + test_results/*.tap + false + false + false + false + true + false + false + false + true + true + false + false + false + false + + + + + echo "#####################################################" +echo "# CLEAN-UP AFTER SUCCESS BUILD #" +echo "#####################################################" +/bin/bash -x ${WORKSPACE}/scripts/cleanup.sh + + + true + false + false + + + + From fafc741d4c26ddea2958a9d09dfeaa44a2e142c0 Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Mon, 15 May 2017 11:53:26 +0200 Subject: [PATCH 04/23] added one forced puppet run before we start waiting --- pushtests.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pushtests.sh b/pushtests.sh index 8ad301d..a167423 100755 --- a/pushtests.sh +++ b/pushtests.sh @@ -68,6 +68,10 @@ do scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ${RSA_ID} \ ${WORKSPACE}/scripts/puppet-done-test.sh root@$I: + # run puppet once, this will skip if puppet already running, so no need for if clause + ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ${RSA_ID} root@$I \ + "puppet agent -t" + # wait for puppet to finish ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ${RSA_ID} root@$I \ "/root/puppet-done-test.sh" From 23df4e44569796a691bdd376ddea73b686b4891c Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Mon, 15 May 2017 12:56:30 +0200 Subject: [PATCH 05/23] adjusted copy of buildtestvms.sh --- starttestvms.sh | 79 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100755 starttestvms.sh diff --git a/starttestvms.sh b/starttestvms.sh new file mode 100755 index 0000000..dab5250 --- /dev/null +++ b/starttestvms.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +# Instruct Foreman to start the test VMs (just in case they are off) +# +# e.g ${WORKSPACE}/scripts/starttestvms.sh 'test' +# +# this will tell Foreman to rebuild all machines in hostgroup TESTVM_HOSTGROUP + +# Load common parameter variables +. $(dirname "${0}")/common.sh + +if [[ -z ${PUSH_USER} ]] || [[ -z ${SATELLITE} ]] || [[ -z ${RSA_ID} ]] \ + || [[ -z ${ORG} ]] || [[ -z ${TESTVM_HOSTCOLLECTION} ]] +then + err "Environment variable PUSH_USER, SATELLITE, RSA_ID, ORG " \ + "or TESTVM_HOSTCOLLECTION not set or not found." + exit ${WORKSPACE_ERR} +fi + +get_test_vm_list # populate TEST_VM_LIST + +# TODO: Error out if no test VM's are available. +if [ $(echo ${#TEST_VM_LIST[@]}) -eq 0 ]; then + err "No test VMs configured in Satellite" +fi + +# rebuild test VMs +for I in "${TEST_VM_LIST[@]}" +do + info "Making sure VM ID $I is on" + + _PROBED_STATUS=$(ssh -q -l ${PUSH_USER} -i ${RSA_ID} ${SATELLITE} "hammer host status --id $I" | grep Power | cut -f2 -d: | tr -d ' ') + + # different hypervisors report power status with different words. parse and get a single word per status + # KVM uses running / shutoff + # VMware uses poweredOn / poweredOff + # add other hypervisors as you come across them and please submit to https://github.com/RedHatEMEA/soe-ci + + case "${_PROBED_STATUS}" in + running) + _STATUS=On + ;; + poweredOn) + _STATUS=On + ;; + up) + _STATUS=On + ;; + shutoff) + _STATUS=Off + ;; + poweredOff) + _STATUS=Off + ;; + down) + _STATUS=Off + ;; + off) + _STATUS=Off + ;; + *) + echo "can not parse power status, please review $0" + esac + + if [[ ${_STATUS} == 'On' ]] + then + info "Host $I is already on." + elif [[ ${_STATUS} == 'Off' ]] + then + info "Host $I is already off, switching it on." + ssh -q -l ${PUSH_USER} -i ${RSA_ID} ${SATELLITE} \ + "hammer host start --id $I" + else + err "Host $I is neither running nor shutoff. No action possible!" + # exit 0 while testingi for issue #50, + # allows for manual rebooting of the test VM(s) + exit 0 + fi +done From 9148467b4a664e06ab512a16dc17506f69e463df Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Mon, 22 Aug 2016 17:28:34 +0200 Subject: [PATCH 06/23] added off for libvirt to buildtestvms.sh --- buildtestvms.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/buildtestvms.sh b/buildtestvms.sh index 34e85df..8686d83 100755 --- a/buildtestvms.sh +++ b/buildtestvms.sh @@ -36,6 +36,7 @@ do # different hypervisors report power status with different words. parse and get a single word per status # KVM uses running / shutoff # VMware uses poweredOn / poweredOff + # libvirt uses running / off # add other hypervisors as you come across them and please submit to https://github.com/RedHatEMEA/soe-ci case "${_PROBED_STATUS}" in @@ -45,7 +46,7 @@ do poweredOn) _STATUS=On ;; - up) + up) _STATUS=On ;; shutoff) @@ -57,6 +58,9 @@ do down) _STATUS=Off ;; + off) + _STATUS=Off + ;; *) echo "can not parse power status, please review $0" esac From cb38bc58274a4a1f644f5658b6104ceb1899a17b Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Mon, 15 May 2017 13:23:36 +0200 Subject: [PATCH 07/23] introduce sleep flag to puppet-done-test.sh --- puppet-done-test.sh | 35 +++++++++++++++++++++++++++++++---- pushtests.sh | 2 +- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/puppet-done-test.sh b/puppet-done-test.sh index 3c175a0..4310912 100755 --- a/puppet-done-test.sh +++ b/puppet-done-test.sh @@ -1,5 +1,19 @@ #!/bin/bash +NO_ARGS=0 +OPTERROR=65 + +usage() +{ + echo "Usage: $0 -s " + echo " s = number of seconds to sleep" + exit 1 +} +if [ $# -eq "$NO_ARGS" ] +then + usage +fi + look_for_state() { while [[ ! -d /var/lib/puppet/state ]] @@ -43,10 +57,23 @@ look_for_finished() date -# waiting just over one minute for puppet to start -# this script gets run on first boot after a system was installed -echo "waiting 75 seconds (one minute and a bit) before checking on puppet" -sleep 75 +while getopts "c:n:s:h" Option +do + case $Option in + s) SLEEP=${OPTARG} + ;; + h) + usage + ;; + *) echo "Non valid switch" + ;; + esac +done + +# if you run puppet on boot, sleep 75 seconds (just over a minute) +# if this is a run in the puppet only workflow, no real need to sleep +echo "waiting ${SLEEP} seconds before checking on puppet" +sleep ${SLEEP} # /var/lib/puppet/state gets created on first run? look_for_state diff --git a/pushtests.sh b/pushtests.sh index a167423..e3878ee 100755 --- a/pushtests.sh +++ b/pushtests.sh @@ -74,7 +74,7 @@ do # wait for puppet to finish ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ${RSA_ID} root@$I \ - "/root/puppet-done-test.sh" + "/root/puppet-done-test.sh -s ${PUPPET_DONE_SLEEP}" info "Installing bats and rsync on test server $I" if ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i ${RSA_ID} root@$I \ From 9bf8a6b025739251cf98da525810a0772e412da1 Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Mon, 15 May 2017 15:14:09 +0200 Subject: [PATCH 08/23] adjusted copy of buildtestvms.sh --- powerofftestvms.sh | 80 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100755 powerofftestvms.sh diff --git a/powerofftestvms.sh b/powerofftestvms.sh new file mode 100755 index 0000000..7794e5d --- /dev/null +++ b/powerofftestvms.sh @@ -0,0 +1,80 @@ +#!/bin/bash + +# power off the test VMs +# hammer (without the --force flag) will attempt a clean shutdown +# +# e.g ${WORKSPACE}/scripts/powerofftestvms.sh 'test' +# + +# Load common parameter variables +. $(dirname "${0}")/common.sh + +if [[ -z ${PUSH_USER} ]] || [[ -z ${SATELLITE} ]] || [[ -z ${RSA_ID} ]] \ + || [[ -z ${ORG} ]] || [[ -z ${TESTVM_HOSTCOLLECTION} ]] +then + err "Environment variable PUSH_USER, SATELLITE, RSA_ID, ORG " \ + "or TESTVM_HOSTCOLLECTION not set or not found." + exit ${WORKSPACE_ERR} +fi + +get_test_vm_list # populate TEST_VM_LIST + +# TODO: Error out if no test VM's are available. +if [ $(echo ${#TEST_VM_LIST[@]}) -eq 0 ]; then + err "No test VMs configured in Satellite" +fi + +# shutdown test VMs +for I in "${TEST_VM_LIST[@]}" +do + info "Checking status of VM ID $I" + + _PROBED_STATUS=$(ssh -q -l ${PUSH_USER} -i ${RSA_ID} ${SATELLITE} "hammer host status --id $I" | grep Power | cut -f2 -d: | tr -d ' ') + + # different hypervisors report power status with different words. parse and get a single word per status + # KVM uses running / shutoff + # VMware uses poweredOn / poweredOff + # libvirt uses running / off + # add other hypervisors as you come across them and please submit to https://github.com/RedHatEMEA/soe-ci + + case "${_PROBED_STATUS}" in + running) + _STATUS=On + ;; + poweredOn) + _STATUS=On + ;; + up) + _STATUS=On + ;; + shutoff) + _STATUS=Off + ;; + poweredOff) + _STATUS=Off + ;; + down) + _STATUS=Off + ;; + off) + _STATUS=Off + ;; + *) + echo "can not parse power status, please review $0" + esac + + if [[ ${_STATUS} == 'On' ]] + then + info "Shutting down VM ID $I" + ssh -q -l ${PUSH_USER} -i ${RSA_ID} ${SATELLITE} \ + "hammer host stop --id $I" + elif [[ ${_STATUS} == 'Off' ]] + then + info "VM ID $I seems off already, no action done." + else + err "Host $I is neither running nor shutoff. No action possible!" + # exit 0 while testingi for issue #50, + # allows for manual rebooting of the test VM(s) + exit 0 + fi +done From e92921479cfc10235e6badded1f981a6f64675eb Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Mon, 15 May 2017 18:28:56 +0200 Subject: [PATCH 09/23] wait 30 seconds betwen checks, and wait after instead of before the check --- pushtests.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pushtests.sh b/pushtests.sh index e3878ee..805ecfb 100755 --- a/pushtests.sh +++ b/pushtests.sh @@ -17,9 +17,6 @@ for I in "${TEST_VM_LIST[@]}"; do vmcopy[$I]=$I; done WAIT=0 while [[ ${#vmcopy[@]} -gt 0 ]] do - sleep 10 - ((WAIT+=10)) - info "Waiting 10 seconds" for I in "${vmcopy[@]}" do info "Checking if test server $I has rebuilt... (Sat 6.2 style)" @@ -33,7 +30,9 @@ do tell "Success!" unset vmcopy[$I] else - tell "Not yet." + tell "Not yet. Sleeping 30 seconds." + sleep 30 + ((WAIT+=30)) fi done if [[ ${WAIT} -gt 6000 ]] From b8cfea0d316dbaecf3910c3d535660f750254cc6 Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Mon, 15 May 2017 21:39:16 +0200 Subject: [PATCH 10/23] as used in testing on home server, add power control --- config-puppet-only.xml | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/config-puppet-only.xml b/config-puppet-only.xml index ce9162a..b84f8d1 100644 --- a/config-puppet-only.xml +++ b/config-puppet-only.xml @@ -109,6 +109,12 @@ e.g. mock --root rhel-6-x86_64 needed to ensure we can build RPMs against more then just the default mock chroot. rhel-7-x86_64 + + PUPPET_DONE_SLEEP + Number of seconds to wait in puppet-done-test.sh +if you set up things with puppet that take a while to settle (e.g. NTP), you may want to wait a bit (e.g. 75 seconds is good for ntp to settle) + 0 + @@ -187,13 +193,10 @@ echo "#####################################################" echo "#####################################################" -echo "# NOT REBUILDING TEST VMS #" +echo "# MAKING SURE TEST VMs ARE ON #" echo "#####################################################" -### -### do a puppety apply though -### -#/bin/bash -x ${WORKSPACE}/scripts/buildtestvms.sh +/bin/bash ${WORKSPACE}/scripts/starttestvms.sh @@ -226,6 +229,12 @@ echo "#####################################################" echo "#####################################################" +echo "# POWER OFF TEST VMs #" +echo "#####################################################" +/bin/bash ${WORKSPACE}/scripts/powerofftestvms.sh + + + echo "#####################################################" echo "# CLEAN-UP AFTER SUCCESS BUILD #" echo "#####################################################" /bin/bash -x ${WORKSPACE}/scripts/cleanup.sh From 5bd61edda7eb1ef5bca946cd33c98d262b5eb6c1 Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Mon, 15 May 2017 23:38:56 +0200 Subject: [PATCH 11/23] as used in testing on home server, add power control --- config.xml | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/config.xml b/config.xml index aaec861..7446693 100644 --- a/config.xml +++ b/config.xml @@ -4,6 +4,14 @@ Generic plan to create Red Hat Enterprise Linux builds false + + + 60 + 30 + -1 + -1 + + @@ -107,9 +115,15 @@ If unset/false, all existing hosts, within the given Host Collection, will be re MOCK_CONFIG This will be passed to mock --root -e.g. mock --root rhel-6-x86_64 +e.g. mock --root rhel-7-x86_64 needed to ensure we can build RPMs against more then just the default mock chroot. - rhel-6-x86_64 + rhel-7-x86_64 + + + PUPPET_DONE_SLEEP + Number of seconds to wait in puppet-done-test.sh +if you set up things with puppet that take a while to settle (e.g. NTP), you may want to wait a bit (e.g. 75 seconds is good for ntp to settle) + 75 @@ -163,8 +177,11 @@ needed to ensure we can build RPMs against more then just the default mock chroo false false + + H H(3-5) * * * + - * * * * * + * * * * * false @@ -238,9 +255,21 @@ echo "#####################################################" echo "#####################################################" +echo "# POWER OFF TEST VMs #" +echo "#####################################################" +/bin/bash ${WORKSPACE}/scripts/powerofftestvms.sh + + + echo "#####################################################" echo "# CLEAN-UP AFTER SUCCESS BUILD #" echo "#####################################################" -/bin/bash -x ${WORKSPACE}/scripts/cleanup.sh +/bin/bash -x ${WORKSPACE}/scripts/cleanup.sh + +echo "#####################################################" +echo "# run cvmanager #" +echo "# on Satellite or Jenkins box? #" +echo "#####################################################" + true From 1297df091523584c4ebc1a60393fc0adaed624d7 Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Sun, 14 May 2017 22:32:53 +0200 Subject: [PATCH 12/23] doc only - Satellite 6.2 has been a minimum requirement since 2016-11-23 added that info to the docs too - clarified Jenkins and mock setup - added setup steps for puppet only workflow --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 4363eaf..37bbc5c 100644 --- a/README.md +++ b/README.md @@ -87,8 +87,10 @@ NB I have SELinux disabled on the Jenkins server as I ran into too many problems * Restart Jenkins * Add the `jenkins` user to the `mock` group (`usermod -a -G mock jenkins`). This will allow Jenkins to build RPMs. * Create `/var/www/html/pub/soe-repo` and `/var/www/html/pub/soe-puppet` and assign their ownership to the `jenkins` user. These will be used as the upstream repositories to publish artefacts to the satellite. + * Create `/var/www/html/pub/soe-puppet-only` for the puppet only workflow and assign their ownership to the `jenkins` user. These serve for the puppet only workflow. * `su` to the `jenkins` user (`su jenkins -s /bin/bash`) and use `ssh-keygen` to create an ssh keypair. These will be used for authentication to both the git repository, and to the satellite server. * Create one build plan per release you want to build for in Jenkins by creating the directory `/var/lib/jenkins/jobs/SOE- (e.g. SOE-el7)` and copying in the [config.xml] file + * create a similar build plan for the puppet only workflow, omitting the RPM stuff. * Check that the build plan is visible and correct via the Jenkins UI, you will surely need to adapt the parameter values to your environment. * you might need to reload the configuration from disk using 'Manage Jenkins -> Reload Configuration from Disk'. From 537782f16c58ca32ac4660f8fb7e02bdc54deec5 Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Tue, 16 May 2017 15:22:42 +0200 Subject: [PATCH 13/23] removed tight polling used during testing --- config.xml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/config.xml b/config.xml index 7446693..ce4ae1d 100644 --- a/config.xml +++ b/config.xml @@ -180,10 +180,6 @@ if you set up things with puppet that take a while to settle (e.g. NTP), you may H H(3-5) * * * - - * * * * * - false - false From e32d57b9ebe7a7127295fc97e4e6d47ee6105e89 Mon Sep 17 00:00:00 2001 From: Janine Eichler Date: Sun, 18 Jun 2017 00:07:52 +0200 Subject: [PATCH 14/23] replaced post build action with conditional build step (#69) tested, fixes #67 in master thank you --- config-puppet-only.xml | 52 +++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 21 deletions(-) diff --git a/config-puppet-only.xml b/config-puppet-only.xml index b84f8d1..6efca00 100644 --- a/config-puppet-only.xml +++ b/config-puppet-only.xml @@ -185,7 +185,7 @@ echo "#####################################################" echo "#####################################################" echo "# PUSH PUPPET MODULES TO SATELLITE #" echo "#####################################################" -/bin/bash -x ${WORKSPACE}/scripts/puppetpush.sh ${WORKSPACE}/artefacts +/bin/bash -x ${WORKSPACE}/scripts/puppetpush.sh ${WORKSPACE}/artefacts echo "#####################################################" echo "# REPUBLISH CONTENT VIEW #" echo "#####################################################" @@ -203,9 +203,38 @@ echo "#####################################################" echo "#####################################################" echo "# PUSHING TESTS to TEST VMS #" echo "#####################################################" -/bin/bash -x ${WORKSPACE}/scripts/pushtests.sh +/bin/bash -x ${WORKSPACE}/scripts/pushtests.sh + + + + SUCCESS + 0 + BLUE + true + + + SUCCESS + 0 + BLUE + true + + + + echo "#####################################################" +echo "# POWER OFF TEST VMs #" +echo "#####################################################" +/bin/bash ${WORKSPACE}/scripts/powerofftestvms.sh + +echo "#####################################################" +echo "# CLEAN-UP AFTER SUCCESS BUILD #" +echo "#####################################################" +/bin/bash -x ${WORKSPACE}/scripts/cleanup.sh + + + + @@ -225,25 +254,6 @@ echo "#####################################################" false false - - - - echo "#####################################################" -echo "# POWER OFF TEST VMs #" -echo "#####################################################" -/bin/bash ${WORKSPACE}/scripts/powerofftestvms.sh - - - echo "#####################################################" -echo "# CLEAN-UP AFTER SUCCESS BUILD #" -echo "#####################################################" -/bin/bash -x ${WORKSPACE}/scripts/cleanup.sh - - - true - false - false - From 933767eb86498d58036bd8c4ff44915b7bffbb79 Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Sun, 25 Jun 2017 14:58:34 +0200 Subject: [PATCH 15/23] SELinux on Jenkins server works just fine --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 37bbc5c..8fdef48 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ The following steps should help you get started with CII. ### Jenkins Server -NB I have SELinux disabled on the Jenkins server as I ran into too many problems with it enabled and didn't have the time to fix them. +NB SELinux in _Enforcing_ mode with the RHEL7 _Targeted_ policy works just fine, #### Installation From 0ebca8fc91253dc97ea406c5d44d1423d2b3751a Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Sun, 25 Jun 2017 15:22:22 +0200 Subject: [PATCH 16/23] add link to yEd --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8fdef48..de15c37 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ The CII system consists of the following components: * Red Hat Satellite 6. This acts as the repository for Red Hat-provided and 3rd party packages, kickstarts and puppet modules. The Foreman module is also used to deploy test clients. * A virtualisation infrastructure to run test clients. I have used KVM/Libvirt, VMware and RHEV in different engagements. -The architecture is shown in [this YeD diagram](https://github.com/RedHatEMEA/soe-ci/blob/master/Engineering%20Platform.graphml). +The architecture is shown in [this YeD diagram](https://github.com/RedHatEMEA/soe-ci/blob/master/Engineering%20Platform.graphml). View it with [yEd](http://www.yworks.com/downloads#yEdLive). ## Setup The following steps should help you get started with CII. From 6e28d7aba372ab0ac8e7b4e90006660ab3a9e05e Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Sun, 25 Jun 2017 15:28:43 +0200 Subject: [PATCH 17/23] puppet-only workflow makes this rev 0.4 --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index de15c37..ee46020 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,15 @@ Continuous Integration Scripts for Satellite 6 ============================================== +- - - + +* Author: Patrick C. F. Ernzer +* Email: +* Revision: 0.4 +* Add puppet-only workflow + +- - - + * Domain Architect: Eric Lavarde * Email: * Consultant: Patrick C. F. Ernzer From a5d5a8ba17b99fc2888c065eb69de4437a7862fc Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Sun, 25 Jun 2017 18:18:12 +0200 Subject: [PATCH 18/23] clarify output --- starttestvms.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/starttestvms.sh b/starttestvms.sh index dab5250..2d7de5d 100755 --- a/starttestvms.sh +++ b/starttestvms.sh @@ -67,7 +67,7 @@ do info "Host $I is already on." elif [[ ${_STATUS} == 'Off' ]] then - info "Host $I is already off, switching it on." + info "Host $I is off, switching it on." ssh -q -l ${PUSH_USER} -i ${RSA_ID} ${SATELLITE} \ "hammer host start --id $I" else From f2ce0679e985b45acfeda88fb30651f8755ad86b Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Tue, 27 Jun 2017 15:26:47 +0200 Subject: [PATCH 19/23] =?UTF-8?q?typo=20fixed;=20>>=20not=20=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- puppetbuild.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/puppetbuild.sh b/puppetbuild.sh index 1ab8789..569f2ef 100755 --- a/puppetbuild.sh +++ b/puppetbuild.sh @@ -49,7 +49,7 @@ function build_puppetmodule { # Something has changed, track it for build and for tests echo ${git_commit} > .puppetbuild-hash echo "#${modname}#" >> "${MODIFIED_CONTENT_FILE}" - echo "${modname}" ยป "${MODIFIED_PUPPET_FILE}" + echo "${modname}" >> "${MODIFIED_PUPPET_FILE}" else info "No changes since last build - skipping ${METADATA}" fi From 82c6feb2b42e6faadcdc9d0cd29adc1ed916284d Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Wed, 28 Jun 2017 17:41:30 +0200 Subject: [PATCH 20/23] force immediate poweroff of SUT plus note RHBZ 1417976 --- buildtestvms.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/buildtestvms.sh b/buildtestvms.sh index 8686d83..92da371 100755 --- a/buildtestvms.sh +++ b/buildtestvms.sh @@ -67,8 +67,11 @@ do if [[ ${_STATUS} == 'On' ]] then + # forcefully poweroff the SUT + # note that until Bug 1417976 is fixed this resets on vmware + # and thus the start command will throw an error ssh -q -l ${PUSH_USER} -i ${RSA_ID} ${SATELLITE} \ - "hammer host stop --id $I" + "hammer host stop --force --id $I" sleep 10 ssh -q -l ${PUSH_USER} -i ${RSA_ID} ${SATELLITE} \ "hammer host start --id $I" From dcdc7e4cfd312cb8850e6b0e55cd68e61fd1f455 Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Fri, 30 Jun 2017 12:03:05 +0200 Subject: [PATCH 21/23] fixup --- buildtestvms.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/buildtestvms.sh b/buildtestvms.sh index 92da371..9c9083d 100755 --- a/buildtestvms.sh +++ b/buildtestvms.sh @@ -68,13 +68,13 @@ do if [[ ${_STATUS} == 'On' ]] then # forcefully poweroff the SUT - # note that until Bug 1417976 is fixed this resets on vmware - # and thus the start command will throw an error + # note that until Bug 1417976 is fixed this resets + # and thus the start command needs to be skipped ssh -q -l ${PUSH_USER} -i ${RSA_ID} ${SATELLITE} \ "hammer host stop --force --id $I" - sleep 10 - ssh -q -l ${PUSH_USER} -i ${RSA_ID} ${SATELLITE} \ - "hammer host start --id $I" + #sleep 10 + #ssh -q -l ${PUSH_USER} -i ${RSA_ID} ${SATELLITE} \ + # "hammer host start --id $I" elif [[ ${_STATUS} == 'Off' ]] then ssh -q -l ${PUSH_USER} -i ${RSA_ID} ${SATELLITE} \ From 3e125d4f1d8a54d2666139081499a4190d669ccd Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Tue, 10 Jul 2018 19:51:33 +0200 Subject: [PATCH 22/23] adjust hammer command for Sat 6.3.2 --- pushtests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pushtests.sh b/pushtests.sh index 1d3f8fa..f8bd398 100755 --- a/pushtests.sh +++ b/pushtests.sh @@ -54,7 +54,7 @@ do # Check the host's entitlements info "Checking entitlements for test server $I" ssh -q -l ${PUSH_USER} -i ${RSA_ID} ${SATELLITE} \ - "hammer content-host info --name ${I} --organization \"${ORG}\"" + "hammer host info --name ${I}" info "Setting up ssh keys for test server $I" sed -i.bak "/^$I[, ]/d" ${KNOWN_HOSTS} # remove test server from the file From 1686a15e3f4ceba2aff18775111fd02f4f9777a3 Mon Sep 17 00:00:00 2001 From: "Patrick C. F. Ernzer" Date: Wed, 11 Jul 2018 11:47:12 +0200 Subject: [PATCH 23/23] fixup, clarify log message --- pushtests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pushtests.sh b/pushtests.sh index f8bd398..fc1f94f 100755 --- a/pushtests.sh +++ b/pushtests.sh @@ -52,7 +52,7 @@ export TEST_ROOT for I in ${TEST_VM_LIST[@]} do # Check the host's entitlements - info "Checking entitlements for test server $I" + inform "Displaying entitlements for test server $I" ssh -q -l ${PUSH_USER} -i ${RSA_ID} ${SATELLITE} \ "hammer host info --name ${I}"