Whenever we run a playbook from ansible to update something in a remote host it will ask for a pseudo password. Thus, to bypass exposing the pseudo password from the command line, we can make the user as a pseudo-user in the remote hosts.

To make a user as a pseudo-user in remote hosts which will be used to run the plays, please use ansible roles tasks and ansible play likes given below.

task.yml

---- name: Add sudoers | Allow 'ameyo' group to have passwordless sudo  lineinfile:    dest: /etc/sudoers    state: present    line: '<you_user_name> ALL=(ALL) NOPASSWD: ALL'    validate: visudo -cf %s    insertbefore: EOF

role.yml

---- include: adding-user-sudoers/main.yaml  become: yes

ansible-playbook.yml

---- name: copying ssh key and updating sudoershosts: <your target group name>gather_facts: falsebecome: trueremote_user: <your_remote_user>roles: - add-sudoers-user

--

--

Mahira Technology

Mahira Technology

Determined to solve problems others couldn’t the Mahira way. Never say ‘NO’ to a problem