title: failed_when with a service vs a command
body: <p>I want to ensure a list of services is disabled if they exist on a system.  By default, many of these services won't exist, but in cases where the service is installed, I want it disabled.</p>
  
  <p>If a service doesn't exist, ansible throws an error.  While I can continue the task with ignore_error, I'm not comfortable with that because it not only masks a real problem, but the error is still shown in the ansible output, and I'd prefer the team not get in the habit of ignoring errors.</p>
  
  <p>I've tried using failed_when, but I don't seem to be able to get it working with a service, and all the examples use command, not service.  Here's the task--disable_services is a list declared elsewhere.</p>
  
  <pre><code>- name: "Stop and disable unneeded services"
    service: name={{ item }} enabled=no status=stopped
    failed_when: "'service not loaded' not in stderr"
    with_items: disable_services
  </code></pre>
  
  <p>It fails with the following output:</p>
  
  <pre><code>TASK: [hardening | Stop and disable unneeded services] ************************ 
  fatal: [host.example.com] =&gt; error while evaluating conditional: 'service not loaded' not in stderr  
  </code></pre>
  
  <p>I have tried registering the variable service_output, and checking to see that "service not loaded" not in service_output.stderr, but have the same error.</p>
  
  <p>Is it possible to used failed_when on a service, and if so, what Layer 8 problem am I experiencing here?</p>