--- # yamllint disable rule:line-length # I run this file with following line to test against my Vagrant Fedora: # ansible-playbook --vault-password-file .vault-password -b -i \ # ~/vagrant/fedora/.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory \ # -e ansible_python_interpreter=/usr/bin/python3 \ # -e container_state=running test-podman.yml # yamllint enable rule:line-length - name: create lighttpd pod hosts: all # connection: local # delegate_to: localhost vars: container_state: running # container_state: absent container_instances: - name: lighthttpd-1 port: 8080 - name: lighthttpd-2 port: 8081 tasks: - name: create test dir for www file file: dest: /tmp/podman-container-systemd state: directory - name: create test www file copy: dest: /tmp/podman-container-systemd/index.html content: "Hello world!\n" - name: tests container vars: container_image_list: - sebp/lighttpd:latest container_name: "{{ outer_item.name }}" container_run_args: >- --rm -v /tmp/podman-container-systemd:/var/www/localhost/htdocs:Z -t -p "{{ outer_item.port }}:80/tcp" container_firewall_ports: - "{{ outer_item.port }}/tcp" ansible.builtin.include_role: name: podman-container-systemd loop: "{{ container_instances }}" loop_control: loop_var: outer_item - name: Wait for lighttpd to come up wait_for: port: "{{ item.port }}" loop: "{{ container_instances }}" when: container_state == "running" - name: test if container runs get_url: url: "http://localhost:{{ item.port }}" dest: /tmp/podman-container-systemd/index.return.html loop: "{{ container_instances }}" register: get_url when: container_state == "running" - name: test web page content command: cat /tmp/podman-container-systemd/index.return.html register: curl when: container_state == "running" - debug: msg: - "Got http://localhost:8080 to test if it worked!" - "This should state 'file' on success: {{ get_url.results[idx].state }}" - "On success, output should say 'Hello world!' here: {{ curl.stdout }}" loop: "{{ container_instances }}" loop_control: index_var: idx when: container_state == "running"