官术网_书友最值得收藏!

  • Learning DevOps
  • Mikael Krief
  • 205字
  • 2021-06-24 12:32:11

Testing the inventory

Once the inventory is written, it is possible to test whether all of the hosts mentioned are accessible from Ansible. To do this, we can execute the following command:

ansible -i inventory all -u demobook -m ping

The -i argument is the path of the inventory file, the -u argument corresponds to the remote user name used to connect to the remote machine, and -m is the command to execute—here, we execute the ping command on all machines in the inventory.

The following screenshot shows the execution of this command:

We can also test connectivity only on hosts of a particular group by calling this command with the group name instead of all. For example, in our case, we will execute this command:

ansible -i inventory webserver -u demobook -m ping

The following screenshot shows the execution of this command:

In this section, we learned that Ansible needs an inventory file to configure hosts. Then, we created and tested our first inventory file and finally, we saw how to go further in the configuration of this file.

In the next section, we will see how to set up and write the configuration action code in the Ansible playbooks.

主站蜘蛛池模板: 福海县| 沂南县| 绍兴市| 安徽省| 安顺市| 奎屯市| 陆河县| 苍山县| 平邑县| 汕头市| 余干县| 苗栗县| 四平市| 囊谦县| 南部县| 莱西市| 海丰县| 墨脱县| 名山县| 江孜县| 汉寿县| 临高县| 鄂州市| 泉州市| 冷水江市| 南康市| 巴林左旗| 米林县| 安平县| 东乡县| 沈丘县| 康乐县| 二连浩特市| 文化| 彰化县| 西盟| 清流县| 彭水| 苏尼特右旗| 理塘县| 镇坪县|