title: How to set salt cmd.run changed state based on stderr
body: <p>In ansible you can register a variable to capture the output of running a command, specify a <code>changed_when</code> argument, and use that variable to determine if the state changed:</p>
  <pre class="lang-yaml prettyprint-override"><code>- name: Combine multiple conditions to override 'changed' result
    ansible.builtin.command: /bin/fake_command
    register: result
    ignore_errors: True
    changed_when:
      - '&quot;ERROR&quot; in result.stderr'
      - result.rc == 2
  </code></pre>
  <p>In salt I found that there is a <a href="https://docs.saltproject.io/en/latest/ref/states/all/salt.states.cmd.html#using-the-stateful-argument" rel="nofollow noreferrer">stateful argument</a> to <code>cmd.run</code> but the output appears that it needs to be in a specific json or key=value pair format to do the equivalent. In salt is there a way to do the equivalent of the ansible example to search for the existence of a specific string in the output to determine if the state changed?</p>