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

<ul dir="auto">
<li>Bug Report</li>
</ul>
<h5 dir="auto">COMPONENT NAME</h5>
<p dir="auto">jenkins_plugin</p>
<h5 dir="auto">ANSIBLE VERSION</h5>

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

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

<h5 dir="auto">SUMMARY</h5>

<p dir="auto">Getting the following using the jenkins_plugin module:<br>
MODULE FAILURE</p>
<p dir="auto">failed: [manager.virtualbox] (item=mailer) =&gt; {<br>
"failed": true,<br>
"item": "mailer",<br>
"module_stderr": "Shared connection to manager.virtualbox closed.\r\n",<br>
"module_stdout": "Traceback (most recent call last):\r\n  File "/tmp/ansible_zgkt5_ya/ansible_module_jenkins_plugin.py", line 335, in _get_json_data\r\n    json_data = json.load(r)\r\n  File "/usr/lib/python3.5/json/<strong>init</strong>.py", line 268, in load\r\n    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)\r\n  File "/usr/lib/python3.5/json/<strong>init</strong>.py", line 312, in loads\r\n    s.<strong>class</strong>.<strong>name</strong>))\r\nTypeError: the JSON object must be str, not 'bytes'\r\n\r\nDuring handling of the above exception, another exception occurred:\r\n\r\nTraceback (most recent call last):\r\n  File "/tmp/ansible_zgkt5_ya/ansible_module_jenkins_plugin.py", line 817, in \r\n    main()\r\n  File "/tmp/ansible_zgkt5_ya/ansible_module_jenkins_plugin.py", line 796, in main\r\n    jp = JenkinsPlugin(module)\r\n  File "/tmp/ansible_zgkt5_ya/ansible_module_jenkins_plugin.py", line 317, in <strong>init</strong>\r\n    if self._csrf_enabled():\r\n  File "/tmp/ansible_zgkt5_ya/ansible_module_jenkins_plugin.py", line 325, in _csrf_enabled\r\n    "%s/%s" % (self.url, "api/json"), 'CSRF')\r\n  File "/tmp/ansible_zgkt5_ya/ansible_module_jenkins_plugin.py", line 340, in _get_json_data\r\n    details=e.message)\r\nAttributeError: 'TypeError' object has no attribute 'message'\r\n"<br>
}</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>

<p dir="auto">Run any code with jenkins_plugin e.g the following from jeerlingguy.jenkins</p>
<ul dir="auto">
<li>name: Install Jenkins plugins.<br>
jenkins_plugin:<br>
name: "{{ item }}"<br>
params:<br>
url_username: "{{ jenkins_admin_username }}"<br>
url_password: "{{ jenkins_admin_password }}"<br>
updates_expiration: "{{ jenkins_plugin_updates_expiration }}"<br>
url: "http://{{ jenkins_hostname }}:{{ jenkins_http_port }}{{ jenkins_url_prefix }}"<br>
with_items: "{{ jenkins_plugins }}"<br>
notify: restart jenkins</li>
</ul>

<p dir="auto">with the variables passed as:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="jenkins_version: 2.60
jenkins_plugins:
  - ant"><pre class="notranslate"><span class="pl-ent">jenkins_version</span>: <span class="pl-c1">2.60</span>
<span class="pl-ent">jenkins_plugins</span>:
  - <span class="pl-s">ant</span></pre></div>

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

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


<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content=""><pre class="notranslate"><code class="notranslate">
</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"><code class="notranslate">jenkins_plugin</code></p>
<h5 dir="auto">ANSIBLE VERSION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible 2.3.0.0"><pre class="notranslate"><code class="notranslate">ansible 2.3.0.0
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible_python_interpreter=/usr/bin/python3"><pre class="notranslate"><code class="notranslate">ansible_python_interpreter=/usr/bin/python3
</code></pre></div>
<h5 dir="auto">OS / ENVIRONMENT</h5>
<p dir="auto">Host: macOS 10.12.4<br>
Controlled server(s): Ubuntu 16.04 LTS (AWS 64-bit AMI)</p>
<h5 dir="auto">SUMMARY</h5>
<p dir="auto">When I run <code class="notranslate">jenkins_plugin</code> tasks, I get the following error (once for each plugin I attempt to install):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="TASK [geerlingguy.jenkins : Install Jenkins plugins.] ******************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'TypeError' object has no attribute 'message'
failed: [1.2.3.4] (item=git) =&gt; {&quot;failed&quot;: true, &quot;item&quot;: &quot;git&quot;, &quot;module_stderr&quot;: &quot;Traceback (most recent call last):\n  File \&quot;/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\&quot;, line 341, in _get_json_data\n    json_data = json.load(r)\n  File \&quot;/usr/lib/python3.5/json/__init__.py\&quot;, line 268, in load\n    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)\n  File \&quot;/usr/lib/python3.5/json/__init__.py\&quot;, line 312, in loads\n    s.__class__.__name__))\nTypeError: the JSON object must be str, not 'bytes'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \&quot;/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\&quot;, line 823, in &lt;module&gt;\n    main()\n  File \&quot;/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\&quot;, line 802, in main\n    jp = JenkinsPlugin(module)\n  File \&quot;/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\&quot;, line 323, in __init__\n    if self._csrf_enabled():\n  File \&quot;/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\&quot;, line 331, in _csrf_enabled\n    \&quot;%s/%s\&quot; % (self.url, \&quot;api/json\&quot;), 'CSRF')\n  File \&quot;/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\&quot;, line 346, in _get_json_data\n    details=e.message)\nAttributeError: 'TypeError' object has no attribute 'message'\n&quot;, &quot;module_stdout&quot;: &quot;&quot;, &quot;msg&quot;: &quot;MODULE FAILURE&quot;, &quot;rc&quot;: 1}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'TypeError' object has no attribute 'message'"><pre class="notranslate"><code class="notranslate">TASK [geerlingguy.jenkins : Install Jenkins plugins.] ******************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'TypeError' object has no attribute 'message'
failed: [1.2.3.4] (item=git) =&gt; {"failed": true, "item": "git", "module_stderr": "Traceback (most recent call last):\n  File \"/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\", line 341, in _get_json_data\n    json_data = json.load(r)\n  File \"/usr/lib/python3.5/json/__init__.py\", line 268, in load\n    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)\n  File \"/usr/lib/python3.5/json/__init__.py\", line 312, in loads\n    s.__class__.__name__))\nTypeError: the JSON object must be str, not 'bytes'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n  File \"/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\", line 823, in &lt;module&gt;\n    main()\n  File \"/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\", line 802, in main\n    jp = JenkinsPlugin(module)\n  File \"/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\", line 323, in __init__\n    if self._csrf_enabled():\n  File \"/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\", line 331, in _csrf_enabled\n    \"%s/%s\" % (self.url, \"api/json\"), 'CSRF')\n  File \"/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\", line 346, in _get_json_data\n    details=e.message)\nAttributeError: 'TypeError' object has no attribute 'message'\n", "module_stdout": "", "msg": "MODULE FAILURE", "rc": 1}
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: AttributeError: 'TypeError' object has no attribute 'message'
</code></pre></div>
<p dir="auto">Formatted more nicely:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File \&quot;/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\&quot;, line 341, in _get_json_data
    json_data = json.load(r)
  File \&quot;/usr/lib/python3.5/json/__init__.py\&quot;, line 268, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File \&quot;/usr/lib/python3.5/json/__init__.py\&quot;, line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File \&quot;/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\&quot;, line 823, in &lt;module&gt;
    main()
  File \&quot;/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\&quot;, line 802, in main
    jp = JenkinsPlugin(module)
  File \&quot;/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\&quot;, line 323, in __init__
    if self._csrf_enabled():
  File \&quot;/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\&quot;, line 331, in _csrf_enabled
    \&quot;%s/%s\&quot; % (self.url, \&quot;api/json\&quot;), 'CSRF')
  File \&quot;/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\&quot;, line 346, in _get_json_data
    details=e.message)
AttributeError: 'TypeError' object has no attribute 'message'"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File \"/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\", line 341, in _get_json_data
    json_data = json.load(r)
  File \"/usr/lib/python3.5/json/__init__.py\", line 268, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File \"/usr/lib/python3.5/json/__init__.py\", line 312, in loads
    s.__class__.__name__))
TypeError: the JSON object must be str, not 'bytes'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File \"/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\", line 823, in &lt;module&gt;
    main()
  File \"/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\", line 802, in main
    jp = JenkinsPlugin(module)
  File \"/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\", line 323, in __init__
    if self._csrf_enabled():
  File \"/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\", line 331, in _csrf_enabled
    \"%s/%s\" % (self.url, \"api/json\"), 'CSRF')
  File \"/tmp/ansible_42hz6qg4/ansible_module_jenkins_plugin.py\", line 346, in _get_json_data
    details=e.message)
AttributeError: 'TypeError' object has no attribute 'message'
</code></pre></div>
<h5 dir="auto">STEPS TO REPRODUCE</h5>
<p dir="auto">Use a task like the following:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="- name: Install Jenkins plugins.
  jenkins_plugin:
    name: &quot;{{ item }}&quot;
    params:
      url_username: &quot;{{ jenkins_admin_username }}&quot;
      url_password: &quot;{{ jenkins_admin_password }}&quot;
    updates_expiration: &quot;{{ jenkins_plugin_updates_expiration }}&quot;
    url: &quot;http://{{ jenkins_hostname }}:{{ jenkins_http_port }}{{ jenkins_url_prefix }}&quot;
  with_items: &quot;{{ jenkins_plugins }}&quot;
  notify: restart jenkins"><pre class="notranslate">- <span class="pl-ent">name</span>: <span class="pl-s">Install Jenkins plugins.</span>
  <span class="pl-ent">jenkins_plugin</span>:
    <span class="pl-ent">name</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ item }}<span class="pl-pds">"</span></span>
    <span class="pl-ent">params</span>:
      <span class="pl-ent">url_username</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ jenkins_admin_username }}<span class="pl-pds">"</span></span>
      <span class="pl-ent">url_password</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ jenkins_admin_password }}<span class="pl-pds">"</span></span>
    <span class="pl-ent">updates_expiration</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ jenkins_plugin_updates_expiration }}<span class="pl-pds">"</span></span>
    <span class="pl-ent">url</span>: <span class="pl-s"><span class="pl-pds">"</span>http://{{ jenkins_hostname }}:{{ jenkins_http_port }}{{ jenkins_url_prefix }}<span class="pl-pds">"</span></span>
  <span class="pl-ent">with_items</span>: <span class="pl-s"><span class="pl-pds">"</span>{{ jenkins_plugins }}<span class="pl-pds">"</span></span>
  <span class="pl-ent">notify</span>: <span class="pl-s">restart jenkins</span></pre></div>
<p dir="auto">And run it against a system that only has Python 3 available (and set <code class="notranslate">ansible_python_interpreter=/usr/bin/python3</code> in the host inventory).</p>
<h5 dir="auto">EXPECTED RESULTS</h5>
<p dir="auto">The <code class="notranslate">jenkins_plugin</code> module should install plugins successfully, and not show an error message.</p>
<h5 dir="auto">ACTUAL RESULTS</h5>
<p dir="auto">See summary above.</p>
<h5 dir="auto">Workaround</h5>
<p dir="auto">My workaround, for now, is to use the method of installing Python 2 listed in this post: <a href="https://www.jeffgeerling.com/blog/2017/how-fix-ssh-errors-when-using-ansible-newer-oses-ubuntu-1604" rel="nofollow">How to fix SSH errors when using Ansible with newer OSes like Ubuntu 16.04</a></p>