From: David Galloway Date: Wed, 2 Feb 2022 22:20:07 +0000 (-0500) Subject: cobbler: Change the way we convert non-stream to stream X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F666%2Fhead;p=ceph-cm-ansible.git cobbler: Change the way we convert non-stream to stream The old method doesn't work since the non-stream repos have moved. Signed-off-by: David Galloway --- diff --git a/roles/cobbler/templates/triggers/install/post/cephlab_ansible.sh b/roles/cobbler/templates/triggers/install/post/cephlab_ansible.sh index 379762b..0fa62f0 100644 --- a/roles/cobbler/templates/triggers/install/post/cephlab_ansible.sh +++ b/roles/cobbler/templates/triggers/install/post/cephlab_ansible.sh @@ -27,6 +27,21 @@ flock --close ./.lock git pull export ANSIBLE_SSH_PIPELINING=1 export ANSIBLE_HOST_KEY_CHECKING=False +# Set up Stream repos +# We have to do it this way because +# 1) Stream ISOs don't work with Cobbler https://bugs.centos.org/view.php?id=18188 +# 2) Since we use a non-stream profile then convert it to stream, we can't run any package related tasks +# until the stream repo files are in place. e.g., The zap ansible tag has some package tasks that fail +# unless we get the repos in place first. +if [[ $profile == *"8.stream"* ]] +then + ansible-playbook tools/convert-to-centos-stream.yml -v --limit $name* 2>&1 >> /var/log/ansible/$name.log +elif [[ $profile == *"9.stream"* ]] +then + # For some reason, we end up with no repos on the first boot without doing this. + ansible-playbook testnodes.yml --tags repos -v --limit $name* 2>&1 >> /var/log/ansible/$name.log +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 # Now run the rest of the playbook. If it fails, at least we have access. @@ -37,13 +52,6 @@ ansible-playbook testnodes.yml -v --limit $name* --tags user,pubkeys,zap 2>&1 > if [[ $profile == *"-stock" ]] then exit 0 -elif [[ $profile == *"8.stream"* ]] -then - ansible-playbook tools/convert-to-centos-stream.yml -v --limit $name* 2>&1 >> /var/log/ansible/$name.log -elif [[ $profile == *"9.stream"* ]] -then - # For some reason, we end up with no repos on the first boot without doing this. - ansible-playbook testnodes.yml --tags repos -v --limit $name* 2>&1 >> /var/log/ansible/$name.log fi ansible-playbook cephlab.yml -v --limit $name* --skip-tags user,pubkeys,zap 2>&1 >> /var/log/ansible/$name.log & popd diff --git a/tools/convert-to-centos-stream.yml b/tools/convert-to-centos-stream.yml index 7a29757..ba0d550 100644 --- a/tools/convert-to-centos-stream.yml +++ b/tools/convert-to-centos-stream.yml @@ -8,6 +8,39 @@ gather_facts: true tasks: + - name: List repo files + find: + paths: /etc/yum.repos.d/ + file_type: file + patterns: 'CentOS-Linux-*.repo' + register: pre_stream_repo_files + when: ansible_distribution == 'CentOS' + + # From ansible docs: 'replace: If not set, matches are removed entirely.' + - name: Remove all mirrorlists + replace: + path: "{{ item.path }}" + regexp: '^mirrorlist=.*' + with_items: "{{ pre_stream_repo_files.files }}" + when: ansible_distribution == 'CentOS' + + - name: Uncomment baseurls + replace: + path: "{{ item.path }}" + regexp: '^mirrorlist=.*' + regexp: '^\s*#*\s*(baseurl=.*)' + replace: '\1' + with_items: "{{ pre_stream_repo_files.files }}" + when: ansible_distribution == 'CentOS' + + - name: Point baseurls to archive server + replace: + path: "{{ item.path }}" + regexp: 'mirror.centos.org/\$contentdir/\$releasever' + replace: 'vault.centos.org/8.5.2111' + with_items: "{{ pre_stream_repo_files.files }}" + when: ansible_distribution == 'CentOS' + - name: Swap to Stream Repos command: dnf -y swap centos-linux-repos centos-stream-repos when: ansible_distribution == 'CentOS'