Files
toallab-automation/roles/ikke_t.podman_container_systemd/tests/test.yml
2021-04-20 12:14:42 -04:00

70 lines
1.9 KiB
YAML

---
# 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:
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_state: running
# container_state: absent
container_image_list:
- sebp/lighttpd:latest
container_name: lighttpd
container_run_args: >-
--rm
-v /tmp/podman-container-systemd:/var/www/localhost/htdocs:Z
-t
-p 8080:80/tcp
container_firewall_ports:
- 8080/tcp
import_role:
name: podman-container-systemd
- name: Wait for lighttpd to come up
wait_for:
port: 8080
when: container_state == "running"
- name: test if container runs
get_url:
url: http://localhost:8080
dest: /tmp/podman-container-systemd/index.return.html
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 sould state 'file' on success: {{ get_url.state }}"
- "On success, output should say 'Hello world!' here: {{ curl.stdout }}"
when: container_state == "running"