--- # Copyright 2019 Red Hat, Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. - name: Create fedora container from /tmp/container-configs with old healthcheck become: true hosts: all gather_facts: false vars: tripleo_container_manage_config: '/tmp/container-configs' tripleo_container_manage_healthcheck_disabled: true tripleo_container_manage_debug: true tripleo_container_manage_config_patterns: 'fedora.json' tripleo_container_manage_systemd_order: true tasks: - include_role: name: tripleo_container_manage post_tasks: - name: Verify that Fedora container was created correctly and manually create old healthcheck for migration testing when: - not ansible_check_mode|bool block: # Reproduce what was done before to create and enable healthchecks - name: "Enable and start systemd timers" systemd: state: started name: "tripleo_fedora_healthcheck.timer" enabled: true daemon_reload: false - name: "Add systemd requires for healthchecks" command: "systemctl add-requires tripleo_fedora.service tripleo_fedora_healthcheck.timer" # Check that migration is ready to be tested - name: Check for fedora container command: podman container exists fedora - name: Check if tripleo_fedora systemd healthcheck service is active command: systemctl is-active --quiet tripleo_fedora_healthcheck.timer register: tripleo_fedora_healthcheck_active_result - name: Assert that tripleo_fedora systemd healthcheck service is active assert: that: - tripleo_fedora_healthcheck_active_result.rc == 0 fail_msg: 'tripleo_fedora systemd healthcheck service is not active' success_msg: 'tripleo_fedora systemd healthcheck service is active' - name: Create all containers from /tmp/container-configs become: true hosts: all gather_facts: false vars: tripleo_container_manage_config: '/tmp/container-configs' tripleo_container_manage_debug: true tripleo_container_manage_config_patterns: '*.json' tripleo_container_manage_systemd_order: true tripleo_container_manage_valid_exit_code: [0] tasks: - include_role: name: tripleo_container_manage post_tasks: - name: Verify that Fedora container was created correctly when: - not ansible_check_mode|bool block: - name: Check for fedora container command: podman container exists fedora - name: Gather facts about fedora container podman_container_info: name: fedora register: fedora_infos - name: Assert that fedora container has the right image assert: that: - "'fedora:latest' in fedora_infos.containers.0.ImageName" fail_msg: 'fedora container has wrong image' success_msg: 'fedora container has the right image' - name: Check if tripleo_fedora systemd service is active command: systemctl is-active --quiet tripleo_fedora register: tripleo_fedora_active_result - name: Assert that tripleo_fedora systemd service is active assert: that: - tripleo_fedora_active_result.rc == 0 fail_msg: 'tripleo_fedora systemd service is not active' success_msg: 'tripleo_fedora systemd service is active' - name: Check if tripleo_fedora healthcheck is active and healthy assert: that: - "'healthy' in fedora_infos.containers.0.State.Healthcheck.Status" fail_msg: 'fedora container healthcheck is not healthy' success_msg: 'fedora container healthcheck is healthy' - name: Verify that Fedora systemd healthcheck container was removed correctly command: systemctl is-active --quiet tripleo_fedora_healthcheck.timer register: tripleo_fedora_healthcheck_active_result failed_when: - tripleo_fedora_healthcheck_active_result.rc == 0 - name: Verify that Fedora bis container was created correctly block: - name: Check for fedora_bis container command: podman container exists fedora_bis - name: Gather facts about fedora_bis container podman_container_info: name: fedora_bis register: fedora_bis_infos - name: Assert that fedora_bis container has the right image assert: that: - "'fedora:latest' in fedora_bis_infos.containers.0.ImageName" fail_msg: 'fedora_bis container has wrong image' success_msg: 'fedora_bis container has the right image' - name: Verify that Fedora three container was created correctly block: - name: Check for fedora_three container command: podman container exists fedora_three - name: Gather facts about fedora_three container podman_container_info: name: fedora_three register: fedora_three_infos - name: Assert that fedora_three container has the right image assert: that: - "'fedora:latest' in fedora_three_infos.containers.0.ImageName" fail_msg: 'fedora_three container has wrong image' success_msg: 'fedora_three container has the right image' - name: Test idempotency on fedora container become: true hosts: all gather_facts: false vars: tripleo_container_manage_config: '/tmp/container-configs' tripleo_container_manage_debug: true tripleo_container_manage_config_patterns: '*.json' tripleo_container_manage_systemd_order: true tasks: - name: Gather facts about fedora container before new run podman_container_info: name: fedora register: fedora_infos_old when: - not ansible_check_mode|bool - include_role: name: tripleo_container_manage - name: Gather facts about fedora container after new run podman_container_info: name: fedora register: fedora_infos_new when: - not ansible_check_mode|bool post_tasks: - name: Assert that fedora container has not been re-created assert: that: - fedora_infos_new == fedora_infos_old fail_msg: 'fedora container was wrongly re-created' success_msg: 'fedora container was not re-created' when: - not ansible_check_mode|bool - name: Test systemd state on fedora container after a manual stop become: true hosts: all gather_facts: false vars: tripleo_container_manage_config: '/tmp/container-configs' tripleo_container_manage_debug: true tripleo_container_manage_config_patterns: '*.json' tripleo_container_manage_systemd_order: true tasks: - name: Stop systemd service for tripleo_fedora in a manual stop systemd: name: tripleo_fedora.service state: stopped enabled: false daemon_reload: true - include_role: name: tripleo_container_manage post_tasks: - name: Check if tripleo_fedora systemd service is active after a manual stop command: systemctl is-active --quiet tripleo_fedora register: tripleo_fedora_active_result - name: Assert that tripleo_fedora systemd service is active after a manual stop when: - not ansible_check_mode|bool assert: that: - tripleo_fedora_active_result.rc == 0 fail_msg: 'tripleo_fedora systemd service is not active after a manual stop' success_msg: 'tripleo_fedora systemd service is active after a manual stop' - name: Manage only one container become: true hosts: all gather_facts: false vars: tripleo_container_manage_config: '/tmp/container-configs' tripleo_container_manage_debug: true tripleo_container_manage_config_patterns: 'fedora.json' tripleo_container_manage_config_overrides: fedora: image: fedora:rawhide tasks: - include_role: name: tripleo_container_manage post_tasks: - name: Verify that all containers still exist when: - not ansible_check_mode|bool block: - name: Check for fedora container command: podman container exists fedora - name: Gather facts about fedora container podman_container_info: name: fedora register: fedora_infos - name: Assert that fedora container has the right image assert: that: - "'fedora:rawhide' in fedora_infos.containers.0.ImageName" fail_msg: 'fedora container has wrong image' success_msg: 'fedora container has the right image' - name: Check if tripleo_fedora systemd service is active command: systemctl is-active --quiet tripleo_fedora register: tripleo_fedora_active_result - name: Assert that tripleo_fedora systemd service is active assert: that: - tripleo_fedora_active_result.rc == 0 fail_msg: 'tripleo_fedora systemd service is not active' success_msg: 'tripleo_fedora systemd service is active' - name: Check if tripleo_fedora healthcheck is active and healthy assert: that: - "'healthy' in fedora_infos.containers.0.State.Healthcheck.Status" fail_msg: 'fedora container healthcheck is not healthy' success_msg: 'fedora container healthcheck is healthy' - name: Check for fedora_bis container command: podman container exists fedora_bis - name: Check for fedora_three container command: podman container exists fedora_three - name: Manage a wrong container (user error) become: true hosts: all gather_facts: false vars: tripleo_container_manage_config: '/tmp/container-configs' tripleo_container_manage_debug: true tripleo_container_manage_config_patterns: 'feduraaa.json' tasks: - include_role: name: tripleo_container_manage post_tasks: - name: Verify that all containers still exist when: - not ansible_check_mode|bool block: - name: Check for fedora container command: podman container exists fedora - name: Gather facts about fedora container podman_container_info: name: fedora register: fedora_infos - name: Check if tripleo_fedora systemd service is active command: systemctl is-active --quiet tripleo_fedora register: tripleo_fedora_active_result - name: Assert that tripleo_fedora systemd service is active assert: that: - tripleo_fedora_active_result.rc == 0 fail_msg: 'tripleo_fedora systemd service is not active' success_msg: 'tripleo_fedora systemd service is active' - name: Check if tripleo_fedora healthcheck is active and healthy assert: that: - "'healthy' in fedora_infos.containers.0.State.Healthcheck.Status" fail_msg: 'fedora container healthcheck is not healthy' success_msg: 'fedora container healthcheck is healthy' - name: Check for fedora_bis container command: podman container exists fedora_bis - name: Check for fedora_three container command: podman container exists fedora_three - name: Test a container removal become: true hosts: all gather_facts: false vars: tripleo_container_manage_config: '/tmp/container-configs' tripleo_container_manage_debug: true tripleo_container_manage_config_patterns: 'fedora_*.json' tripleo_container_manage_systemd_order: true tasks: - name: Remove fedora container config file: path: '/tmp/container-configs/fedora.json' state: absent - include_role: name: tripleo_container_manage post_tasks: - name: Verify that all containers still exist when: - not ansible_check_mode|bool block: - name: Check that fedora container was removed command: podman container exists fedora register: container_exist failed_when: container_exist.rc == 0 - name: Check if tripleo_fedora systemd service is still active command: systemctl is-active --quiet tripleo_fedora register: tripleo_fedora_active_result failed_when: tripleo_fedora_active_result.rc == 0 - name: Check for fedora_bis container command: podman container exists fedora_bis - name: Check for fedora_three container command: podman container exists fedora_three - name: Test a container update become: true hosts: all gather_facts: false vars: tripleo_container_manage_config: '/tmp/container-configs' tripleo_container_manage_debug: true tripleo_container_manage_config_patterns: 'fedora_*.json' tripleo_container_manage_systemd_order: true tasks: - name: Modify the fedora_bis container config copy: content: | { "image": "fedora:rawhide", "net": "host", "command": "sleep 10" } dest: '/tmp/container-configs/fedora_bis.json' - include_role: name: tripleo_container_manage post_tasks: - name: Verify that Fedora bis container was re-created correctly when: - not ansible_check_mode|bool block: - name: Check for fedora_bis container command: podman container exists fedora_bis - name: Gather facts about fedora_bis container podman_container_info: name: fedora_bis register: fedora_bis_infos - name: Assert that fedora_bis container has the right image assert: that: - "'fedora:rawhide' in fedora_bis_infos.containers.0.ImageName" fail_msg: 'fedora_bis container has wrong image' success_msg: 'fedora_bis container has the right image' - name: Check for fedora_three container command: podman container exists fedora_three when: - not ansible_check_mode|bool - name: Test a container config override become: true hosts: all gather_facts: false vars: tripleo_container_manage_config: '/tmp/container-configs' tripleo_container_manage_debug: true tripleo_container_manage_config_patterns: 'fedora_*.json' tripleo_container_manage_systemd_order: true tripleo_container_manage_config_overrides: fedora_bis: image: fedora:latest tasks: - include_role: name: tripleo_container_manage post_tasks: - name: Verify that Fedora bis container was re-created correctly when: - not ansible_check_mode|bool block: - name: Check for fedora_bis container command: podman container exists fedora_bis - name: Gather facts about fedora_bis container podman_container_info: name: fedora_bis register: fedora_bis_infos - name: Assert that fedora_bis container has the right image assert: that: - "'fedora:latest' in fedora_bis_infos.containers.0.ImageName" fail_msg: 'fedora_bis container has wrong image' success_msg: 'fedora_bis container has the right image' - name: Check for fedora_three container command: podman container exists fedora_three when: - not ansible_check_mode|bool