@@ -9,21 +9,21 @@ include:
99 - docker.compose.software
1010 - docker.networks
1111
12- {%- for name, container in d.compose.ng.items() % }
13- {%- set id = container.container_name| d(name) % }
14- {%- set required_containers = [] % }
15- {%- set required_networks = [] % }
12+ {%- for name, container in d.compose.ng.items() % }
13+ {%- set id = container.container_name| d(name) % }
14+ {%- set required_containers = [] % }
15+ {%- set required_networks = [] % }
1616
1717docker- compose- ng- {{ id }}- present:
1818 docker_image.present:
1919 - force: {{ d.misc.force_present }}
20- {%- if ' :' in container.image % }
21- {%- set image = container.image.split(' :' ,1 ) % }
20+ {%- if ' :' in container.image % }
21+ {%- set image = container.image.split(' :' ,1 ) % }
2222 - name: {{ image[0 ] }}
2323 - tag: {{ image[1 ] }}
24- {%- else % }
24+ {%- else % }
2525 - name: {{ container.image }}
26- {%- endif % }
26+ {%- endif % }
2727
2828docker- compose- ng- {{ id }}- running:
2929 docker_container.running:
@@ -34,107 +34,107 @@ docker-compose-ng-{{ id }}-running:
3434 - privileged: {{ container.privileged| default(False ) }}
3535 - interactive: {{ container.stdin_open| default(False ) }}
3636 - tty: {{ container.tty| default(False ) }}
37- {%- if ' command' in container % }
37+ {%- if ' command' in container % }
3838 - command: {{ container.command }}
39- {%- endif % }
40- {%- if ' working_dir' in container % }
39+ {%- endif % }
40+ {%- if ' working_dir' in container % }
4141 - working_dir: {{ container.working_dir }}
42- {%- endif % }
43- {%- if ' volume_driver' in container % }
42+ {%- endif % }
43+ {%- if ' volume_driver' in container % }
4444 - volume_driver: {{ container.volume_driver }}
45- {%- endif % }
46- {%- if ' userns_mode' in container % }
45+ {%- endif % }
46+ {%- if ' userns_mode' in container % }
4747 - userns_mode: {{ container.userns_mode }}
48- {%- endif % }
49- {%- if ' user' in container % }
48+ {%- endif % }
49+ {%- if ' user' in container % }
5050 - user: {{ container.user }}
51- {%- endif % }
52- {%- if ' environment' in container and container.environment is iterable % }
51+ {%- endif % }
52+ {%- if ' environment' in container and container.environment is iterable % }
5353 - environment:
54- {%- for variable, value in container.environment.items() % }
54+ {%- for variable, value in container.environment.items() % }
5555 - {{ variable }}: {{ value }}
56- {%- endfor % }
57- {%- endif % }
58- {%- if ' ports' in container and container.ports is iterable % }
56+ {%- endfor % }
57+ {%- endif % }
58+ {%- if ' ports' in container and container.ports is iterable % }
5959 - port_bindings:
60- {%- for port_mapping in container.ports % }
61- {%- if port_mapping is string % }
62- {%- set mapping = port_mapping.split(' :' ,2 ) % }
63- {%- if mapping| length < 2 % }
60+ {%- for port_mapping in container.ports % }
61+ {%- if port_mapping is string % }
62+ {%- set mapping = port_mapping.split(' :' ,2 ) % }
63+ {%- if mapping| length < 2 % }
6464 - " {{ mapping[0] }} "
65- {%- elif mapping| length > 2 % }
65+ {%- elif mapping| length > 2 % }
6666 - " {{ mapping[0] }} :{{ mapping[1] }} :{{ mapping[-1] }} "
67- {%- else % }
67+ {%- else % }
6868 - " {{ mapping[0] }} :{{ mapping[-1] }} "
69- {%- endif % }
70- {%- elif port_mapping is mapping % }
71- - {{ port_mapping }}
7269 {%- endif % }
73- {%- endfor % }
74- {%- endif % }
75- {%- if ' volumes' in container % }
70+ {%- elif port_mapping is mapping % }
71+ - {{ port_mapping }}
72+ {%- endif % }
73+ {%- endfor % }
74+ {%- endif % }
75+ {%- if ' volumes' in container % }
7676 - binds:
77- {%- for bind in container.volumes % }
78- {%- set mapping = bind.rsplit(' :' , 1 ) % }
79- {%- if mapping| length > 1 % }
77+ {%- for bind in container.volumes % }
78+ {%- set mapping = bind.rsplit(' :' , 1 ) % }
79+ {%- if mapping| length > 1 % }
8080 - " {{ mapping[0] }} :{{ mapping[-1] }} "
81- {%- else % }
81+ {%- else % }
8282 - " {{ mapping[0] }} "
83- {%- endif % }
84- {%- endfor % }
85- {%- endif % }
86- {%- if ' volumes_from' in container % }
83+ {%- endif % }
84+ {%- endfor % }
85+ {%- endif % }
86+ {%- if ' volumes_from' in container % }
8787 - volumes_from:
88- {%- for volume in container.volumes_from % }
89- {%- do required_containers.append(volume) % }
88+ {%- for volume in container.volumes_from % }
89+ {%- do required_containers.append(volume) % }
9090 - {{ volume }}
91- {%- endfor % }
92- {%- endif % }
93- {%- if ' links' in container % }
91+ {%- endfor % }
92+ {%- endif % }
93+ {%- if ' links' in container % }
9494 - links:
95- {%- for link in container.links % }
96- {%- set name, alias = link.split(' :' ,1 ) % }
97- {%- do required_containers.append(name) % }
95+ {%- for link in container.links % }
96+ {%- set name, alias = link.split(' :' ,1 ) % }
97+ {%- do required_containers.append(name) % }
9898 {{ name }}: {{ alias }}
99- {%- endfor % }
100- {%- endif % }
101- {%- if ' networks' in container % }
99+ {%- endfor % }
100+ {%- endif % }
101+ {%- if ' networks' in container % }
102102 - networks:
103- {%- for network in container.networks % }
104- {%- do required_networks.append(network) % }
103+ {%- for network in container.networks % }
104+ {%- do required_networks.append(network) % }
105105 - {{ network }}
106- {%- endfor % }
107- {%- endif % }
108- {%- if ' restart' in container % }
109- {%- set policy = container.restart.split(' :' ,1 ) % }
110- {%- if policy| length < 2 % }
106+ {%- endfor % }
107+ {%- endif % }
108+ {%- if ' restart' in container % }
109+ {%- set policy = container.restart.split(' :' ,1 ) % }
110+ {%- if policy| length < 2 % }
111111 - restart_policy: {{ policy[0 ] }}
112- {%- else % }
112+ {%- else % }
113113 - restart_policy: {{ policy[0 ] }}:{{ policy[- 1 ] }}
114- {%- endif % }
115114 {%- endif % }
116- {%- if ' devices' in container % }
115+ {%- endif % }
116+ {%- if ' devices' in container % }
117117 - devices:
118- {%- for device in container.devices % }
119- {%- set mapping = device.rsplit(' :' , 1 ) % }
120- {%- if mapping| length > 1 % }
118+ {%- for device in container.devices % }
119+ {%- set mapping = device.rsplit(' :' , 1 ) % }
120+ {%- if mapping| length > 1 % }
121121 - " {{ mapping[0] }} :{{ mapping[-1] }} "
122- {%- else % }
122+ {%- else % }
123123 - " {{ mapping[0] }} "
124- {%- endif % }
125- {%- endfor % }
126- {%- endif % }
124+ {%- endif % }
125+ {%- endfor % }
126+ {%- endif % }
127127 - require:
128128 - docker_image: docker- compose- ng- {{ id }}- present
129- {%- if required_containers is defined % }
130- {%- for containerid in required_containers % }
129+ {%- if required_containers is defined % }
130+ {%- for containerid in required_containers % }
131131 - docker_image: docker- compose- ng- {{ id }}- present
132- {%- endfor % }
133- {%- endif % }
134- {%- if required_networks is defined % }
135- {%- for networkid in required_networks % }
132+ {%- endfor % }
133+ {%- endif % }
134+ {%- if required_networks is defined % }
135+ {%- for networkid in required_networks % }
136136 - docker_network: docker- network- {{ networkid }}- present
137- {%- endfor % }
138- {%- endif % }
137+ {%- endfor % }
138+ {%- endif % }
139139
140- {% endfor % }
140+ {% endfor % }
0 commit comments