title: Configuring Salt SLS files for multiple OS and versions
body: <p>I'm trying to learn Salt and want to set up a deployment mechanism for new VMs.</p>
  
  <p>Currently each VM will have a hostname based on the software and version I wat to install, so:</p>
  
  <ul>
  <li>app-101-1 - Will be an Ubuntu VM with the app software, ver 1.0.1, installed from a local rpm.</li>
  <li>app-101-2 - Will be a CentOS VM the same app software and version but a different rpm because it's a CentOS machine.</li>
  <li>dev-231-1 - Will have the dev software, ver 2.3.1, installed from a different local rpm.</li>
  </ul>
  
  <p>You get the idea.</p>
  
  <p>These RPMs will differ based on application, app version, O/S type and O/S revision:</p>
  
  <ul>
  <li>app-1.0.1-rhel-6-x86_64.tar.gz</li>
  <li>app-1.0.1-ubuntu-14-x86_64.tar.gz</li>
  <li>app-1.0.2-rhel-6-x86_64.tar.gz</li>
  <li>dev-3.2.1-rhel-7-x86_64.tar.gz</li>
  </ul>
  
  <p>I would like the Salt config to be as simple as possible, but ideally I don't want to have a separate SLS file each RPM. So far I have my top.sls as:</p>
  
  <pre><code>base:
    'host:app-101*':
      - match: grain
      - app-101
  </code></pre>
  
  <p>This works, it matches VMs who's names start with "app-101". </p>
  
  <p>I also have an app-101.sls file that looks like:</p>
  
  <pre><code>app:
    'G@os:CentOS and G@osrelease:6.*':
      - match: compound
  
    file.managed:
      - name: /home/user/app-1.0.1-rhel-6-x86_64.tar.gz
      - source: salt://sw/app-1.0.1-rhel-6-x86_64.tar.gz
  
    cmd.run:
      - name: "tar xvzf /home/user/app-1.0.1-rhel-6-x86_64.tar.gz; rpm -ivh /home/user/app-101/*rpm"
      - creates: /usr/local/sbin/app
  </code></pre>
  
  <p>The compound statement doesn't work at all although the file.managed and cmd.run parts do copy the tar ball to the VM and install the RPMs extracted from it, so any comments on that would be appreciated, especially around what is wrong with the compound statement .</p>
  
  <p>However, is there a nicer way to do this? I would expect to be able to have a single SLS file for each app, or at least for each app+version, that can distinguish between the OS name and version and upload/install the right files. Compound statements seem to be the obvious way to go but I can't get them to work, and if I can I still don't see how I can have multiple sets of files in a single SLS file, but maybe I am missing the point here.</p>