title: Whats the best way in Ansible to check if a command is available?
body: <p>I use the following block to detect if homebrew is already installed. In a new version, homebrew it is installed in the <code>/opt/</code> folder and my “solution” is no longer working. What is a better way to check if a command is available?</p>
  <pre><code>- name: Check if homebrew is installed
    stat:
      path: &quot;/usr/local/bin/brew&quot;
    register: &quot;homebrew_check&quot;
  </code></pre>
  <p>Considerations I know <code>which</code> and <code>command -v</code> but assumed there should be something in Ansible itself, am I wrong?</p>