title: Ansible register result result.stdout result.rc etc dict variable not found, how to use until loop
body: <p>ansible/ansible-playbook version: 2.1.2.0 / 2.2.0.0</p>
  <p>I'm trying to install a package using yum/apt but as the repository for installing the package is sitting in packagecloud.io, sometimes I'm getting an error message (when I'm passing <code>-vvv</code> while running my ansible-playbook).</p>
  <pre><code>[Errno 14] curl#56 - \&quot;TCP connection reset by peer\&quot;\nTrying other mirror. ...some ansible verbose text here.. [Errno 256] No more mirrors to try.
  </code></pre>
  <p>This doesn't happen all the time. If I re-run the same playbook again, it works fine, so the failure (connection reset) is randomly coming.</p>
  <p>To overcome this issue, I wanted to use Ansible's <code>until</code> loop which we have to use with a <code>register</code> variable.</p>
  <p>So, I created this playbook action by referring Ansible doc for how to use <code>until</code> loop <a href="http://docs.ansible.com/ansible/playbooks_loops.html#do-until-loops" rel="nofollow noreferrer">here</a>, but using that syntax I'm getting a 'dictionary' error saying that result variable (registered) dict doesn't have any key named <em>stdout</em>. Then I tried to use result.rc (key field) and it worked on CentOS machine but failed on an Ubuntu 14.x trusty vagrant machine with the following result.rc dict not present error:</p>
  <pre><code>- name: Install telegraf agent/collector (RedHat)
    yum:
      name: &quot;{{ agent_collector }}&quot;
      state: &quot;installed&quot;
    when: ( ansible_os_family == 'RedHat' and company_install_collector == true )
    register: result
    until: result.stdout.find(&quot;Installed:&quot;) != -1
    #The following works in CentOS/RedHat
    #until: result.rc == 0  
  
   - debug: msg=&quot;result (redhat) = {{ result }}&quot;
  </code></pre>
  <p>OR (Update to my question which was obvious)</p>
  <pre><code>- name: Install Company Proxy (Ubuntu)
    apt:
      name: &quot;{{ company_proxy_pkg }}&quot;
      state: &quot;installed&quot;
    when: ( ansible_distribution == 'Ubuntu' and company_install_proxy == true )
    register: result
    until: result.rc == 0
  
   - debug: msg=&quot;result (ubuntu) = {{ result }}&quot;
  </code></pre>
  <p>Getting the following error messages (result.stdout -- dict object' has no attribute 'stdout' in both RedHat/CentOS and Ubuntu but getting dict object has no attribute 'rc' only in Ubuntu server) :</p>
  <pre><code>fatal: [localhost]: FAILED! =&gt; {&quot;failed&quot;: true, &quot;msg&quot;: &quot;The conditional check '(result.stdout.find(\&quot;Installed:\&quot;) != -1)' failed. The error was: error while evaluating conditional ((result.stdout.find(\&quot;Installed:\&quot;) != -1)): 'dict object' has no attribute 'stdout'&quot;}
  </code></pre>
  <p>and</p>
  <pre><code>fatal: [localhost]: FAILED! =&gt; {
      &quot;failed&quot;: true, 
      &quot;msg&quot;: &quot;The conditional check 'result.rc == 0' failed. The error was: error while evaluating conditional (result.rc == 0): 'dict object' has no attribute 'rc'&quot;
  }
  </code></pre>
  <p>Why the register variable (<strong>result</strong> in my case) is not having <code>stdout</code> or <code>rc</code> dict/variables when the documentation says that those exist or if I can see them in <code>-vvv</code> verbose output on one OS but it doesn't show up on the other OS?</p>