Add And Manage Linux Machines With Ansible

In this blog post, I am going to show you how to add a Linux host to Ansible and make the group work to manage it.

Create file

On my control host, I will edit the hosts’ file /etc/hosts

The host file looks like the YAML file below, where Linux is the name of my hosts’ group.

The IP address belongs to my Linux host that I will manage.

Fill in the details of the variables of your environment ( in the next article you can use passwordless).

You will need to password and username.


Run test

Save the file and run the following command to test.

ansible --inventory=hosts linux --module-name=setup

The shortcut of the above command is:

ansible -I hosts linux -m setup

Success! You're on the list.