Create "update all" state in Saltstack
<p>Hello helpful friends,</p>

<p>We have quite a setup here of 100+ servers being managed by Salt states. With different roles in the organization executed by different people, I'd really like to have a possibility to "aggregate" some states. In this case: updating (yum) packages.</p>

<p>I would really like to have our sysadmins safely being able to execute a command like this on the master:</p>

<pre><code>salt '*' state.apply update.packages
</code></pre>

<p>while maybe our developers would be able to execute:</p>

<pre><code>salt 'dev-*' state.apply update.application
</code></pre>

<p>Of course we have a large set of sls files and the key to this issue is that I don't want all those states executed, but just a selected bunch of them.</p>

<p>To achieve this, I've tried to create an <code>update/packages.sls</code> state, containing:</p>

<pre><code>update-packages:
  test.nop
</code></pre>

<p>And then added to, for example the following existing state:</p>

<pre><code>nagios-plugins-all:
  pkg.latest:
    - require:
      - pkg: corepackages
</code></pre>

<p>a <code>watch_in</code> as follows:</p>

<pre><code>nagios-plugins-all:
  pkg.latest:
    - require:
      - pkg: corepackages
    - watch_in:
      - test: update-packages
</code></pre>

<p>Unfortunately, this is clearly not the way to go, as executing <code>salt 'testserver001' state.apply update.packages</code> now only returns:</p>

<pre><code>testserver001:
    ----------
    test_|-update-packages_|-update-packages_|-nop:
        ----------
        __id__:
            update-packages
        __run_num__:
            0
        changes:
            ----------
        comment:
            Success!
        duration:
            0.946
        name:
            update-packages
        result:
            True
        start_time:
            12:10:46.035686
</code></pre>

<p>while I know for sure that updated packages are available. I can't <code>include</code> all the existing state files into the <code>update/packages.sls</code> file, as that would cause <strong>all</strong> states to be executed in those files and that's not what I want either. It would also become a very messy file.</p>

<p>I also don't want to just execute <code>salt '*' pkg.upgrade</code> as I have states depending on updates; i.e. if the package <code>nagios</code> is updated, the states concerning the up-to-date config files should be run and consequently a restart of the <code>nagios</code> service should be executed. All of that is configured in salt using <code>watch</code> and <code>require</code> arguments, so I'd like to use that also when updating my packages. Also, I want to be in control of which packages can be updated.</p>

<p>I don't know if I'm on the right path, or whether this is possible with Salt at all, but maybe someone here has a brilliant idea on how to achieve this behavior. I would be very thankful!</p>