From 34c15942165de44668a21d4d258133c911fa9310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hozza?= Date: Mon, 13 Feb 2023 11:40:34 +0100 Subject: [PATCH] Test: reformat parts of `ostree-raw-image.sh` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Break the execution of `ansible-playbook` into multiple lines to make it easier to read. Add a comment on top of the second `ansible-playbook` execution if Ignitions is availble, explaining what differs. Otherwise this is hard to spot. There are 3 places in the script, where there are always 2 executions of the `ansible-playbook`. First the user from the BP is used. On the second run, the user created by Ignition is used. This was not the case for the last 2 executions of `ansible-playbook` at the end of the script. Adjust the order for consistency with the rest of the script. The changes should have no effect on the test case. Signed-off-by: Tomáš Hozza --- test/cases/ostree-raw-image.sh | 97 ++++++++++++++++++++++++---------- 1 file changed, 69 insertions(+), 28 deletions(-) diff --git a/test/cases/ostree-raw-image.sh b/test/cases/ostree-raw-image.sh index 361bc5892..fd94f9203 100755 --- a/test/cases/ostree-raw-image.sh +++ b/test/cases/ostree-raw-image.sh @@ -617,12 +617,20 @@ EOF sudo /usr/libexec/osbuild-composer-test/ansible-blocking-io.py # Test IoT/Edge OS - sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type="${OSTREE_OSNAME}" -e skip_rollback_test="true" -e ignition="${HAS_IGNITION}" -e edge_type=edge-raw-image -e ostree_commit="${INSTALL_HASH}" -e sysroot_ro="$SYSROOT_RO" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 + sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \ + -e image_type="${OSTREE_OSNAME}" \ + -e skip_rollback_test="true" \ + -e ignition="${HAS_IGNITION}" \ + -e edge_type=edge-raw-image \ + -e ostree_commit="${INSTALL_HASH}" \ + -e sysroot_ro="$SYSROOT_RO" \ + /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result + # Test the same playbook with the user created by Ignition if [[ ${IGNITION} -eq 0 ]]; then - # Add instance IP address into /etc/ansible/hosts - sudo tee "${TEMPDIR}"/inventory > /dev/null << EOF + # Add instance IP address into /etc/ansible/hosts + sudo tee "${TEMPDIR}"/inventory > /dev/null << EOF [ostree_guest] ${BIOS_GUEST_ADDRESS} @@ -636,9 +644,16 @@ ansible_become_method=sudo ansible_become_pass=${EDGE_USER_PASSWORD} EOF - # Test IoT/Edge OS - sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type="${OSTREE_OSNAME}" -e skip_rollback_test="true" -e ignition="${HAS_IGNITION}" -e edge_type=edge-raw-image -e ostree_commit="${INSTALL_HASH}" -e sysroot_ro="$SYSROOT_RO" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 - check_result + # Test IoT/Edge OS + sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \ + -e image_type="${OSTREE_OSNAME}" \ + -e skip_rollback_test="true" \ + -e ignition="${HAS_IGNITION}" \ + -e edge_type=edge-raw-image \ + -e ostree_commit="${INSTALL_HASH}" \ + -e sysroot_ro="$SYSROOT_RO" \ + /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 + check_result fi # Clean up BIOS VM @@ -731,14 +746,22 @@ greenprint "fix stdio file non-blocking issue" sudo /usr/libexec/osbuild-composer-test/ansible-blocking-io.py # Test IoT/Edge OS -sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type="${OSTREE_OSNAME}" -e skip_rollback_test="true" -e ignition="${HAS_IGNITION}" -e edge_type=edge-raw-image -e ostree_commit="${INSTALL_HASH}" -e sysroot_ro="$SYSROOT_RO" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 +sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \ + -e image_type="${OSTREE_OSNAME}" \ + -e skip_rollback_test="true" \ + -e ignition="${HAS_IGNITION}" \ + -e edge_type=edge-raw-image \ + -e ostree_commit="${INSTALL_HASH}" \ + -e sysroot_ro="$SYSROOT_RO" \ + /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result # test with ignition user +# Test the same playbook with the user created by Ignition if [[ ${IGNITION} -eq 0 ]]; then - # Add instance IP address into /etc/ansible/hosts - sudo tee "${TEMPDIR}"/inventory > /dev/null << EOF + # Add instance IP address into /etc/ansible/hosts + sudo tee "${TEMPDIR}"/inventory > /dev/null << EOF [ostree_guest] ${UEFI_GUEST_ADDRESS} @@ -752,9 +775,16 @@ ansible_become_method=sudo ansible_become_pass=${EDGE_USER_PASSWORD} EOF - # Test IoT/Edge OS - sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type="${OSTREE_OSNAME}" -e skip_rollback_test="true" -e ignition="${HAS_IGNITION}" -e edge_type=edge-raw-image -e ostree_commit="${INSTALL_HASH}" -e sysroot_ro="$SYSROOT_RO" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 - check_result + # Test IoT/Edge OS + sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \ + -e image_type="${OSTREE_OSNAME}" \ + -e skip_rollback_test="true" \ + -e ignition="${HAS_IGNITION}" \ + -e edge_type=edge-raw-image \ + -e ostree_commit="${INSTALL_HASH}" \ + -e sysroot_ro="$SYSROOT_RO" \ + /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 + check_result fi ################################################################## @@ -893,24 +923,30 @@ done check_result if [[ ${IGNITION} -eq 0 ]]; then - # Add instance IP address into /etc/ansible/hosts - sudo tee "${TEMPDIR}"/inventory > /dev/null << EOF - [ostree_guest] - ${UEFI_GUEST_ADDRESS} + # Add instance IP address into /etc/ansible/hosts + sudo tee "${TEMPDIR}"/inventory > /dev/null << EOF +[ostree_guest] +${UEFI_GUEST_ADDRESS} - [ostree_guest:vars] - ansible_python_interpreter=/usr/bin/python3 - ansible_user=core - ansible_private_key_file=${SSH_KEY} - ansible_ssh_common_args="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" - ansible_become=yes - ansible_become_method=sudo - ansible_become_pass=${EDGE_USER_PASSWORD} +[ostree_guest:vars] +ansible_python_interpreter=/usr/bin/python3 +ansible_user=core +ansible_private_key_file=${SSH_KEY} +ansible_ssh_common_args="-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" +ansible_become=yes +ansible_become_method=sudo +ansible_become_pass=${EDGE_USER_PASSWORD} EOF - # Test IoT/Edge OS - sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type="${OSTREE_OSNAME}" -e skip_rollback_test="true" -e edge_type=edge-raw-image -e ostree_commit="${UPGRADE_HASH}" -e sysroot_ro="$SYSROOT_RO" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 - check_result + # Test IoT/Edge OS + sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \ + -e image_type="${OSTREE_OSNAME}" \ + -e skip_rollback_test="true" \ + -e edge_type=edge-raw-image \ + -e ostree_commit="${UPGRADE_HASH}" \ + -e sysroot_ro="$SYSROOT_RO" \ + /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 + check_result fi # Add instance IP address into /etc/ansible/hosts @@ -933,7 +969,12 @@ greenprint "fix stdio file non-blocking issue" sudo /usr/libexec/osbuild-composer-test/ansible-blocking-io.py # Test IoT/Edge OS -sudo ansible-playbook -v -i "${TEMPDIR}"/inventory -e image_type="${OSTREE_OSNAME}" -e edge_type=edge-raw-image -e ostree_commit="${UPGRADE_HASH}" -e sysroot_ro="$SYSROOT_RO" /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 +sudo ansible-playbook -v -i "${TEMPDIR}"/inventory \ + -e image_type="${OSTREE_OSNAME}" \ + -e edge_type=edge-raw-image \ + -e ostree_commit="${UPGRADE_HASH}" \ + -e sysroot_ro="$SYSROOT_RO" \ + /usr/share/tests/osbuild-composer/ansible/check_ostree.yaml || RESULTS=0 check_result # Final success clean up