debian-forge-composer/test/data/ansible/check-minimal.yaml
Xiaofeng Wang 15a94899a8 test: remove persistent log checking on minimal raw test
Persistent log is not related with minimal raw image itself and
it is not stable. After discuss with team, remove this test
2023-12-11 15:12:04 +01:00

201 lines
6.6 KiB
YAML

---
- hosts: ostree_guest
become: no
vars:
total_counter: "0"
failed_counter: "0"
download_node: ""
tasks:
# current target host's IP address
- debug: var=ansible_all_ipv4_addresses
- debug: var=ansible_facts['distribution_version']
- debug: var=ansible_facts['distribution']
- debug: var=ansible_facts['architecture']
# check BIOS or UEFI
- name: check bios or uefi
stat:
path: /sys/firmware/efi
# check secure boot status if it's enabled
- name: check secure boot status
command: mokutil --sb-state
ignore_errors: yes
- name: check partition size
command: df -h
ignore_errors: yes
become: yes
- name: check disk partition table
command: fdisk -l
ignore_errors: yes
become: yes
# case: check rt kernel installed after upgrade
- name: check installed kernel
command: uname -r
# case: check wget installed after upgrade
- name: check installed package
shell: rpm -qa | sort
register: result_packages
# case: check package installed in blueprint
- name: check wget installed
block:
- assert:
that:
- "'wget' in result_packages.stdout"
fail_msg: "wget not installed, ostree upgrade might be failed"
success_msg: "wget installed in ostree upgrade"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
- name: add RHEL 9.4 BaseOS repository
yum_repository:
name: baseos
description: RHEL repository
baseurl: "http://{{ download_node }}/rhel-9/nightly/RHEL-9/latest-RHEL-9.4.0/compose/BaseOS/{{ ansible_facts['architecture'] }}/os/"
gpgcheck: no
file: rhel_repo
become: yes
when: ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('9.4', '==')
- name: add RHEL 9.4 AppStream repository
yum_repository:
name: appstream
description: RHEL repository
baseurl: "http://{{ download_node }}/rhel-9/nightly/RHEL-9/latest-RHEL-9.4.0/compose/AppStream/{{ ansible_facts['architecture'] }}/os/"
gpgcheck: no
file: rhel_repo
become: yes
when: ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('9.4', '==')
- name: add RHEL 8.10 BaseOS repository
yum_repository:
name: baseos
description: RHEL repository
baseurl: "http://{{ download_node }}/rhel-8/nightly/RHEL-8/latest-RHEL-8.10.0/compose/BaseOS/{{ ansible_facts['architecture'] }}/os/"
gpgcheck: no
file: rhel_repo
become: yes
when: ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('8.10', '==')
- name: add RHEL 8.10 AppStream repository
yum_repository:
name: appstream
description: RHEL repository
baseurl: "http://{{ download_node }}/rhel-8/nightly/RHEL-8/latest-RHEL-8.10.0/compose/AppStream/{{ ansible_facts['architecture'] }}/os/"
gpgcheck: no
file: rhel_repo
become: yes
when: ansible_facts['distribution'] == 'RedHat' and ansible_facts ['distribution_version'] is version('8.10', '==')
- name: install podman
dnf:
name:
- podman
state: latest
become: yes
# case: check dmesg error and failed log
- name: check dmesg output
command: dmesg
register: result_dmesg
- name: check dmesg error and fail log
shell: dmesg --notime | grep -i "error\|fail" | grep -v "skipped" | grep -v "failover" || true
register: result_dmesg_error
# case: check running container with podman
- name: run ubi8 image with root
command: podman run ubi8-minimal:latest cat /etc/redhat-release
register: podman_result
become: yes
retries: 30 # due to https://github.com/osbuild/osbuild-composer/issues/2492
delay: 2
until: podman_result is success
ignore_errors: yes
- name: run container test
block:
- assert:
that:
- podman_result is succeeded
- "'Red Hat Enterprise Linux release' in podman_result.stdout"
fail_msg: "failed run container with podman (root)"
success_msg: "running container with podman (root) successed"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
# case: check running container with podman (non-root)
- name: run ubi8 image with non-root
command: podman run ubi8:latest cat /etc/redhat-release
register: podman_result
retries: 30 # due to https://github.com/osbuild/osbuild-composer/issues/2492
delay: 2
until: podman_result is success
ignore_errors: yes
- name: run container test
block:
- assert:
that:
- podman_result is succeeded
- "'Red Hat Enterprise Linux release' in podman_result.stdout"
fail_msg: "failed run container with podman (non-root)"
success_msg: "running container with podman (non-root) successed"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
# case: check rebooting
- name: check rebooting
block:
- name: reboot to deploy new ostree commit
reboot:
become: yes
- name: wait for connection to become reachable/usable
wait_for_connection:
delay: 30
- name: waits until instance is reachable
wait_for:
host: "{{ ansible_all_ipv4_addresses[0] }}"
port: 22
search_regex: OpenSSH
delay: 10
register: result_rollback
until: result_rollback is success
retries: 6
delay: 10
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
- assert:
that:
- failed_counter == "0"
fail_msg: "Run {{ total_counter }} tests, but {{ failed_counter }} of them failed"
success_msg: "Totally {{ total_counter }} test passed"