title: Reload nginx config from salt state, only if the configtest passes
body: <p>I've recently written a salt state which handles the nginx config for a number of servers from some static variables in pillar. I wanted to roll this out to all the servers, but before I did this I wanted to make sure before the config is applied on a server it has first been tested.</p>
  
  <p>Nginx has an inbuilt configtest which I use frequently on command line, and I found that salt has an nginx module which can be used to run configtest.</p>
  
  <p>I have the following in my state file:</p>
  
  <pre><code>reload-nginx:
    service.running:
      - enabled: True
      - reload: True
      - watch:
        - pkg: nginx
        - file: /etc/nginx/sites-available/*
        - file: /etc/nginx/nginx.conf
  </code></pre>
  
  <p>This should reload nginx if the config files change, or if the nginx install is upgraded/changed. I believe I can run a config test using the following in my state file (untested):</p>
  
  <pre><code>nginx-config-test:
    module.run:
      - name: nginx.configtest
  </code></pre>
  
  <p>And I believe if I add this state to the watch in the reload-nginx state it would reload if the configtest passed. </p>
  
  <p>However, I want the reload to happen only if either of the config files have changed <strong>AND</strong> the config test passes, or if nginx changes <strong>AND</strong> the configtest passes. I see I can use onlyif to run a state if <strong>ALL</strong> of the things are True, and from experience you can' have multiple uses of the same method (so I can't have 3 different onlyif's - correct me if I am wrong).</p>
  
  <p>But I don't see any way to reload nginx only if the config files have changed (or nginx has been updated) and the configtest has passed.</p>
  
  <p>Is this possible?</p>