Can anyone help me in inventory variable in Ansible?
I have a server where root login via ssh is not permitted and I used to login on server with a normal user (MYUSER) and then
su - to become root.
I have ssh key-based authentication with user (MYUSER).
Now, I want to execute something like below.
ansible --private-key /PATH/TO/PRIVATE/KEY.KEY -i INVENTORY -m shell -a "whoami" all
But I am getting output as MYUSER.
I want to login on server with my ssh keys in user MYUSER and, then execute some commands using shell module on server via root user :NOTE: I have root password to provide in inventory. Below is the inventory that I created. (^ ^) I know it is wrong.
test-web.example.com ansible_ssh_host=X.X.X.X ansible_ssh_user=MYUSER ansible_become_method=su ansible_become_user=root ansible_become_pass=Xjdt@mdaj12
[root@server ansi]# ansible --private-key /root/MASTER/audit/key.key -i test -m shell -a "whoami" all test-web.example.com | SUCCESS | rc=0 >> MYUSER
How can I make this work?