Skip to content

Commit

Permalink
Fix OC image edition
Browse files Browse the repository at this point in the history
Starting liguestfs-1.48.1, the "--selinux-relabel" option has been
removed, and any call of it will lead to an error[1]

So we now have to detect if this option is present or not, and enable it
where needed - usually cs8, and older cs9 version of that package.

[1] libguestfs/libguestfs@2f6a27f
  • Loading branch information
cjeanner committed May 24, 2022
1 parent 0a8c838 commit 9e07458
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions roles/overcloud/tasks/manage-oc-images.yaml
Expand Up @@ -56,6 +56,16 @@
overcloud-full.qcow2
{%- endif -%}
- name: Detect if "--selinux-relabel" exists in the options
tags:
- lab
- overcloud
- overcloud-images
register: selinux_relabel_option
shell: virt-sysprep --help | grep '\-\-selinux-relabel'
failed_when:
- selinux_relabel_option.rc not in [0, 1]

- name: "Inject root password in OC image {{ oc_image_name }}"
tags:
- lab
Expand All @@ -65,7 +75,7 @@
- new_oc_image|bool
shell: |
LIBGUESTFS_BACKEND="direct" virt-sysprep -a /home/stack/overcloud_imgs/{{ oc_image_name }} \
--selinux-relabel --root-password "password:{{undercloud_password}}" \
{{ (selinux_relabel_option.rc == 0) | ternary('--selinux-relabel', '') }} --root-password "password:{{undercloud_password}}" \
--enable customize \
--ssh-inject "root:file:/home/stack/.ssh/authorized_keys" \
--truncate /etc/machine-id &> /home/stack/overcloud_imgs/overcloud-password.done
Expand All @@ -91,8 +101,7 @@
--copy-in /usr/local/src/:/usr/local/ \
--firstboot /tmp/overcloud-firstboot \
--update \
--selinux-relabel \
--enable customize \
{{ (selinux_relabel_option.rc == 0) | ternary('--selinux-relabel', '') }}--enable customize \
--network \
--truncate /etc/machine-id &> /home/stack/overcloud_imgs/overcloud-full.done
args:
Expand All @@ -109,8 +118,7 @@
shell: |
LIBGUESTFS_BACKEND="direct" virt-sysprep -a /home/stack/overcloud_imgs/{{ oc_image_name }} \
--install {{ oc_image_rpms|join(',') }}\
--selinux-relabel \
--enable customize \
{{ (selinux_relabel_option.rc == 0) | ternary('--selinux-relabel', '') }} --enable customize \
--network \
--truncate /etc/machine-id &> /home/stack/overcloud_imgs/overcloud-full.modified
args:
Expand All @@ -127,7 +135,6 @@
LIBGUESTFS_BACKEND="direct" virt-sysprep -a /home/stack/overcloud_imgs/{{ oc_image_name }} \
--network --copy-in /usr/local/bin/lab-newrelic:/usr/local/bin/ \
--run /usr/local/bin/lab-newrelic \
--selinux-relabel \
--truncate /etc/machine-id &> /home/stack/overcloud_imgs/overcloud-newrelic.log
{{ (selinux_relabel_option.rc == 0) | ternary('--selinux-relabel', '') }} --truncate /etc/machine-id &> /home/stack/overcloud_imgs/overcloud-newrelic.log
args:
creates: /home/stack/overcloud_imgs/overcloud-newrelic.log

0 comments on commit 9e07458

Please sign in to comment.