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

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

<p dir="auto">authorized_key</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
  config file = /Users/brian/Dropbox/Tech-Notes/Programming/Ansible/ansible.cfg
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible 2.2.1.0
  config file = /Users/brian/Dropbox/Tech-Notes/Programming/Ansible/ansible.cfg
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="[defaults]
inventory = inventory
remote_user = ubuntu
ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}
roles_path = roles
retry_files_enabled = False"><pre class="notranslate"><code class="notranslate">[defaults]
inventory = inventory
remote_user = ubuntu
ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}
roles_path = roles
retry_files_enabled = False
</code></pre></div>
<h5 dir="auto">OS / ENVIRONMENT</h5>

<p dir="auto">macOS Sierra (10.12.3)</p>
<h5 dir="auto">SUMMARY</h5>

<p dir="auto">Today I had to use one of my playbooks against a box that only has Python3.  I learned about the "ansible_python_interpreter=/usr/bin/python3" variable I had to set, and my playbook worked through everything until I got to the "authorized_key" where it failed.  I tried the same playbook against an Ubuntu box that still has Python2.7 and it worked fine.  So it seems to be only the Python3.</p>
<h5 dir="auto">STEPS TO REPRODUCE</h5>


<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    - name: Add SSH keys for the administrators
      authorized_key:
        user: bhuddleston
        key: https://github.com/bhuddleston.keys
        state: present"><pre class="notranslate">    - <span class="pl-ent">name</span>: <span class="pl-s">Add SSH keys for the administrators</span>
      <span class="pl-ent">authorized_key</span>:
        <span class="pl-ent">user</span>: <span class="pl-s">bhuddleston</span>
        <span class="pl-ent">key</span>: <span class="pl-s">https://github.com/bhuddleston.keys</span>
        <span class="pl-ent">state</span>: <span class="pl-s">present</span></pre></div>

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

<p dir="auto">TASK [Add SSH keys for the administrators] *************************************<br>
changed: [targethost.domain.net]</p>
<h5 dir="auto">ACTUAL RESULTS</h5>

<p dir="auto">The module gave an error and didn't add the SSH keys to the user.</p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="{
  &quot;changed&quot;: false,
  &quot;failed&quot;: true,
  &quot;module_stderr&quot;: &quot;Shared connection to collector.oitd.net closed.\r\n&quot;,
  &quot;module_stdout&quot;: &quot;Traceback (most recent call last):\r\n  File \&quot;/tmp/ansible__ftramx6/ansible_module_authorized_key.py\&quot;, line 527, in &lt;module&gt;\r\n    main()\r\n  File \&quot;/tmp/ansible__ftramx6/ansible_module_authorized_key.py\&quot;, line 523, in main\r\n    results = enforce_state(module, module.params)\r\n  File \&quot;/tmp/ansible__ftramx6/ansible_module_authorized_key.py\&quot;, line 433, in enforce_state\r\n    key = [s for s in key.splitlines() if s and not s.startswith('#')]\r\n  File \&quot;/tmp/ansible__ftramx6/ansible_module_authorized_key.py\&quot;, line 433, in &lt;listcomp&gt;\r\n    key = [s for s in key.splitlines() if s and not s.startswith('#')]\r\nTypeError: startswith first arg must be bytes or a tuple of bytes, not str\r\n&quot;,
  &quot;msg&quot;: &quot;MODULE FAILURE&quot;
}"><pre class="notranslate"><code class="notranslate">{
  "changed": false,
  "failed": true,
  "module_stderr": "Shared connection to collector.oitd.net closed.\r\n",
  "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible__ftramx6/ansible_module_authorized_key.py\", line 527, in &lt;module&gt;\r\n    main()\r\n  File \"/tmp/ansible__ftramx6/ansible_module_authorized_key.py\", line 523, in main\r\n    results = enforce_state(module, module.params)\r\n  File \"/tmp/ansible__ftramx6/ansible_module_authorized_key.py\", line 433, in enforce_state\r\n    key = [s for s in key.splitlines() if s and not s.startswith('#')]\r\n  File \"/tmp/ansible__ftramx6/ansible_module_authorized_key.py\", line 433, in &lt;listcomp&gt;\r\n    key = [s for s in key.splitlines() if s and not s.startswith('#')]\r\nTypeError: startswith first arg must be bytes or a tuple of bytes, not str\r\n",
  "msg": "MODULE FAILURE"
}
</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">authorized_key core module</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.0.0
  config file = /home/james/active/boss/ansible.cfg
  configured module search path = Default w/o overrides"><pre class="notranslate"><code class="notranslate">ansible 2.2.0.0
  config file = /home/james/active/boss/ansible.cfg
  configured module search path = Default w/o overrides
</code></pre></div>
<h5 dir="auto">CONFIGURATION</h5>

<p dir="auto">[defaults]<br>
nocows=1<br>
inventory=ansible_hosts<br>
host_key_checking=False</p>
<h5 dir="auto">OS / ENVIRONMENT</h5>

<p dir="auto">Local: Ubuntu with Python 3.5.0+ at <code class="notranslate">/usr/bin/python3.5</code><br>
Remote: Ubuntu 16.04.1 with Python 3.5.2 at <code class="notranslate">/usr/bin/python3.5</code></p>
<p dir="auto">Python version is specified with:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="ansible_python_interpreter=/usr/bin/python3.5"><pre class="notranslate"><code class="notranslate">ansible_python_interpreter=/usr/bin/python3.5
</code></pre></div>
<h5 dir="auto">SUMMARY</h5>

<h5 dir="auto">STEPS TO REPRODUCE</h5>

<p dir="auto">Given that user <code class="notranslate">james</code> exists, attempt to install keys from <a href="https://github.com/jamescooke.keys">https://github.com/jamescooke.keys</a> using <code class="notranslate">authorized_key</code> module.</p>

<p dir="auto">Smallest example playbook I could create <code class="notranslate">test.yml</code>:</p>
<div class="highlight highlight-source-yaml notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="---
- hosts: all
  vars:
    - ansible_ssh_user: root
  tasks:
  - authorized_key:
      user: james
      key: https://github.com/jamescooke.keys"><pre class="notranslate">---
- <span class="pl-ent">hosts</span>: <span class="pl-s">all</span>
  <span class="pl-ent">vars</span>:
    - <span class="pl-ent">ansible_ssh_user</span>: <span class="pl-s">root</span>
  <span class="pl-ent">tasks</span>:
  - <span class="pl-ent">authorized_key</span>:
      <span class="pl-ent">user</span>: <span class="pl-s">james</span>
      <span class="pl-ent">key</span>: <span class="pl-s">https://github.com/jamescooke.keys</span></pre></div>

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

<p dir="auto">Two keys would be added to <code class="notranslate">james</code> user on remote.</p>
<h5 dir="auto">ACTUAL RESULTS</h5>

<p dir="auto">Python crashes.</p>

<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="(venv) james@codebox:~/active/boss$ ansible-playbook test.yml -vvvv
Using /home/james/active/boss/ansible.cfg as config file
Loading callback plugin default of type stdout, v2.0 from /home/james/active/boss/venv/lib/python3.5/site-packages/ansible/plugins/callback/__init__.py

PLAYBOOK: test.yml *************************************************************
1 plays in test.yml

PLAY [all] *********************************************************************

TASK [setup] *******************************************************************
Using module file /home/james/active/boss/venv/lib/python3.5/site-packages/ansible/modules/core/system/setup.py
&lt;104.131.17.109&gt; ESTABLISH SSH CONNECTION FOR USER: root
&lt;104.131.17.109&gt; SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/james/.ansible/cp/ansible-ssh-%h-%p-%r 104.131.17.109 '/bin/sh -c '&quot;'&quot;'( umask 77 &amp;&amp; mkdir -p &quot;` echo $HOME/.ansible/tmp/ansible-tmp-1483808135.2190897-90788529272429 `&quot; &amp;&amp; echo ansible-tmp-1483808135.2190897-90788529272429=&quot;` echo $HOME/.ansible/tmp/ansible-tmp-1483808135.2190897-90788529272429 `&quot; ) &amp;&amp; sleep 0'&quot;'&quot;''
&lt;104.131.17.109&gt; PUT /tmp/tmpqi9xuich TO /root/.ansible/tmp/ansible-tmp-1483808135.2190897-90788529272429/setup.py
&lt;104.131.17.109&gt; SSH: EXEC sftp -b - -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/james/.ansible/cp/ansible-ssh-%h-%p-%r '[104.131.17.109]'
&lt;104.131.17.109&gt; ESTABLISH SSH CONNECTION FOR USER: root
&lt;104.131.17.109&gt; SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/james/.ansible/cp/ansible-ssh-%h-%p-%r 104.131.17.109 '/bin/sh -c '&quot;'&quot;'chmod u+x /root/.ansible/tmp/ansible-tmp-1483808135.2190897-90788529272429/ /root/.ansible/tmp/ansible-tmp-1483808135.2190897-90788529272429/setup.py &amp;&amp; sleep 0'&quot;'&quot;''
&lt;104.131.17.109&gt; ESTABLISH SSH CONNECTION FOR USER: root
&lt;104.131.17.109&gt; SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/james/.ansible/cp/ansible-ssh-%h-%p-%r -tt 104.131.17.109 '/bin/sh -c '&quot;'&quot;'/usr/bin/python3.5 /root/.ansible/tmp/ansible-tmp-1483808135.2190897-90788529272429/setup.py; rm -rf &quot;/root/.ansible/tmp/ansible-tmp-1483808135.2190897-90788529272429/&quot; &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0'&quot;'&quot;''
ok: [104.131.17.109]

TASK [authorized_key] **********************************************************
task path: /home/james/active/boss/test.yml:6
Using module file /home/james/active/boss/venv/lib/python3.5/site-packages/ansible/modules/core/system/authorized_key.py
&lt;104.131.17.109&gt; ESTABLISH SSH CONNECTION FOR USER: root
&lt;104.131.17.109&gt; SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/james/.ansible/cp/ansible-ssh-%h-%p-%r 104.131.17.109 '/bin/sh -c '&quot;'&quot;'( umask 77 &amp;&amp; mkdir -p &quot;` echo $HOME/.ansible/tmp/ansible-tmp-1483808139.0550506-81997757222281 `&quot; &amp;&amp; echo ansible-tmp-1483808139.0550506-81997757222281=&quot;` echo $HOME/.ansible/tmp/ansible-tmp-1483808139.0550506-81997757222281 `&quot; ) &amp;&amp; sleep 0'&quot;'&quot;''
&lt;104.131.17.109&gt; PUT /tmp/tmpinuhh2o4 TO /root/.ansible/tmp/ansible-tmp-1483808139.0550506-81997757222281/authorized_key.py
&lt;104.131.17.109&gt; SSH: EXEC sftp -b - -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/james/.ansible/cp/ansible-ssh-%h-%p-%r '[104.131.17.109]'
&lt;104.131.17.109&gt; ESTABLISH SSH CONNECTION FOR USER: root
&lt;104.131.17.109&gt; SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/james/.ansible/cp/ansible-ssh-%h-%p-%r 104.131.17.109 '/bin/sh -c '&quot;'&quot;'chmod u+x /root/.ansible/tmp/ansible-tmp-1483808139.0550506-81997757222281/ /root/.ansible/tmp/ansible-tmp-1483808139.0550506-81997757222281/authorized_key.py &amp;&amp; sleep 0'&quot;'&quot;''
&lt;104.131.17.109&gt; ESTABLISH SSH CONNECTION FOR USER: root
&lt;104.131.17.109&gt; SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/james/.ansible/cp/ansible-ssh-%h-%p-%r -tt 104.131.17.109 '/bin/sh -c '&quot;'&quot;'/usr/bin/python3.5 /root/.ansible/tmp/ansible-tmp-1483808139.0550506-81997757222281/authorized_key.py; rm -rf &quot;/root/.ansible/tmp/ansible-tmp-1483808139.0550506-81997757222281/&quot; &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0'&quot;'&quot;''
fatal: [104.131.17.109]: FAILED! =&gt; {
    &quot;changed&quot;: false,
    &quot;failed&quot;: true,
    &quot;invocation&quot;: {
        &quot;module_name&quot;: &quot;authorized_key&quot;
    },
    &quot;module_stderr&quot;: &quot;OpenSSH_6.9p1 Ubuntu-2ubuntu0.2, OpenSSL 1.0.2d 9 Jul 2015\r\ndebug1: Reading configuration data /home/james/.ssh/config\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 22341\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to 104.131.17.109 closed.\r\n&quot;,
    &quot;module_stdout&quot;: &quot;Traceback (most recent call last):\r\n  File \&quot;/tmp/ansible_grkuvdsh/ansible_module_authorized_key.py\&quot;, line 527, in &lt;module&gt;\r\n    main()\r\n  File \&quot;/tmp/ansible_grkuvdsh/ansible_module_authorized_key.py\&quot;, line 523, in main\r\n    results = enforce_state(module, module.params)\r\n  File \&quot;/tmp/ansible_grkuvdsh/ansible_module_authorized_key.py\&quot;, line 433, in enforce_state\r\n    key = [s for s in key.splitlines() if s and not s.startswith('#')]\r\n  File \&quot;/tmp/ansible_grkuvdsh/ansible_module_authorized_key.py\&quot;, line 433, in &lt;listcomp&gt;\r\n    key = [s for s in key.splitlines() if s and not s.startswith('#')]\r\nTypeError: startswith first arg must be bytes or a tuple of bytes, not str\r\n&quot;,
    &quot;msg&quot;: &quot;MODULE FAILURE&quot;
}
        to retry, use: --limit @/home/james/active/boss/test.retry

PLAY RECAP *********************************************************************
104.131.17.109             : ok=1    changed=0    unreachable=0    failed=1"><pre class="notranslate"><code class="notranslate">(venv) james@codebox:~/active/boss$ ansible-playbook test.yml -vvvv
Using /home/james/active/boss/ansible.cfg as config file
Loading callback plugin default of type stdout, v2.0 from /home/james/active/boss/venv/lib/python3.5/site-packages/ansible/plugins/callback/__init__.py

PLAYBOOK: test.yml *************************************************************
1 plays in test.yml

PLAY [all] *********************************************************************

TASK [setup] *******************************************************************
Using module file /home/james/active/boss/venv/lib/python3.5/site-packages/ansible/modules/core/system/setup.py
&lt;104.131.17.109&gt; ESTABLISH SSH CONNECTION FOR USER: root
&lt;104.131.17.109&gt; SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/james/.ansible/cp/ansible-ssh-%h-%p-%r 104.131.17.109 '/bin/sh -c '"'"'( umask 77 &amp;&amp; mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1483808135.2190897-90788529272429 `" &amp;&amp; echo ansible-tmp-1483808135.2190897-90788529272429="` echo $HOME/.ansible/tmp/ansible-tmp-1483808135.2190897-90788529272429 `" ) &amp;&amp; sleep 0'"'"''
&lt;104.131.17.109&gt; PUT /tmp/tmpqi9xuich TO /root/.ansible/tmp/ansible-tmp-1483808135.2190897-90788529272429/setup.py
&lt;104.131.17.109&gt; SSH: EXEC sftp -b - -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/james/.ansible/cp/ansible-ssh-%h-%p-%r '[104.131.17.109]'
&lt;104.131.17.109&gt; ESTABLISH SSH CONNECTION FOR USER: root
&lt;104.131.17.109&gt; SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/james/.ansible/cp/ansible-ssh-%h-%p-%r 104.131.17.109 '/bin/sh -c '"'"'chmod u+x /root/.ansible/tmp/ansible-tmp-1483808135.2190897-90788529272429/ /root/.ansible/tmp/ansible-tmp-1483808135.2190897-90788529272429/setup.py &amp;&amp; sleep 0'"'"''
&lt;104.131.17.109&gt; ESTABLISH SSH CONNECTION FOR USER: root
&lt;104.131.17.109&gt; SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/james/.ansible/cp/ansible-ssh-%h-%p-%r -tt 104.131.17.109 '/bin/sh -c '"'"'/usr/bin/python3.5 /root/.ansible/tmp/ansible-tmp-1483808135.2190897-90788529272429/setup.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1483808135.2190897-90788529272429/" &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0'"'"''
ok: [104.131.17.109]

TASK [authorized_key] **********************************************************
task path: /home/james/active/boss/test.yml:6
Using module file /home/james/active/boss/venv/lib/python3.5/site-packages/ansible/modules/core/system/authorized_key.py
&lt;104.131.17.109&gt; ESTABLISH SSH CONNECTION FOR USER: root
&lt;104.131.17.109&gt; SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/james/.ansible/cp/ansible-ssh-%h-%p-%r 104.131.17.109 '/bin/sh -c '"'"'( umask 77 &amp;&amp; mkdir -p "` echo $HOME/.ansible/tmp/ansible-tmp-1483808139.0550506-81997757222281 `" &amp;&amp; echo ansible-tmp-1483808139.0550506-81997757222281="` echo $HOME/.ansible/tmp/ansible-tmp-1483808139.0550506-81997757222281 `" ) &amp;&amp; sleep 0'"'"''
&lt;104.131.17.109&gt; PUT /tmp/tmpinuhh2o4 TO /root/.ansible/tmp/ansible-tmp-1483808139.0550506-81997757222281/authorized_key.py
&lt;104.131.17.109&gt; SSH: EXEC sftp -b - -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/james/.ansible/cp/ansible-ssh-%h-%p-%r '[104.131.17.109]'
&lt;104.131.17.109&gt; ESTABLISH SSH CONNECTION FOR USER: root
&lt;104.131.17.109&gt; SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/james/.ansible/cp/ansible-ssh-%h-%p-%r 104.131.17.109 '/bin/sh -c '"'"'chmod u+x /root/.ansible/tmp/ansible-tmp-1483808139.0550506-81997757222281/ /root/.ansible/tmp/ansible-tmp-1483808139.0550506-81997757222281/authorized_key.py &amp;&amp; sleep 0'"'"''
&lt;104.131.17.109&gt; ESTABLISH SSH CONNECTION FOR USER: root
&lt;104.131.17.109&gt; SSH: EXEC ssh -vvv -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/james/.ansible/cp/ansible-ssh-%h-%p-%r -tt 104.131.17.109 '/bin/sh -c '"'"'/usr/bin/python3.5 /root/.ansible/tmp/ansible-tmp-1483808139.0550506-81997757222281/authorized_key.py; rm -rf "/root/.ansible/tmp/ansible-tmp-1483808139.0550506-81997757222281/" &gt; /dev/null 2&gt;&amp;1 &amp;&amp; sleep 0'"'"''
fatal: [104.131.17.109]: FAILED! =&gt; {
    "changed": false,
    "failed": true,
    "invocation": {
        "module_name": "authorized_key"
    },
    "module_stderr": "OpenSSH_6.9p1 Ubuntu-2ubuntu0.2, OpenSSL 1.0.2d 9 Jul 2015\r\ndebug1: Reading configuration data /home/james/.ssh/config\r\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: /etc/ssh/ssh_config line 19: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_forwards: request forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 22341\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 2\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to 104.131.17.109 closed.\r\n",
    "module_stdout": "Traceback (most recent call last):\r\n  File \"/tmp/ansible_grkuvdsh/ansible_module_authorized_key.py\", line 527, in &lt;module&gt;\r\n    main()\r\n  File \"/tmp/ansible_grkuvdsh/ansible_module_authorized_key.py\", line 523, in main\r\n    results = enforce_state(module, module.params)\r\n  File \"/tmp/ansible_grkuvdsh/ansible_module_authorized_key.py\", line 433, in enforce_state\r\n    key = [s for s in key.splitlines() if s and not s.startswith('#')]\r\n  File \"/tmp/ansible_grkuvdsh/ansible_module_authorized_key.py\", line 433, in &lt;listcomp&gt;\r\n    key = [s for s in key.splitlines() if s and not s.startswith('#')]\r\nTypeError: startswith first arg must be bytes or a tuple of bytes, not str\r\n",
    "msg": "MODULE FAILURE"
}
        to retry, use: --limit @/home/james/active/boss/test.retry

PLAY RECAP *********************************************************************
104.131.17.109             : ok=1    changed=0    unreachable=0    failed=1
</code></pre></div>
<p dir="auto">Fails with:</p>
<ul dir="auto">
<li>current master: <a href="https://github.com/ansible/ansible/tree/cba66dfedc4b34c622fb61209dbe355d8bcc8503">https://github.com/ansible/ansible/tree/cba66dfedc4b34c622fb61209dbe355d8bcc8503</a></li>
<li>2.2.0.0 from pip: <a href="https://pypi.python.org/pypi/ansible/2.2.0.0" rel="nofollow">https://pypi.python.org/pypi/ansible/2.2.0.0</a></li>
</ul>