diff --git a/test/cases/ostree-raw-image.sh b/test/cases/ostree-raw-image.sh index 1cae96344d7..a664a9c5e44 100755 --- a/test/cases/ostree-raw-image.sh +++ b/test/cases/ostree-raw-image.sh @@ -103,6 +103,7 @@ KERNEL_RT_PKG="kernel-rt" # Set up variables. SYSROOT_RO="false" CUSTOM_DIRS_FILES="false" +CUSTOM_FS_LVS="false" # Set FIPS variable default FIPS="${FIPS:-false}" @@ -121,6 +122,7 @@ case "${ID}-${VERSION_ID}" in PARENT_REF="rhel/9/${ARCH}/edge" OS_VARIANT="rhel9-unknown" SYSROOT_RO="true" + CUSTOM_FS_LVS="true" ;; "centos-8") OSTREE_REF="centos/8/${ARCH}/edge" @@ -478,6 +480,22 @@ enabled = ["custom.service"] EOF fi +if [[ "${CUSTOM_FS_LVS}" == "true" ]]; then + tee -a "$BLUEPRINT_FILE" > /dev/null << EOF +[[customizations.filesystem]] +mountpoint = "/foo/bar" +size=2147483648 + +[[customizations.filesystem]] +mountpoint = "/foo" +size=8589934592 + +[[customizations.filesystem]] +mountpoint = "/var/myfiles" +size= "1 GiB" +EOF +fi + greenprint "📄 raw image blueprint" cat "$BLUEPRINT_FILE" @@ -590,6 +608,7 @@ EOF -e sysroot_ro="$SYSROOT_RO" \ -e test_custom_dirs_files="$CUSTOM_DIRS_FILES" \ -e fips="${FIPS}" \ + -e custom_fs_lvs="${CUSTOM_FS_LVS}" \ /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result @@ -658,6 +677,18 @@ enabled = ["custom.service"] EOF fi + # Workaround for issue https://github.com/osbuild/images/issues/352 + if [[ "${CUSTOM_FS_LVS}" == "true" ]]; then + tee -a "$BLUEPRINT_FILE" > /dev/null << EOF +[[customizations.files]] +path = "/etc/systemd/system/remount-lvm.service" +data = "[Unit]\nDescription=remount lvm\nDefaultDependencies=no\n[Service]\nType=oneshot\nRemainAfterExit=yes\nExecStartPre=chattr -i /\nExecStart=mkdir -p /foo/bar\nExecStopPost=chattr +i /\n[Install]\nWantedBy=remote-fs.target\n" + +[customizations.services] +enabled = ["remount-lvm.service"] +EOF + fi + greenprint "📄 rebase blueprint" cat "$BLUEPRINT_FILE" @@ -758,6 +789,7 @@ EOF -e sysroot_ro="$SYSROOT_RO" \ -e test_custom_dirs_files="$CUSTOM_DIRS_FILES" \ -e fips="${FIPS}" \ + -e custom_fs_lvs="${CUSTOM_FS_LVS}" \ /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result @@ -864,6 +896,7 @@ sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \ -e sysroot_ro="$SYSROOT_RO" \ -e test_custom_dirs_files="$CUSTOM_DIRS_FILES" \ -e fips="${FIPS}" \ + -e custom_fs_lvs="${CUSTOM_FS_LVS}" \ /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result @@ -946,6 +979,18 @@ enabled = ["custom.service"] EOF fi +# Workaround for issue https://github.com/osbuild/images/issues/352 +if [[ "${CUSTOM_FS_LVS}" == "true" ]]; then + tee -a "$BLUEPRINT_FILE" > /dev/null << EOF +[[customizations.files]] +path = "/etc/systemd/system/remount-lvm.service" +data = "[Unit]\nDescription=remount lvm\nDefaultDependencies=no\n[Service]\nType=oneshot\nRemainAfterExit=yes\nExecStartPre=chattr -i /\nExecStart=mkdir -p /foo/bar\nExecStopPost=chattr +i /\n[Install]\nWantedBy=remote-fs.target\n" + +[customizations.services] +enabled = ["remount-lvm.service"] +EOF +fi + greenprint "📄 upgrade blueprint" cat "$BLUEPRINT_FILE" @@ -1056,6 +1101,7 @@ sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \ -e sysroot_ro="$SYSROOT_RO" \ -e test_custom_dirs_files="$CUSTOM_DIRS_FILES" \ -e fips="${FIPS}" \ + -e custom_fs_lvs="${CUSTOM_FS_LVS}" \ /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result diff --git a/test/data/ansible/check_ostree.yaml b/test/data/ansible/check_ostree.yaml index db3b4c5e8f2..da71ec3d5d7 100644 --- a/test/data/ansible/check_ostree.yaml +++ b/test/data/ansible/check_ostree.yaml @@ -14,6 +14,7 @@ test_custom_dirs_files: "false" sysroot_ro: "false" fips: "false" + custom_fs_lvs: "false" tasks: # current target host's IP address @@ -261,7 +262,7 @@ # case: check pv size - name: check pv size - shell: pvs --reportformat json | jq .report[0].pv[0].pv_size -r + shell: pvs --reportformat json --units g | jq .report[0].pv[0].pv_size -r | sed "s/\.[0-9]\+g//g" become: yes register: result_pv_size when: "'/dev/mapper/rootvg-rootlv' in result_sysroot_source.stdout" @@ -303,6 +304,38 @@ when: - "'/dev/mapper/rootvg-rootlv' in result_sysroot_source.stdout" - fdo_credential == "false" + - custom_fs_lvs == "false" + + # check logical volumes + - name: check logical volumes + shell: lvdisplay -a + become: yes + register: result_custom_lvs + when: + - "'/dev/mapper/rootvg-rootlv' in result_sysroot_source.stdout" + - custom_fs_lvs == "true" + + - name: "check that custom partitions are present" + block: + - assert: + that: + - "'var_myfileslv' in result_custom_lvs.stdout" + - "'foolv' in result_custom_lvs.stdout" + - "'foo_barlv' in result_custom_lvs.stdout" + fail_msg: "There are custom lvs missing" + success_msg: "Custom lvs present in filesystem" + always: + - set_fact: + total_counter: "{{ total_counter | int + 1 }}" + rescue: + - name: failed count + 1 + set_fact: + failed_counter: "{{ failed_counter | int + 1 }}" + when: + - "'/dev/mapper/rootvg-rootlv' in result_sysroot_source.stdout" + - fdo_credential == "false" + - custom_fs_lvs == "true" + # case: check /sysroot lv size - name: check sysroot lv size