title: How do we assure that an ansible registered variable has a particular attribute
body: <p>I have a playbook that has the below SQL query:</p>
  
  <pre><code>  - name: "Search for Front"
      command: &gt;
        mysql --user="{{ DBUSER }}" --password="{{ DBPASS }}" deployment
        --host=localhost --batch --skip-column-names
        --execute="SELECT * FROM mytable WHERE num LIKE '{{ Number }}'"
      register: result_front
      when: Layer == 'Front'
  
    - name: "Search for Back"
      command: &gt;
        mysql --user="{{ DBUSER }}" --password="{{ DBPASS }}" deployment
        --host=localhost --batch --skip-column-names
        --execute="SELECT * FROM mytable WHERE num LIKE '{{ Number }}'"
      register: result_back
      when: Layer == 'Back'
  </code></pre>
  
  <p>I trigger this playbook as below:</p>
  
  <pre><code>ansible-playbook test.yml -e "Layer=Front" -e "Number=1234" -e "DBUSER=root" -e "DBPASS=password"
  </code></pre>
  
  <p>Note that at a time only one of the two sql query will execute depending on the parameter "Layer" passed.</p>
  
  <p>I wish to set_fact "reqnum" to string "Deploy" if any of the above two SQL queries returns records found. </p>
  
  <p>Below is what i did:</p>
  
  <pre><code>   - set_fact:
         reqnum: "Deploy"
       when: result_back.stdout_lines | default([]) | length != ""  and result_back.skipped == False
  
     - set_fact:
         reqnum: "Deploy"
       when: result_front.stdout_lines |  default([]) | length != ""  and result_front.skipped == False
  </code></pre>
  
  <p>However, I get the following error:</p>
  
  <pre><code>TASK [set_fact] ****************************************************************
  fatal: [localhost]: FAILED! =&gt; {"msg": "The conditional check 'result_back.stdout_lines == \"\"  and result_back.skipped == False' failed. The error was: error while evaluating conditional (result_back.stdout_lines == \"\"  and result_back.skipped == False): 'dict object' has no attribute 'stdout_lines'\n\nThe error appears to be in '/app/deploy.yml': line 149, column 6, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n   - set_fact:\n     ^ here\n"}
  </code></pre>
  
  <p>What is the correct way to to check such conditions where one variable gets skipped while the other gets a failure or success as a result ?</p>