Hi, Does the user "ansible" have write permissions on /etc/ssh/sshd_config?
Regards David When in trouble, or in doubt Run in circles, scream and shout On 14 June 2022, 4:46 pm, at 4:46 pm, 'Shivakumar Venkataswamy' via Ansible Project <[email protected]> wrote: >Hi team, > look at my playbook >--- >- hosts: all > become: true > become_user: ansible > tasks: > - name: add a user to the list of AllowUsers if not present > vars: > usernames: > - shivakumar.venkataswamy > - karthik.reddy > - aman.saxena > lineinfile: > path: /etc/ssh/sshd_config > backrefs: yes > backup: yes > state: absent > regexp: '^AllowUsers((?:(?:\s+\S+(?!\S))(?<!\s{{ usernames >}}))+\s*?)(\n?)$' > line: 'AllowUsers\1 shivakumar.venkataswamy karthik.reddy >aman.saxena\2' > validate: /usr/sbin/sshd -t -f %s > >I'm facing below error, >SSH password: >1 >BECOME password[defaults to SSH password]: >2 >3 >PLAY [all] >*********************************************************************12:45:29 >4 >5 >TASK [Gathering Facts] >*********************************************************12:45:29 >6 >ok: [172.16.13.254] >7 >8 >TASK [add a user to the list of AllowUsers if not present] >*********************12:45:31 >9 >An exception occurred during task execution. To see the full traceback, >use >-vvv. The error was: IOError: [Errno 13] Permission denied: >'/etc/ssh/sshd_config' >10 >fatal: [172.16.13.254]: FAILED! => {"changed": false, "module_stderr": >"Shared connection to 172.16.13.254 closed.\r\n", "module_stdout": >"Traceback (most recent call last):\r\n File >\"/home/ansible/.ansible/tmp/ansible-tmp-1655190931.6542027-6944-29566285149733/AnsiballZ_lineinfile.py\", > >line 102, in <module>\r\n _ansiballz_main()\r\n File >\"/home/ansible/.ansible/tmp/ansible-tmp-1655190931.6542027-6944-29566285149733/AnsiballZ_lineinfile.py\", > >line 94, in _ansiballz_main\r\n invoke_module(zipped_mod, temp_path, >ANSIBALLZ_PARAMS)\r\n File >\"/home/ansible/.ansible/tmp/ansible-tmp-1655190931.6542027-6944-29566285149733/AnsiballZ_lineinfile.py\", > >line 40, in invoke_module\r\n >runpy.run_module(mod_name='ansible.modules.files.lineinfile', >init_globals=None, run_name='__main__', alter_sys=True)\r\n File >\"/usr/lib64/python2.7… >11 >12 >PLAY RECAP >*********************************************************************12:45:32 >13 >172.16.13.254 : ok=1 changed=0 unreachable=0 failed=1 skipped=0 >rescued=0 >ignored=0 > >-- >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 [email protected]. >To view this discussion on the web visit >https://groups.google.com/d/msgid/ansible-project/551f8529-2fc7-409c-bac9-06216fb7c6d5n%40googlegroups.com. -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/b3369bde-eaa8-49ec-afeb-c8b8e208663b%40gmail.com.
