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 \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