檢查 inventory

  1. 使用 inventory 列出群組 product 群組主機:
    [deyu1@kvm19 10927000]$ ansible product -i inventory --list-hosts
      hosts (2):
        node3
        node4
    
  2. 使用 inventory 列出所有受管主機,pattern 'all' 也可用 '*' 代表全部:
    [deyu1@kvm19 10927000]$ ansible all -i inventory --list-hosts
      hosts (5):
        node1
        node2
        node5
        node3
        node4
    
  3. 在沒有在組態設定 inventory 下,不指定 inventory 下受管主機是空的。
    [deyu1@kvm19 10927000]$ 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):