Ansible:如何使用 shell 命令获取 ansible_hosts 的 ip?

问题描述 投票:0回答:0

我有一个

inventory.yaml
文件:

secondtest:
  hosts:
    host1:
      ansible_host: 192.168.33.168
    host2:
      ansible_host: 192.168.7.151
    host3:
      ansible_host: 192.168.33.158

我想获取所有的 ip 地址,我尝试了

ansible secondtest -i inventory.yaml --list-hosts
这是输出:

  hosts (3):
    host1
    host2
    host3

如何获得 Ips?

ansible ansible-inventory
© www.soinside.com 2019 - 2024. All rights reserved.