Reputation: 431
Being a new ansible user, I'm not able to understand if the control user (except root) needs to exist on target machines too or can those machine be controlled by any user on control machine?
I've tried to go through documentation, but is too overwhelming for a beginner. So tell me if below scenario can be possible?
Upvotes: 1
Views: 712
Reputation: 68189
On a control node as a user (User1@controller) configure ssh connection to the target (User2@target). For example:
[User1@controler]# ssh-copy-id User2@target
Test SSH connection
[User1@controler]# ssh User2@target
On target allow User2 sudo
# grep User2 /usr/local/etc/sudoers
User2 ALL=(ALL) NOPASSWD: ALL
On controller create inventory
[User1@controler]# cat hosts
target
ansible_connection=ssh
ansible_user=User2
ansible_become=yes
ansible_become_user=root
ansible_become_method=sudo
Test Ansible
[User1@controler]# ansible -m setup target
Ansible is a flexible tool. There are many other variations how to configure it. YMMV.
Upvotes: 1