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

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

主站蜘蛛池模板: 泰兴市| 姜堰市| 太仆寺旗| 县级市| 乐安县| 太湖县| 高清| 盐边县| 广水市| 清水河县| 米泉市| 广州市| 涿鹿县| 贞丰县| 宁都县| 十堰市| 惠水县| 阿鲁科尔沁旗| 广灵县| 莫力| 清徐县| 南康市| 道孚县| 军事| 朝阳县| 长宁区| 偃师市| 京山县| 平原县| 德兴市| 牙克石市| 青浦区| 大洼县| 蛟河市| 琼中| 宽城| 遂川县| 莆田市| 尉犁县| 阳江市| 新建县|