# Authorized\_Key module not compatible with Python3?

**URL:** <https://forum.ansible.com/t/authorized-key-module-not-compatible-with-python3/24065>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [March 26, 2017, 8:15pm UTC](https://forum.ansible.com/t/authorized-key-module-not-compatible-with-python3/24065 "2017-03-26T20:15:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Huddleston](https://avatars.discourse-cdn.com/v4/letter/b/2bfe46/32.png) [@Brian\_Huddleston](https://forum.ansible.com/u/Brian_Huddleston)\
**Post date:** [March 26, 2017, 8:15pm UTC](https://forum.ansible.com/t/authorized-key-module-not-compatible-with-python3/24065/1 "2017-03-26T20:15:25Z")

</div>

I use the “authorized\_key” module ([https://docs.ansible.com/ansible/authorized\_key\_module.html](https://docs.ansible.com/ansible/authorized_key_module.html)), for adding SSH keys to the admins of our boxes.

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.

Here is the task:

- name: Add SSH keys for the administrators  
authorized\_key:  
user: bhuddleston  
key: [https://github.com/bhuddleston.keys](https://github.com/bhuddleston.keys)  
state: present

Here is the Error:

{  
“changed”: false,  
“failed”: true,  
“module\_stderr”: “Shared connection to [collector.oitd.net](http://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 \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 \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”  
}

Is this the place to mention this or can I be directed to the correct support channel/group?

---

<div class="post-metadata">

**Author:** ![Andrew\_Latham](https://avatars.discourse-cdn.com/v4/letter/a/ed8c4c/32.png) [@Andrew\_Latham](https://forum.ansible.com/u/Andrew_Latham)\
**Post date:** [March 26, 2017, 8:26pm UTC](https://forum.ansible.com/t/authorized-key-module-not-compatible-with-python3/24065/2 "2017-03-26T20:26:33Z")

</div>

Interesting, this or the ansible-dev list are both good places to bring this up. Can you share the exact version you are using and maybe some system package versions?

---

<div class="post-metadata">

**Author:** ![Brian\_Huddleston](https://avatars.discourse-cdn.com/v4/letter/b/2bfe46/32.png) [@Brian\_Huddleston](https://forum.ansible.com/u/Brian_Huddleston)\
**Post date:** [March 26, 2017, 8:41pm UTC](https://forum.ansible.com/t/authorized-key-module-not-compatible-with-python3/24065/3 "2017-03-26T20:41:00Z")

</div>

I’m running (ansible 2.2.1.0), how do I get the system package versions?

PS: I just opened this issue on the Ansible GitHub repo: [https://github.com/ansible/ansible/issues/22984](https://github.com/ansible/ansible/issues/22984)
