<h5 dir="auto">Issue Type:</h5>
<p dir="auto">“Feature Idea”</p>
<h5 dir="auto">Ansible Version:</h5>
<p dir="auto"><a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/ansible/ansible/commit/c6b26ff7c79cd73c98b161022044f3678ab7378d/hovercard" href="https://github.com/ansible/ansible/commit/c6b26ff7c79cd73c98b161022044f3678ab7378d"><tt>c6b26ff</tt></a></p>
<h5 dir="auto">Summary:</h5>
<p dir="auto">Hi,<br>
I need to dump all the vars available at certain steps of playbook so I tried to follow <a href="https://coderwall.com/p/13lh6w" rel="nofollow">this tip</a>.<br>
At first it looks like it does what I need but then I noticed that dumping <code class="notranslate">vars</code> gives me variables specified only in role's vars file and no vars inherited from <code class="notranslate">group_vars/</code>.<br>
Inspecting <code class="notranslate">lib/ansible/runner/__init__.py</code> I see this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="# use combined_cache and host_variables to template the module_vars                  
# we update the inject variables with the data we're about to template               
# since some of the variables we'll be replacing may be contained there too          
module_vars_inject = utils.combine_vars(host_variables, combined_cache.get(host, {}))
module_vars_inject = utils.combine_vars(self.module_vars, module_vars_inject)        
module_vars = template.template(self.basedir, self.module_vars, module_vars_inject)"><pre class="notranslate"><code class="notranslate"># use combined_cache and host_variables to template the module_vars                  
# we update the inject variables with the data we're about to template               
# since some of the variables we'll be replacing may be contained there too          
module_vars_inject = utils.combine_vars(host_variables, combined_cache.get(host, {}))
module_vars_inject = utils.combine_vars(self.module_vars, module_vars_inject)        
module_vars = template.template(self.basedir, self.module_vars, module_vars_inject)
</code></pre></div>
<p dir="auto">and I see that vars inherited from <code class="notranslate">group_vars</code> are contained in <code class="notranslate">host_variables</code>.<br>
Now I'm in doubt whether they should get in <code class="notranslate">module_vars</code> here and there's just a bug at this point<br>
or they should not and then I'd like to add them later to <code class="notranslate">inject</code> dict like it's done with <code class="notranslate">module_vars</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="inject['vars']        = self.module_vars"><pre class="notranslate"><code class="notranslate">inject['vars']        = self.module_vars
</code></pre></div>
<p dir="auto">Currently if we are trying to register an instance that has not yet<br>
been registered with the elb an exception is thrown as follows:</p>
<p dir="auto">Traceback (most recent call last):<br>
File "/home/ubuntu/.ansible/tmp/ansible-1388916053.26-72858643329411/ec2_elb", line 1412, in<br>
main()<br>
File "/home/ubuntu/.ansible/tmp/ansible-1388916053.26-72858643329411/ec2_elb", line 335, in main<br>
elb_man.register(wait, enable_availability_zone)<br>
File "/home/ubuntu/.ansible/tmp/ansible-1388916053.26-72858643329411/ec2_elb", line 168, in register<br>
self.awaitelb_instance_state(lb, 'InService', initial_state)<br>
File "/home/ubuntu/.ansible/tmp/ansible-1388916053.26-72858643329411/ec2_elb", line 213, in awaitelb_instance_state<br>
if instance_state.state != initial_state.state:<br>
AttributeError: 'NoneType' object has no attribute 'state'</p>
<p dir="auto">This is expected because the code is querying the elb for the state of the new instance and it responds with a "InvalidInstance" response (as its not been registered with the ELB yet) and the code sets the value of the initial_state to None.</p>
<p dir="auto">This code change checks if the initial_state is None. If it is, its safe to assume that its state has changed.</p>
<p dir="auto">I have create <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="25068793" data-permission-text="Title is private" data-url="https://github.com/ansible/ansible/issues/5506" data-hovercard-type="pull_request" data-hovercard-url="/ansible/ansible/pull/5506/hovercard" href="https://github.com/ansible/ansible/pull/5506">#5506</a> as a suggested fix</p>