title: How to check few keywords in a string and assert if not present in Ansible tasks
body: <p>I have a string like this</p>
  
  <pre><code>"3000 Native                           active    Po121, Po123"
  </code></pre>
  
  <p>I need to check if 3000 is present and active is present in this string. If not assert</p>
  
  <p>I wanted to use <code>when</code> command  and <code>set_fact</code>. Check if the variable present and assert. (which I haven't finished). Right now I am just printing a message. This is not the good to way to do it. If I can assert directly when 3000 and active not present, that would be great.
  Also another question about when, if it matches first condition, it prints the debug message. It should match both right as its an and?</p>
  
  <pre><code>var:
    vlan_output: "3000 Native                           active    Po121, Po123"
  
  item={vlan_id: 3000, state: present}
  </code></pre>
  
  <p>I tried like this</p>
  
  <pre><code> - name: Validate vlan for delete
  
     debug: msg="VLAN FAILED "
  
     when: item.state == "present" and "item.vlan_id not in vlan_output"
  </code></pre>