--- - name: Create hosts: localhost connection: local gather_facts: false vars: molecule_inventory: all: hosts: {} molecule: {} tasks: - name: Create a container community.docker.docker_container: name: "{{ item.name }}" image: "{{ item.image }}" state: started command: "{{ item.command }}" log_driver: json-file register: result loop: "{{ molecule_yml.platforms }}" - name: Print some info ansible.builtin.debug: msg: "{{ result.results }}" - name: Fail if container is not running when: > item.container.State.ExitCode != 0 or not item.container.State.Running ansible.builtin.include_tasks: file: tasks/create-fail.yml loop: "{{ result.results }}" loop_control: label: "{{ item.container.Name }}" - name: Add container to molecule_inventory vars: inventory_partial_yaml: | all: children: molecule: hosts: "{{ item.name }}": ansible_connection: community.docker.docker service_users: - name: eqadmin services: - netbird - service2 ansible.builtin.set_fact: molecule_inventory: > {{ molecule_inventory | combine(inventory_partial_yaml | from_yaml, recursive=true) }} loop: "{{ molecule_yml.platforms }}" loop_control: label: "{{ item.name }}" - name: Dump molecule_inventory ansible.builtin.copy: content: | {{ molecule_inventory | to_yaml }} dest: "{{ molecule_ephemeral_directory }}/inventory/molecule_inventory.yml" mode: "0600" - name: Force inventory refresh ansible.builtin.meta: refresh_inventory - name: Fail if molecule group is missing ansible.builtin.assert: that: "'molecule' in groups" fail_msg: | molecule group was not found inside inventory groups: {{ groups }} run_once: true # noqa: run-once[task] # we want to avoid errors like "Failed to create temporary directory" - name: Validate that inventory was refreshed hosts: molecule gather_facts: false tasks: - name: Check uname ansible.builtin.raw: uname -a register: result changed_when: false - name: Display uname info ansible.builtin.debug: msg: "{{ result.stdout }}" - name: Verify container properties hosts: molecule gather_facts: false tasks: - name: Prerequisite packages ansible.builtin.dnf: name: ['openssh-server', 'python3-policycoreutils', 'python3-firewall', 'cronie'] state: present - name: Apply prerequisite roles hosts: molecule gather_facts: true tasks: - name: Apply podman-host Role include_role: name: podman-host - name: Apply repo-epel Role include_role: name: geerlingguy.repo-epel - name: Apply certbot Role include_role: name: geerlingguy.certbot - name: Register certbot command: cmd: "certbot register --agree-tos --email admin@libre.audio" creates: "/etc/letsencrypt/renewal-hooks/"