Skip to content

Instantly share code, notes, and snippets.

@wnkz

wnkz/docker.sls Secret

Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wnkz/306063f54dcfb2f228b7 to your computer and use it in GitHub Desktop.
Save wnkz/306063f54dcfb2f228b7 to your computer and use it in GitHub Desktop.
# foo-docker-app.sls (state)
{% set app = salt['pillar.get']('docker-apps:foo', {}) %}
{% if app %}
[...]
{{ app.name }}-service:
docker.running:
- name: {{ app.name }}
- container: {{ app.name }}
- port_bindings:
{{ app.port_bindings }}
- require:
- docker: {{ app.name }}-container
- watch:
- docker: {{ app.name }}-container
[...]
{% endif %}
# -----
# docker-apps.sls (pillar)
docker-apps:
foo:
name: foo
iname: bar/foo
tag: latest
port_bindings: |
"80/tcp":
HostIp: ""
HostPort: "8001"
@SVQTQ
Copy link

SVQTQ commented Oct 24, 2014

add this before the if statement:
{% set portbinding = salt['pillar.get']('docker-apps:foo:port_bindings'; {}) %}
replace {{ app.port_bindings }} with {{ portbinding }}
that should do the trick, although I haven't tested it..

@SVQTQ
Copy link

SVQTQ commented Oct 24, 2014

another option would be to
{% set app = salt['pillar.get']('docker-apps:foo', {}).items %}
this way (might need some tweaking thought, again, i'm not testing anything) you should be able to access everything in your pillar with app.get('name'), app.get('iname') etc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment