1---
2- name: Test podman rootful pod play
3  block:
4
5    - name: Create networks
6      containers.podman.podman_network:
7        name: "{{ item }}"
8        state: present
9      loop:
10        - testnet1
11        - testnet2
12
13    - name: Create container with parameters
14      register: continfo
15      containers.podman.podman_containers:
16        containers:
17          - name: cont1
18            image: docker.io/alpine:3.7
19            state: started
20            command: sleep 1d
21            debug: true
22            network: testnet1
23            add_hosts:
24              host1: 127.0.0.1
25              host2: 127.0.0.1
26            annotation:
27              this: "annotation_value"
28            dns_servers:
29              - 1.1.1.1
30              - 8.8.4.4
31            dns_search_domains: example.com
32            capabilities:
33              - SYS_TIME
34              - NET_ADMIN
35            ports:
36              - "9000:80"
37              - "9001:8000"
38            workdir: "/bin"
39            env:
40              FOO: bar=1
41              BAR: foo
42              TEST: 1
43              BOOL: false
44            label:
45              somelabel: labelvalue
46              otheralbe: othervalue
47            volumes:
48              - /tmp:/data
49            interactive: true
50          - name: cont2
51            image: docker.io/alpine:3.7
52            state: started
53            command: sleep 1d
54            recreate: true
55            network:
56              - testnet2
57              - testnet1
58            etc_hosts:
59              host1: 127.0.0.1
60              host2: 127.0.0.1
61            annotation:
62              this: "annotation_value"
63            dns_servers:
64              - 1.1.1.1
65              - 8.8.4.4
66            dns_search_domains: example.com
67            capabilities:
68              - SYS_TIME
69              - NET_ADMIN
70            ports:
71              - "9002:80"
72              - "9003:8000"
73            workdir: "/bin"
74            env:
75              FOO: bar=1
76              BAR: foo
77              TEST: 1
78              BOOL: false
79            label:
80              somelabel: labelvalue
81              otheralbe: othervalue
82            volumes:
83              - /tmp:/data
84            interactive: false
85
86    - name: Check multiple root containers
87      assert:
88        that:
89          - continfo.containers[0]['NetworkSettings']['Networks'].keys() | list == ['testnet1']
90          - continfo.containers[1]['NetworkSettings']['Networks'].keys() | list == ['testnet1', 'testnet2'] or
91            continfo.containers[1]['NetworkSettings']['Networks'].keys() | list == ['testnet2', 'testnet1']
92
93  always:
94
95    - name: Delete all containers leftovers from tests
96      containers.podman.podman_container:
97        name: "{{ item }}"
98        state: absent
99      loop:
100        - cont1
101        - cont2
102        - cont3
103
104    - name: Delete all networks leftovers from tests
105      containers.podman.podman_network:
106        name: "{{ item }}"
107        state: absent
108      loop:
109        - testnet1
110        - testnet2
111