From e20916d9430d7bed38568ee45d5cc9937d96ca1e Mon Sep 17 00:00:00 2001 From: David Galloway Date: Fri, 16 Nov 2018 15:14:44 -0500 Subject: [PATCH] cobbler: Configure snippets & triggers for RHEL8 Signed-off-by: David Galloway --- .../templates/snippets/cephlab_packages_rhel | 19 ++++++++++++------- .../templates/snippets/cephlab_rc_local | 7 +++++-- .../triggers/install/post/cephlab_ansible.sh | 14 ++++++++++++-- 3 files changed, 29 insertions(+), 11 deletions(-) diff --git a/roles/cobbler/templates/snippets/cephlab_packages_rhel b/roles/cobbler/templates/snippets/cephlab_packages_rhel index f2d060ef..295641c9 100644 --- a/roles/cobbler/templates/snippets/cephlab_packages_rhel +++ b/roles/cobbler/templates/snippets/cephlab_packages_rhel @@ -7,16 +7,21 @@ #else @base #end if +#if $distro == 'RHEL' +#set distro_ver = $distro_ver.split(".")[0] +#end if +#if not int($distro_ver) == 8 +libselinux-python +libsemanage-python +policycoreutils-python +ntp +python-jwt +#else +python3 +#end if perl wget redhat-lsb-core -python-jwt -## For ansible/NRPE smartmontools -libselinux-python -libsemanage-python -policycoreutils-python selinux-policy-targeted -ntp -## For disk partitioning gdisk diff --git a/roles/cobbler/templates/snippets/cephlab_rc_local b/roles/cobbler/templates/snippets/cephlab_rc_local index 0f95ba7e..000e8d35 100644 --- a/roles/cobbler/templates/snippets/cephlab_rc_local +++ b/roles/cobbler/templates/snippets/cephlab_rc_local @@ -3,7 +3,10 @@ # Set proper location for firstboot ansible post-install trigger #set distro = $getVar('distro','').split("-")[0] #set distro_ver = $getVar('distro','').split("-")[1] -#if $distro == 'Fedora' and int($distro_ver) >= 22 +#if $distro == 'RHEL' +#set distro_ver = $distro_ver.split(".")[0] +#end if +#if ($distro == 'Fedora' and int($distro_ver) >= 22) or ($distro == 'RHEL' and int($distro_ver) >= 8) #set script = '/etc/rc.d/rc.local' #else if $distro == 'openSUSE' #set script = '/etc/init.d/boot.local' @@ -144,7 +147,7 @@ set +x echo -e "==================================\nInstructing Cobbler to run Ansible\n Waiting for completion\n==================================" > /dev/console set -x # Run the post-install trigger a second time -wget --timeout=1800 -t1 -O /dev/null "http://$http_server:$http_port/cblr/svc/op/trig/mode/post/system/$system_name" || true +curl --max-time 1800 --silent "http://$http_server:$http_port/cblr/svc/op/trig/mode/post/system/$system_name" -o /dev/null || true touch $lockfile EOF diff --git a/roles/cobbler/templates/triggers/install/post/cephlab_ansible.sh b/roles/cobbler/templates/triggers/install/post/cephlab_ansible.sh index c7352078..40fc3d12 100644 --- a/roles/cobbler/templates/triggers/install/post/cephlab_ansible.sh +++ b/roles/cobbler/templates/triggers/install/post/cephlab_ansible.sh @@ -26,8 +26,18 @@ pushd $ANSIBLE_CM_PATH flock --close ./.lock git pull export ANSIBLE_SSH_PIPELINING=1 export ANSIBLE_HOST_KEY_CHECKING=False + +# Set ansible_python_interpeter var if RHEL8 +# https://docs.ansible.com/ansible/2.7/reference_appendices/python_3_support.html +if [[ $(cobbler system dumpvars --name $2 | grep os_version | awk '{ print $3 }') == "rhel8" ]]; then + # Nagios packages aren't available in the RHEL8 beta image so we'll skip those tasks + ANSIBLE_EXTRAVAR="-e ansible_python_interpreter=/usr/bin/python3 --skip-tags nagios" +else + ANSIBLE_EXTRAVAR="" +fi + # Tell ansible to create users, populate authorized_keys, and zap non-root disks -ansible-playbook testnodes.yml -v --limit $name* --tags user,pubkeys,zap 2>&1 > /var/log/ansible/$name.log +ansible-playbook $ANSIBLE_EXTRAVAR testnodes.yml -v --limit $name* --tags user,pubkeys,zap 2>&1 > /var/log/ansible/$name.log # Now run the rest of the playbook. If it fails, at least we have access. # Background it so that the request doesn't block for this part and end up # causing the client to retry, thus spawning this trigger multiple times @@ -37,5 +47,5 @@ if [[ $profile == *"-stock" ]] then exit 0 fi -ansible-playbook testnodes.yml -v --limit $name* --skip-tags user,pubkeys,zap 2>&1 >> /var/log/ansible/$name.log & +ansible-playbook $ANSIBLE_EXTRAVAR testnodes.yml -v --limit $name* --skip-tags user,pubkeys,zap 2>&1 >> /var/log/ansible/$name.log & popd -- 2.47.3