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

  • 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.

主站蜘蛛池模板: 丽水市| 清远市| 崇阳县| 辉县市| 壶关县| 阿拉善右旗| 定兴县| 赤壁市| 大关县| 盘锦市| 宿州市| 铜梁县| 宿松县| 清远市| 阿坝县| 庆元县| 丹江口市| 阿瓦提县| 哈巴河县| 广灵县| 台前县| 奉化市| 全州县| 上栗县| 海门市| 巨鹿县| 行唐县| 富宁县| 东至县| 嘉义市| 资阳市| 扬州市| 平陆县| 襄樊市| 丰原市| 广平县| 兴业县| 通州市| 青川县| 临西县| 长沙市|