How to login with root password when using Ansible tool

Here’s how you can log in to a remote system as the root user using the Ansible tool:

  1. Open a terminal and navigate to the directory where your Ansible playbook is located.
  2. Edit the Ansible playbook file to specify the ansible_user as root. For example:
- name: Log in to remote system as root
hosts: <hostname or IP address of remote system>
become: yes
become_user: root
tasks:
- name: Perform some action as root
<module>: <arguments>
  1. Run the Ansible playbook using the following command:
ansible-playbook <playbook name>.yml

Replace <playbook name> with the name of your Ansible playbook file. When the playbook runs, Ansible will log in to the remote system as the root user and perform the specified tasks. If necessary, you can also specify the root password in the playbook using the ansible_become_password variable.

Leave a Comment