title: Organize pillar and states to deploy docker container with Salt
body: <p>I'm currently building a deployment system relying on Salt and Docker. For simplicity, let's say I want to deploy a gitlab for 2 clients on the same server. </p>
  
  <p>All the parameters of my apps are stored in Pillar. </p>
  
  <blockquote>
    <p>cat /srv/pillar/top.sls</p>
  </blockquote>
  
  <pre><code>'myminion':
  - client1.git
  - client2.git
  </code></pre>
  
  <blockquote>
    <p>cat /srv/pillar/client1/git.sls </p>
  </blockquote>
  
  <pre><code>gitlab:
      client1:
          domains: 
            - git.client1.net
          container_no : 1
  </code></pre>
  
  <blockquote>
    <p>cat /srv/pillar/client2/git.sls </p>
  </blockquote>
  
  <pre><code>gitlab:
      client2:
          domains: 
            - git.client2.com
          container_no : 2
  </code></pre>
  
  <p>So far, my Salt states contain specific instructions to deploy different application profiles (Django, NodeJS, Gitlab...). For Gitlab it would be : </p>
  
  <blockquote>
    <p>$ cat /srv/salt/profile/gitlab/init.sls</p>
  </blockquote>
  
  <pre><code>{% for app_name,config in pillar.get('gitlab', {}).items() %}
  configure reverse proxy for {{app_name}}:
    module.run:
      - name: haproxyctl.add
      - app_name: {{app_name}}
      - domains: {{ config['domains'] }}
  
  [...]
  {% endfor %}
  </code></pre>
  
  <p>Everything works fine. But with this I can't deploy one app at a time. I have to do : </p>
  
  <blockquote>
    <p>salt myminion state.apply profile.gitlab</p>
  </blockquote>
  
  <p>And this will deploy all gitlab apps on the server. But I would like to be able to trigger only one app. </p>
  
  <p>I'm not playing with Salt for a long time but I feel this loop on all apps is not a elegant way to do the job. What would be the Salty way to do it ? </p>