-
-
Save anonymous/d23f4f1e6213c07949c7 to your computer and use it in GitHub Desktop.
File is getting - Rendering SLS 'base:docker.containers' failed: found unexpected end of stream; line 66
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
include: | |
- docker.images | |
# docker.containers | |
# Spin up each defined container and link to corresponding sites | |
# | |
# This state also restarts containers when there is a new version of the image pushed | |
{% for name in salt['pillar.get']('docker-containers', []) %} | |
# Remove old containers | |
{{ name }}-remove-if-old: | |
dockerng.absent: | |
- name: {{ name }}_old | |
- unless: docker inspect --format '{{ "{{" }} .Image {{ "}}" }}' {{ name }} | grep $(docker images --no-tr | |
unc | grep "{{ salt['pillar.get']('docker-containers:'+name+':image') }}" | awk '{print $3}') | |
# - onlyif: docker ps | grep -q {{ name }} | |
- require: | |
- dockerng: {{ name }}-image | |
cmd.run: | |
- name: 'docker rename {{ name }} {{ name }}_old | |
- watch: | |
- dockerng: {{ name }}-remove-if-old | |
{{ name }}-stop-old: | |
dockerng.stopped: | |
- name: {{ name }}_old | |
- watch: | |
- cmd: {{ name }}-remove-if-old | |
{{ name }}-running: | |
dockerng.running: | |
- name: {{ name }} | |
- image: {{ salt['pillar.get']('docker-containers:'+name+':image') }} | |
- memory: 0 | |
# - mem_limit: !!null | |
- restart_policy: always | |
- dns: "172.17.42.1" | |
- labels: | |
{% for label in salt['pillar.get']('docker-containers:'+name+':labels', []) %} | |
- {{ label }} | |
#{{ label }}: "{{ pillar['docker-containers'][name].labels[label] }}" | |
{% endfor %} | |
- ports: | |
{% for port in salt['pillar.get']('docker-containers:'+name+':ports') %} | |
{% if salt['pillar.get']('docker-containers:'+name+':ports:'+port+':HostPort', False) %} | |
- "{{ pillar['docker-containers'][name].ports[port].container }}": | |
HostIp: "{{ salt['pillar.get']('docker-containers:'+name+':ports:'+port+':HostIp','') }}" | |
HostPort: "{{ pillar['docker-containers'][name].ports[port].HostPort }}" | |
{% else %} | |
- "{{ pillar['docker-containers'][name].ports[port].container }}" | |
{% endif %} | |
{% endfor %} | |
- environment: | |
{% for env in salt['pillar.get']('docker-containers:'+name+':environment') %} | |
- "{{ env }}": "{{ pillar['docker-containers'][name].environment[env] }}" | |
{% endfor %} | |
{% if salt['pillar.get']('docker-containers:'+name+':volumes', False) or salt['pillar.get']('docker-containers | |
:'+name+':sites',False) %} | |
- volumes: | |
{% for volume in salt['pillar.get']('docker-containers:'+name+':volumes',[]) %} | |
- {{ pillar['docker-containers'][name].volumes[volume].source }}: | |
bind: {{ pillar['docker-containers'][name].volumes[volume].target }} | |
ro: {{ salt['pillar.get']('docker-containers:'+name+':volumes:'+volume+':ro',False) }} | |
{% endfor %} | |
{% for site in salt['pillar.get']('docker-containers:'+name+':sites', []) %} | |
- {{ pillar.sites[site].path }}: | |
bind: {{ pillar.sites[site].path }} | |
ro: True | |
- {{ pillar.sites[site].path + '/' + pillar.sites[site].files }}: | |
bind: {{ pillar.sites[site].path +'/'+ pillar.sites[site].files }} | |
{% if salt['pillar.get']('sites:'+site+':filecache', False) %} | |
- {{ pillar.sites[site].path + '/' + pillar.sites[site].filecache }}: | |
bind: {{ pillar.sites[site].path + '/' + pillar.sites[site].filecache }} | |
{% endif %} | |
{% endfor %} | |
{% endif %} | |
- watch: | |
- dockerng: {{ name }}-container | |
- require: | |
- dockerng: {{ name }}-image | |
{% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment