檢查 inventory

  1. 使用 inventory 列出群組 product 群組主機:
    ceuser@deyu:~/ansible_pb$ ansible product -i inventory --list-hosts
      hosts (2):
        node3
        node4
    
  2. 使用 inventory 列出所有受管主機,pattern 'all' 也可用 '*' 代表全部:
    ceuser@deyu:~/ansible_pb$ ansible all -i inventory --list-hosts
      hosts (5):
        node1
        node2
        node5
        node3
        node4
    
  3. 不指定 inventory 下,使用預設檔 /etc/ansible/hosts 受管主機是空的。
    ceuser@deyu:~/ansible_pb$ ansible all --list-hosts
    [WARNING]: provided hosts list is empty, only localhost is available. Note that
    the implicit localhost does not match 'all'
      hosts (0):