---
- hosts: greenboot_guest
become: no
vars:
total_counter: "0"
failed_counter: "0"
tasks:
- debug: var=ansible_all_ipv4_addresses
- debug: var=ansible_facts['distribution_version']
- debug: var=ansible_facts['distribution']
- debug: var=ansible_facts['architecture']
- name: check bootc status
command: bootc status
ignore_errors: yes
- name: greenboot should be installed
block:
- name: greenboot should be installed
shell: rpm -qa | grep greenboot
register: result_greenboot_packages
- assert:
that:
- "'greenboot-0' in result_greenboot_packages.stdout"
- "'greenboot-default-health-checks' in result_greenboot_packages.stdout"
fail_msg: "greenboot is not installed"
success_msg: "greenboot is installed"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
- name: a list of greenboot* service should be enabled
block:
- name: a list of greenboot* service should be enabled
command: systemctl is-enabled greenboot-healthcheck greenboot-rollback.service
register: result_greenboot_service
- assert:
that:
- result_greenboot_service.stdout == 'enabled\nenabled'
fail_msg: "at least one greenboot service is not enabled"
success_msg: "greenboot services are enabled"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
- name: fallback log should be found here
block:
- name: check boot-complete.target
command: systemctl --no-pager status boot-complete.target
become: yes
register: result
retries: 10
delay: 60
until: "'inactive' not in result.stdout"
- name: fallback log should be found here
command: journalctl -b -0 -u greenboot -u greenboot-healthcheck
become: yes
register: result_greenboot_log
- assert:
that:
- "'FALLBACK BOOT DETECTED! Default bootc deployment has been rolled back' in result_greenboot_log.stdout"
- "'Script \\'00_required_scripts_start.sh\\' SUCCESS' in result_greenboot_log.stdout"
- "'Script \\'00_wanted_scripts_start.sh\\' SUCCESS' in result_greenboot_log.stdout"
- "'greenboot Health Checks Runner' in result_greenboot_log.stdout"
- "'Mark boot as successful in grubenv' in result_greenboot_log.stdout"
fail_msg: "Fallback log not found"
success_msg: "Found fallback log"
always:
- set_fact:
total_counter: "{{ total_counter | int + 1 }}"
rescue:
- name: failed count + 1
set_fact:
failed_counter: "{{ failed_counter | int + 1 }}"
- name: grubenv variables should contain boot_success=1
block:
- name: grubenv variables should contain boot_success=1
command: grub2-editenv list
register: result_grubenv
become: yes
- assert:
that:
- "'boot_success=1' in result_grubenv.stdout"
fail_msg: "Not found boot_success=1"
success_msg: "Found boot_success=1"
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"