title: Understanding salt environments
body: <p>I would like to know what is the utility of declaring environments in /etc/salt/master ? </p>
  
  <p>Example : </p>
  
  <pre><code>file_roots:
    base:
      - /srv/salt
    env1:
      - /srv/salt/env1
  </code></pre>
  
  <p>This is the /srv/salt tree: </p>
  
  <pre><code>.
  ├── base
  ├── env1
  │   └── domain1
  │       ├── init.sls
  │       └── nginx.conf
  └── top.sls
  </code></pre>
  
  <p>And the top.sls:</p>
  
  <pre><code>env1:
    '*':
      - env1.domain1
  </code></pre>
  
  <p>This is the init.sls inside env1/domain1/</p>
  
  <pre><code>/etc/nginx/nginx.conf:
    file.managed:
        - source: salt://env1/domain1/nginx.conf 
  </code></pre>
  
  <p>When executing:</p>
  
  <pre><code>salt '*' state.sls env1.domain1
  </code></pre>
  
  <p>everything works fine.</p>
  
  <p>But with highstate:</p>
  
  <pre><code># salt '*' state.highstate
  myHost:
      Data failed to compile:
  ----------
      No matching sls found for 'env1.domain1' in env 'env1'
  </code></pre>
  
  <p>Given that the environment "env1" is declared in master config.I changed my configuration and I have put :</p>
  
  <pre><code>- source: salt://domain1/nginx.conf 
  </code></pre>
  
  <p>instead of:</p>
  
  <pre><code>- source: salt://env1/domain1/nginx.conf 
  </code></pre>
  
  <p>I had this error : </p>
  
  <pre><code> Comment: Source file salt://domain1/nginx.conf not found
  </code></pre>
  
  <p>Is there a misconfiguration somewhere ?
  What is the utility of declaring environments in master conf, 
  if we can't call it directly using <code>salt://subfolder</code> instead of <code>salt://environment/subfolder</code> directly ?</p>
  
  <p>I can't find a good documentation about creating environments and using them !</p>
  
  <p><strong>===Edit===</strong></p>
  
  <p>This is the new configuration:</p>
  
  <p><strong>The master:</strong></p>
  
  <pre><code>file_roots:
    base:
      - /srv/salt/base
    env1:
      - /srv/salt/env1
  </code></pre>
  
  <p><strong>The /srv/salt tree</strong></p>
  
  <pre><code>.
  ├── base
  │   └── init.sls
  ├── conf_template
  ├── env1
  │   └── domain1
  │       ├── init.sls
  │       └── nginx.conf
  └── top.sls
  </code></pre>
  
  <p><strong>top.sls:</strong></p>
  
  <pre><code>base:
    '*':
      - init
  env1:
    '*':
      - domain1
  </code></pre>
  
  <p><strong>And env1/domain1/init.sls:</strong></p>
  
  <pre><code>/etc/nginx/nginx.conf:
    file.managed:
        - source: salt://domain1/nginx.conf
  </code></pre>
  
  <p><strong>and the execution result:</strong></p>
  
  <pre><code>salt '*' state.sls env1.domain1
  myHost:
      Data failed to compile:
  ----------
      No matching sls found for 'env1.domain1' in env 'base'
  </code></pre>