—ask-pass.
---
- name: Get ssh key
hosts: all
tasks:
- name: install ssh Key
authorized_key:
user: "{{ ansible_user }}"
state: present
key: "{{lookup('file', '/home/vlad/.ssh/id_rsa.pub')}}"
- name: Backup sudoersfile
command: cp /etc/sudoers /etc/sudoers.bak
changed_when: false
- name: Add line in sudoersfile
lineinfile:
path: /etc/sudoers
line: "{{ ansible_user }} ALL=(ALL:ALL) NOPASSWD:ALL"
insertafter: "%sudo ALL=(ALL:ALL) ALL "
ОШИБКА
: The full traceback is:
Traceback (most recent call last):
File "/home/guest2/.ansible/tmp/ansible-tmp-1697474723.2844176-4340-267409275183569/AnsiballZ_lineinfile.py", line 102, in <module>
_ansiballz_main()
File "/home/guest2/.ansible/tmp/ansible-tmp-1697474723.2844176-4340-267409275183569/AnsiballZ_lineinfile.py", line 94, in _ansiballz_main
invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
File "/home/guest2/.ansible/tmp/ansible-tmp-1697474723.2844176-4340-267409275183569/AnsiballZ_lineinfile.py", line 40, in invoke_module
runpy.run_module(mod_name='ansible.modules.lineinfile', init_globals=None, run_name='main', alter_sys=True)
File "/usr/lib/python3.10/runpy.py", line 224, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/tmp/ansible_lineinfile_payload_trtlilnj/ansible_lineinfile_payload.zip/ansible/modules/lineinfile.py", line 580, in <module>
File "/tmp/ansible_lineinfile_payload_trtlilnj/ansible_lineinfile_payload.zip/ansible/modules/lineinfile.py", line 570, in main
File "/tmp/ansible_lineinfile_payload_trtlilnj/ansible_lineinfile_payload.zip/ansible/modules/lineinfile.py", line 277, in present
PermissionError: [Errno 13] Permission denied: b'/etc/sudoers'
fatal: [192.168.1.47]: FAILED! => {
"changed": false,
"module_stderr": "Shared connection to 192.168.1.47 closed.\r\n",
"module_stdout": "Traceback (most recent call last):\r\n File \"/home/guest2/.ansible/tmp/ansible-tmp-1697474723.2844176-4340-267409275183569/AnsiballZ_lineinfile.py\", line 102, in <module>\r\n _ansiballz_main()\r\n File \"/home/guest2/.ansible/tmp/ansible-tmp-1697474723.2844176-4340-267409275183569/AnsiballZ_lineinfile.py\", line 94, in _ansiballz_main\r\n invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\r\n File \"/home/guest2/.ansible/tmp/ansible-tmp-1697474723.2844176-4340-267409275183569/AnsiballZ_lineinfile.py\", line 40, in invoke_module\r\n runpy.run_module(mod_name='ansible.modules.lineinfile', init_globals=None, run_name='main', alter_sys=True)\r\n File \"/usr/lib/python3.10/runpy.py\", line 224, in run_module\r\n return _run_module_code(code, init_globals, run_name, mod_spec)\r\n File \"/usr/lib/python3.10/runpy.py\", line 96, in _run_module_code\r\n _run_code(code, mod_globals, init_globals,\r\n File \"/usr/lib/python3.10/runpy.py\", line 86, in _run_code\r\n exec(code, run_globals)\r\n File \"/tmp/ansible_lineinfile_payload_trtlilnj/ansible_lineinfile_payload.zip/ansible/modules/lineinfile.py\", line 580, in <module>\r\n File \"/tmp/ansible_lineinfile_payload_trtlilnj/ansible_lineinfile_payload.zip/ansible/modules/lineinfile.py\", line 570, in main\r\n File \"/tmp/ansible_lineinfile_payload_trtlilnj/ansible_lineinfile_payload.zip/ansible/modules/lineinfile.py\", line 277, in present\r\nPermissionError: [Errno 13] Permission denied: b'/etc/sudoers'\r\n",
"msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
"rc": 1
Стикер
я умею только так
become: true ?
fatal: [192.168.1.49]: FAILED! => { "msg": "Missing sudo password" }
Обсуждают сегодня