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

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.

主站蜘蛛池模板: 晋江市| 罗源县| 祁阳县| 扶沟县| 蒙山县| 迁西县| 且末县| 哈密市| 西充县| 固镇县| 城固县| 濉溪县| 湟源县| 石狮市| 三台县| 陈巴尔虎旗| 蒲城县| 肥西县| 平利县| 女性| 防城港市| 保定市| 横峰县| 台中市| 彭泽县| 海宁市| 海南省| 托克逊县| 二连浩特市| 米易县| 冀州市| 南皮县| 柏乡县| 吉木萨尔县| 安塞县| 河间市| 明星| 陈巴尔虎旗| 舒兰市| 衡南县| 济源市|