Hi team,
look at my playbook
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
Permission denied: '/etc/ssh/sshd_config'
The ansible user can't edit the file, so try "become_user: root" in your task.
Regards
Racke
ansible is user account we created and member of sudor’s ( /etc/sudoers) with full privileges’ same as root.
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
ansible is user account we created and member of sudor's ( /etc/sudoers) with full privileges' same as root.
IMHO the privileges are only the same when using the "sudo" command.
Regards
Racke
what is mean by IMHO
how can i execute all commands through playbook by a normal user with root access.
Hi team ,
can we connect through google meet or zoom
it giving more trouble to me… i hope you guy’s easily catch up that…
Regards,
shivu
what is mean by IMHO
how can i execute all commands through playbook by a normal user with root access.
You don’t seem to understand the concept of privilege escalation.
Hopefully this will enough to help you:
https://docs.ansible.com/ansible/latest/user_guide/become.html
The user ‘ansible’ runs the playbook,. The user ‘ansible’ has sudo privilege as 'root ’
In the playbook, the 'become user ’ is ‘root’
Read the docs pertaining to sudo.
Ansible doesn’t use it directly.