diff --git a/docker/compose-ng.sls b/docker/compose-ng.sls index 9826d751..d1d64a5c 100644 --- a/docker/compose-ng.sls +++ b/docker/compose-ng.sls @@ -10,22 +10,22 @@ include: {%- set id = container.container_name|d(name) %} {%- set required_containers = [] %} {%- if grains['saltversioninfo'] >= [2017, 7, 0] %} -{{id}}: +{{ id }}: docker_image.present: - force: {{ docker.containers.force_present }} {%- else %} -{{id}} image: +{{ id }} image: docker.pulled: {%- endif %} {%- if ':' in container.image %} {%- set image = container.image.split(':',1) %} - - name: {{image[0]}} - - tag: {{image[1]}} + - name: {{ image[0] }} + - tag: {{ image[1] }} {%- else %} - - name: {{container.image}} + - name: {{ container.image }} {%- endif %} -{{id}} container: +{{ id }} container: {%- if grains['saltversioninfo'] >= [2017, 7, 0] %} docker_container.running: - skip_translate: {{ docker.containers.skip_translate }} @@ -37,15 +37,15 @@ include: docker.running: {%- endif %} {%- endif %} - - name: {{id}} - - image: {{container.image}} + - name: {{ id }} + - image: {{ container.image }} {%- if 'command' in container %} - - command: {{container.command}} + - command: {{ container.command }} {%- endif %} {%- if 'environment' in container and container.environment is iterable %} - environment: {%- for variable, value in container.environment.items() %} - - {{variable}}: {{value}} + - {{ variable }}: {{ value }} {%- endfor %} {%- endif %} {%- if 'ports' in container and container.ports is iterable %} @@ -54,28 +54,28 @@ include: {%- if port_mapping is string %} {%- set mapping = port_mapping.split(':',2) %} {%- if mapping|length < 2 %} - - "{{mapping[0]}}" + - "{{ mapping[0] }}" {%- else %} - - "{{mapping[-1]}}/tcp": - HostPort: "{{mapping[-2]}}" - HostIp: "{{mapping[-3]|d('')}}" + - "{{ mapping[-1] }}/tcp": + HostPort: "{{ mapping[-2] }}" + HostIp: "{{ mapping[-3]|d('') }}" {%- endif %} {%- elif port_mapping is mapping %} - - {{port_mapping}} + - {{ port_mapping }} {%- endif %} {%- endfor %} {%- endif %} {%- if 'volumes' in container %} - volumes: {%- for volume in container.volumes %} - - {{volume}} + - {{ volume }} {%- endfor %} {%- endif %} {%- if 'volumes_from' in container %} - volumes_from: {%- for volume in container.volumes_from %} {%- do required_containers.append(volume) %} - - {{volume}} + - {{ volume }} {%- endfor %} {%- endif %} {%- if 'links' in container %} @@ -83,29 +83,29 @@ include: {%- for link in container.links %} {%- set name, alias = link.split(':',1) %} {%- do required_containers.append(name) %} - {{name}}: {{alias}} + {{ name }}: {{ alias }} {%- endfor %} {%- endif %} {%- if 'restart' in container %} - restart_policy: {%- set policy = container.restart.split(':',1) %} - Name: {{policy[0]}} + Name: {{ policy[0] }} {%- if policy|length > 1 %} - MaximumRetryCount: {{policy[1]}} + MaximumRetryCount: {{ policy[1] }} {%- endif %} {%- endif %} - require: {%- if grains['saltversioninfo'] >= [2017, 7, 0] %} - - docker_image: {{id}} + - docker_image: {{ id }} {%- else %} - - docker: {{id}} image + - docker: {{ id }} image {%- endif %} {%- if required_containers is defined %} {%- for containerid in required_containers %} {%- if grains['saltversioninfo'] >= [2017, 7, 0] %} - - docker_image: {{containerid}} + - docker_image: {{ containerid }} {%- else %} - - docker: {{containerid}} + - docker: {{ containerid }} {%- endif %} {%- endfor %} {%- endif %}