Ansible: Facts获取方法 How to get facts?

参考文章:https://www.middlewareinventory.com/blog/ansible-facts-list-how-to-use-ansible-facts/


常用指令:

ansible -m setup

本地测试指令如:

ansible -i deploy/profiles/ha/hosts config  -u root --key-file ~/.ssh/build.key -m setup

Ansible Gathered Facts or playbook variables belongs to one of the following types

Dictionary:{{ansible_apparmor.status}}

List:{{ansible_all_ipv4_addresses[1]}} (不带[1]会返回整个list内容)

AnsibleUnsafeText:{{ ansible_architecture }}


测试variable类型:{{ | type_debug }}

你可能感兴趣的:(Ansible: Facts获取方法 How to get facts?)