zoukankan      html  css  js  c++  java
  • Ansible学习 Inventory文件

      Ansible可同时操作属于一个组的多台主机,组与主机之间关系配置在inventory文件中,inventory默认的配置文件是/etc/ansible/hosts

    1、在/etc/ansible/hosts文件中配置两个组,分别为test1和test2

    [test1]
    192.168.144.129

    [test2]
    192.168.144.130

    1.1、对一个组操作

    [root@client01 ansible]# ansible test1 -m ping
    192.168.144.129 | SUCCESS => {
    "changed": false,
    "failed": false,
    "ping": "pong"
    }

    1.2、对两个组同时操作

    [root@client01 ansible]# ansible test1:test2 -m ping
    192.168.144.130 | SUCCESS => {
    "changed": false,
    "failed": false,
    "ping": "pong"
    }
    192.168.144.129 | SUCCESS => {
    "changed": false,
    "failed": false,
    "ping": "pong"
    }

    除了默认使用/etc/ansible/hosts,还可用通过-i选项指定inventory文件

    [root@client01 ansible]# ansible all -i /home/zhuwan/ansible/hosts -m ping
    192.168.144.129 | SUCCESS => {
    "changed": false,
    "failed": false,
    "ping": "pong"
    }

  • 相关阅读:
    「manacher」
    「回文自动机」
    「可持久化数据结构(平衡树、trie树、线段树) 」
    「后缀数组」
    「LCT」
    「网络流」
    「一些知识点」
    「至今不会」
    「推荐博客」
    「最小生成树」
  • 原文地址:https://www.cnblogs.com/pigwan7/p/8191863.html
Copyright © 2011-2022 走看看