# Ansible 2.10.4 authorized\_key - Syntax error

**URL:** <https://forum.ansible.com/t/ansible-2-10-4-authorized-key-syntax-error/34359>\
**Category:** Ansible Project\
**Created:** [December 21, 2020, 3:36am UTC](https://forum.ansible.com/t/ansible-2-10-4-authorized-key-syntax-error/34359 "2020-12-21T03:36:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lucas\_Possamai](https://avatars.discourse-cdn.com/v4/letter/l/5fc32e/32.png) [@Lucas\_Possamai](https://forum.ansible.com/u/Lucas_Possamai)\
**Post date:** [December 21, 2020, 3:36am UTC](https://forum.ansible.com/t/ansible-2-10-4-authorized-key-syntax-error/34359/1 "2020-12-21T03:36:13Z")

</div>

Hi all,

I’m trying to set up [ansible.posix.authorized\_key](https://docs.ansible.com/ansible/latest/collections/ansible/posix/authorized_key_module.html#examples) on my playbook, which look like this:

- name: Set authorized key for Carol  
ansible.posix.authorized\_key:  
user: carol  
state: present  
key: “{{ lookup(‘file’, ‘ssh-keys/carol’) }}”

When executing the playbook (_ansible-playbook -i inventory main.yml_), I get the following message:  
TASK [Set authorized key for Carol] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: SyntaxError: invalid syntax  
fatal: [nzprodapp]: FAILED! =\> {“ansible\_facts”: {“discovered\_interpreter\_python”: “/usr/bin/python”}, “changed”: false, “module\_stderr”: “Shared connection to 192.168.199.3 closed.\r\n”, “module\_stdout”: “Traceback (most recent call last):\r\n File "/home/lucas/.ansible/tmp/ansible-tmp-1608521692.1705554-90163-205930135785049/AnsiballZ\_authorized\_key.py", line 102, in \r\n \_ansiballz\_main()\r\n File "/home/lucas/.ansible/tmp/ansible-tmp-1608521692.1705554-90163-205930135785049/AnsiballZ\_authorized\_key.py", line 94, in \_ansiballz\_main\r\n invoke\_module(zipped\_mod, temp\_path, ANSIBALLZ\_PARAMS)\r\n File "/home/lucas/.ansible/tmp/ansible-tmp-1608521692.1705554-90163-205930135785049/AnsiballZ\_authorized\_key.py", line 40, in invoke\_module\r\n runpy.run\_module(mod\_name=‘ansible\_collections.ansible.posix.plugins.modules.authorized\_key’, init\_globals=None, run\_name=‘ **main** ’, alter\_sys=True)\r\n File "/usr/lib64/python2.6/runpy.py", line 136, in run\_module\r\n fname, loader, pkg\_name)\r\n File "/usr/lib64/python2.6/runpy.py", line 54, in \_run\_module\_code\r\n mod\_loader, pkg\_name)\r\n File "/usr/lib64/python2.6/runpy.py", line 34, in \_run\_code\r\n exec code in run\_globals\r\n File "/tmp/ansible\_ansible.posix.authorized\_key\_payload\_fuOpH9/ansible\_ansible.posix.authorized\_key\_payload.zip/ansible\_collections/ansible/posix/plugins/modules/authorized\_key.py", line 216, in \r\n File "/tmp/ansible\_ansible.posix.authorized\_key\_payload\_fuOpH9/ansible\_ansible.posix.authorized\_key\_payload.zip/ansible/module\_utils/urls.py", line 115, in \r\n File "/usr/lib/python2.6/site-packages/urllib3/ **init**.py", line 7, in \r\n from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection\_from\_url\r\n File "/usr/lib/python2.6/site-packages/urllib3/connectionpool.py", line 105\r\n \_blocking\_errnos = {errno.EAGAIN, errno.EWOULDBLOCK}\r\n ^\r\nSyntaxError: invalid syntax\r\n”, “msg”: “MODULE FAILURE\nSee stdout/stderr for the exact error”, “rc”: 1}

I don’t know what could be the problem here, as my syntax looks identical to the documentation. Could someone please advise?

Thanks and merry xmas! 🙂  
Lucas

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [December 21, 2020, 4:42am UTC](https://forum.ansible.com/t/ansible-2-10-4-authorized-key-syntax-error/34359/2 "2020-12-21T04:42:28Z")

</div>

Hi Lucas,

It seems that you are using Python 2.6 which is old and end-of-life. Please upgrade to the latest version of Python.

I got to know this by looking at log pasted in mail

```auto
/usr/lib/python2.6

```

---

<div class="post-metadata">

**Author:** ![Lucas\_Possamai](https://avatars.discourse-cdn.com/v4/letter/l/5fc32e/32.png) [@Lucas\_Possamai](https://forum.ansible.com/u/Lucas_Possamai)\
**Post date:** [December 21, 2020, 9:07pm UTC](https://forum.ansible.com/t/ansible-2-10-4-authorized-key-syntax-error/34359/3 "2020-12-21T21:07:10Z")

</div>

Hi Abhijeet, thanks for your help.

Indeed the Python version is 2.6, but it works on another server with the same version. So that’s not the issue.

Any other ideas, please?

Thanks!

Lucas

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [December 21, 2020, 9:13pm UTC](https://forum.ansible.com/t/ansible-2-10-4-authorized-key-syntax-error/34359/4 "2020-12-21T21:13:33Z")

</div>

You have a version of urllib3 installed which is not compatible with Python2.6.

You would either need to uninstall urllib3 on that target host, or downgrade it to a version that works with python2.6

The change to drop python2.6 support in urllib3 was done in [https://github.com/urllib3/urllib3/commit/cb2159878f8b47c5b4bc6d159ae2857b85c0a197](https://github.com/urllib3/urllib3/commit/cb2159878f8b47c5b4bc6d159ae2857b85c0a197)

That commit indicates that urllib3 1.24 was the first version to require python2.7 or newer. Which indicates that urllib3 1.23 is the newest version that you can have installed for py26.
