title: Ansible failed_when statement
body: <p>In the following task I want to make ansible <strong>not</strong> to fail when <code>stderr</code> contains <code>the object has been modified</code> or <code>have a resource type</code>.</p>
  <pre><code>- name: List nodes
    delegate_to: localhost
    shell: kubectl get nodes
    run_once: true
    register: output_error
    failed_when: (output_error.stderr_lines | length &gt; 0) and (&quot;'the object has been modified' not in output_error.stderr or 'have a resource type' not in output_error.stderr&quot;)
  </code></pre>
  <p>However I am reveiving the following error message:</p>
  <pre><code>kubectl get nodes&quot;, &quot;delta&quot;: &quot;0:00:00.498169&quot;, &quot;end&quot;: &quot;2022-08-05 11:08:01.386024&quot;, &quot;failed_when_result&quot;: true, &quot;item&quot;: &quot;nodes&quot;, &quot;rc&quot;: 0, &quot;start&quot;: &quot;2022-08-05 11:08:00.887855&quot;, &quot;stderr&quot;: &quot;error: the server doesn't have a resource type \&quot;nodes\&quot;&quot;, &quot;stderr_lines&quot;: [&quot;error: the server doesn't have a resource type \&quot;nodes\&quot;&quot;], &quot;stdout&quot;: &quot;&quot;, &quot;stdout_lines&quot;: []}
  </code></pre>