<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>

<p dir="auto">import_role</p>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.4.2.0"><pre class="notranslate"><code class="notranslate">ansible 2.4.2.0
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<h5 dir="auto">OS / ENVIRONMENT</h5>

<p dir="auto">python version = 2.7.14 (default, Jan 17 2018, 14:28:32) [GCC 7.2.1 20170915 (Red Hat 7.2.1-2)]</p>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">Using import_role inside handler task fails while other tasks work fine.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>


<p dir="auto">test.yml</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="- hosts: wasservers
  tasks:
  - name: Tester Role
    import_role: name=tester"><pre class="notranslate">- <span class="pl-ent">hosts</span>: <span class="pl-s">wasservers</span>
  <span class="pl-ent">tasks</span>:
  - <span class="pl-ent">name</span>: <span class="pl-s">Tester Role</span>
    <span class="pl-ent">import_role</span>: <span class="pl-s">name=tester</span></pre></div>
<p dir="auto">roles/tester/tasks/main.yml</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="---
- name: Testing Handler
  command: pwd
  notify:
    - TEST_HANDLER_1
    - TEST_HANDLER_2
"><pre class="notranslate">---
- <span class="pl-ent">name</span>: <span class="pl-s">Testing Handler</span>
  <span class="pl-ent">command</span>: <span class="pl-s">pwd</span>
  <span class="pl-ent">notify</span>:
    - <span class="pl-s">TEST_HANDLER_1</span>
    - <span class="pl-s">TEST_HANDLER_2</span>
</pre></div>
<p dir="auto">roles/tester/handlers/main.yml</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="---
- name: TEST_HANDLER_1
  debug: msg=&quot;TEST_HANDLER_1 Called&quot;

- name: TEST_HANDLER_2
  import_role: name=test_role"><pre class="notranslate">---
- <span class="pl-ent">name</span>: <span class="pl-s">TEST_HANDLER_1</span>
  <span class="pl-ent">debug</span>: <span class="pl-s">msg="TEST_HANDLER_1 Called"</span>

- <span class="pl-ent">name</span>: <span class="pl-s">TEST_HANDLER_2</span>
  <span class="pl-ent">import_role</span>: <span class="pl-s">name=test_role</span></pre></div>
<p dir="auto">roles/test_role/tasks/main.yml</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="---
- name: Inside Test Handler Role
  debug: msg=&quot;Called through TEST_HANDLER_2 &quot;"><pre class="notranslate">---
- <span class="pl-ent">name</span>: <span class="pl-s">Inside Test Handler Role</span>
  <span class="pl-ent">debug</span>: <span class="pl-s">msg="Called through TEST_HANDLER_2 "</span></pre></div>

<h5 dir="auto">EXPECTED RESULTS</h5>

<p dir="auto">RUNNING HANDLER [tester : TEST_HANDLER_1] *************************************************************************************************************************************************************************<br>
ok: [192.168.124.85] =&gt; {<br>
"msg": "TEST_HANDLER_1 Called"<br>
}</p>
<p dir="auto">RUNNING HANDLER [tester : TEST_HANDLER_2] *************************************************************************************************************************************************************************<br>
TASK [test_role : Inside Test Handler Role] ***********************************************************************************************************************************************************************<br>
ok: [192.168.124.85] =&gt; {<br>
"msg": "Called through TEST_HANDLER_2 "<br>
}</p>
<h5 dir="auto">ACTUAL RESULTS</h5>


<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="PLAYBOOK: test.yml ************************************************************************************************************************************************************************************************
1 plays in test.yml

PLAY [wasservers] *************************************************************************************************************************************************************************************************
ERROR! Unexpected Exception, this is probably a bug: 'Task' object has no attribute 'listen'
the full traceback was:

Traceback (most recent call last):
  File &quot;/usr/bin/ansible-playbook&quot;, line 106, in &lt;module&gt;
    exit_code = cli.run()
  File &quot;/usr/lib/python2.7/site-packages/ansible/cli/playbook.py&quot;, line 130, in run
    results = pbex.run()
  File &quot;/usr/lib/python2.7/site-packages/ansible/executor/playbook_executor.py&quot;, line 154, in run
    result = self._tqm.run(play=play)
  File &quot;/usr/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py&quot;, line 253, in run
    self._initialize_notified_handlers(new_play)
  File &quot;/usr/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py&quot;, line 142, in _initialize_notified_handlers
    self.update_handler_list(handler_list)
  File &quot;/usr/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py&quot;, line 149, in update_handler_list
    if handler.listen:
AttributeError: 'Task' object has no attribute 'listen'
"><pre class="notranslate"><code class="notranslate">PLAYBOOK: test.yml ************************************************************************************************************************************************************************************************
1 plays in test.yml

PLAY [wasservers] *************************************************************************************************************************************************************************************************
ERROR! Unexpected Exception, this is probably a bug: 'Task' object has no attribute 'listen'
the full traceback was:

Traceback (most recent call last):
  File "/usr/bin/ansible-playbook", line 106, in &lt;module&gt;
    exit_code = cli.run()
  File "/usr/lib/python2.7/site-packages/ansible/cli/playbook.py", line 130, in run
    results = pbex.run()
  File "/usr/lib/python2.7/site-packages/ansible/executor/playbook_executor.py", line 154, in run
    result = self._tqm.run(play=play)
  File "/usr/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py", line 253, in run
    self._initialize_notified_handlers(new_play)
  File "/usr/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py", line 142, in _initialize_notified_handlers
    self.update_handler_list(handler_list)
  File "/usr/lib/python2.7/site-packages/ansible/executor/task_queue_manager.py", line 149, in update_handler_list
    if handler.listen:
AttributeError: 'Task' object has no attribute 'listen'

</code></pre></div>
<h5 dir="auto">ISSUE TYPE</h5>

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>

<p dir="auto">ansible-inventory</p>
<h5 dir="auto">ANSIBLE VERSION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="2.4.1.0-2.4.3.0"><pre class="notranslate"><code class="notranslate">2.4.1.0-2.4.3.0
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<h5 dir="auto">OS / ENVIRONMENT</h5>

<p dir="auto">redhat linux</p>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">ansible-inventory script cannot output inventory when it have yaml files with embedded ecnrypted variables</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>

<p dir="auto">setup simple inventory with yaml file containing embedded encrypted value<br>
run ansible-inventory --list</p>


<p dir="auto"><a href="https://gist.github.com/kudrevatykh/39875c9939d7248cd91f7bd1155a22ae">https://gist.github.com/kudrevatykh/39875c9939d7248cd91f7bd1155a22ae</a></p>
<h5 dir="auto">EXPECTED RESULTS</h5>

<p dir="auto">correct json that can be used as inventory</p>
<h5 dir="auto">ACTUAL RESULTS</h5>

<p dir="auto">exception when output is json and not valid output when yaml (with values &amp;id001, *id001 instead of real value)</p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ERROR! Unexpected Exception, this is probably a bug: u'111' is not JSON serializable
the full traceback was:

Traceback (most recent call last):
  File &quot;/home/kudrale/ansible-2.4.1.0/bin/ansible-inventory&quot;, line 106, in &lt;module&gt;
    exit_code = cli.run()
  File &quot;/home/kudrale/ansible-2.4.1.0/lib/ansible/cli/inventory.py&quot;, line 157, in run
    results = self.dump(results)
  File &quot;/home/kudrale/ansible-2.4.1.0/lib/ansible/cli/inventory.py&quot;, line 174, in dump
    results = json.dumps(stuff, sort_keys=True, indent=4)
  File &quot;/usr/lib64/python2.7/json/__init__.py&quot;, line 250, in dumps
    sort_keys=sort_keys, **kw).encode(obj)
  File &quot;/usr/lib64/python2.7/json/encoder.py&quot;, line 209, in encode
    chunks = list(chunks)
  File &quot;/usr/lib64/python2.7/json/encoder.py&quot;, line 434, in _iterencode
    for chunk in _iterencode_dict(o, _current_indent_level):
  File &quot;/usr/lib64/python2.7/json/encoder.py&quot;, line 408, in _iterencode_dict
    for chunk in chunks:
  File &quot;/usr/lib64/python2.7/json/encoder.py&quot;, line 408, in _iterencode_dict
    for chunk in chunks:
  File &quot;/usr/lib64/python2.7/json/encoder.py&quot;, line 408, in _iterencode_dict
    for chunk in chunks:
  File &quot;/usr/lib64/python2.7/json/encoder.py&quot;, line 408, in _iterencode_dict
    for chunk in chunks:
  File &quot;/usr/lib64/python2.7/json/encoder.py&quot;, line 442, in _iterencode
    o = _default(o)
  File &quot;/usr/lib64/python2.7/json/encoder.py&quot;, line 184, in default
    raise TypeError(repr(o) + &quot; is not JSON serializable&quot;)
TypeError: u'111' is not JSON serializable
"><pre class="notranslate"><code class="notranslate">ERROR! Unexpected Exception, this is probably a bug: u'111' is not JSON serializable
the full traceback was:

Traceback (most recent call last):
  File "/home/kudrale/ansible-2.4.1.0/bin/ansible-inventory", line 106, in &lt;module&gt;
    exit_code = cli.run()
  File "/home/kudrale/ansible-2.4.1.0/lib/ansible/cli/inventory.py", line 157, in run
    results = self.dump(results)
  File "/home/kudrale/ansible-2.4.1.0/lib/ansible/cli/inventory.py", line 174, in dump
    results = json.dumps(stuff, sort_keys=True, indent=4)
  File "/usr/lib64/python2.7/json/__init__.py", line 250, in dumps
    sort_keys=sort_keys, **kw).encode(obj)
  File "/usr/lib64/python2.7/json/encoder.py", line 209, in encode
    chunks = list(chunks)
  File "/usr/lib64/python2.7/json/encoder.py", line 434, in _iterencode
    for chunk in _iterencode_dict(o, _current_indent_level):
  File "/usr/lib64/python2.7/json/encoder.py", line 408, in _iterencode_dict
    for chunk in chunks:
  File "/usr/lib64/python2.7/json/encoder.py", line 408, in _iterencode_dict
    for chunk in chunks:
  File "/usr/lib64/python2.7/json/encoder.py", line 408, in _iterencode_dict
    for chunk in chunks:
  File "/usr/lib64/python2.7/json/encoder.py", line 408, in _iterencode_dict
    for chunk in chunks:
  File "/usr/lib64/python2.7/json/encoder.py", line 442, in _iterencode
    o = _default(o)
  File "/usr/lib64/python2.7/json/encoder.py", line 184, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: u'111' is not JSON serializable

</code></pre></div>