Ansible 2.10.4 authorized_key - Syntax error

63 views
Skip to first unread message

Lucas Possamai

unread,
Dec 20, 2020, 10:37:56 PM12/20/20
to ansible...@googlegroups.com
Hi all,

I'm trying to set up ansible.posix.authorized_key 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 <module>\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 <module>\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 <module>\r\n  File \"/usr/lib/python2.6/site-packages/urllib3/__init__.py\", line 7, in <module>\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

Abhijeet Kasurde

unread,
Dec 20, 2020, 11:42:53 PM12/20/20
to ansible...@googlegroups.com
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

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

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAE_gQfVkUHwCsZY7gKno19fW1ciNBua_PBtvJVR3xrg%2BirYscA%40mail.gmail.com.


--
Thanks,
Abhijeet Kasurde

Lucas Possamai

unread,
Dec 21, 2020, 4:08:52 PM12/21/20
to ansible...@googlegroups.com
On Mon, 21 Dec 2020 at 17:42, Abhijeet Kasurde <akas...@redhat.com> wrote:
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

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


 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

Matt Martz

unread,
Dec 21, 2020, 4:14:35 PM12/21/20
to ansible...@googlegroups.com
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

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.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.


--
Matt Martz
@sivel
sivel.net
Reply all
Reply to author
Forward
0 new messages