setup
1、获取setup的所有信息,获取的信息有上百条:
ansible all -m setup
"ansible_facts": {
"ansible_all_ipv4_addresses": [
"172.xx.xx.xxx"
],
"ansible_all_ipv6_addresses": [
"fe80::250:56ff:febc:5e1d"
],
..........................................
..........................................
"module_setup": true
},
"changed": false
}
2、对查询的结果进行筛选:
ansible all -m setup -a 'filter=ansible_*_mb'
![img_b657dd23174663af9967f6bab2555edb.png](https://i-blog.csdnimg.cn/blog_migrate/1524511817d9ea97b5c4459e285a0f4f.png)
image.png
3、将每台主机的信息,分别存放到特定目录中,文件名为hosts文件中对应的别名或IP:
ansible all -m setup --tree /tmp/facts
![img_60d914da234f53f577f8118e6bbeb169.png](https://i-blog.csdnimg.cn/blog_migrate/93063c4c5c97e82168b0fdb2b769f646.png)
image.png
stat
4、获取文件的详细信息:
ansible all -m stat -a "path=/root/test.sh"
![img_bd6d0289aade5ccbffc54fa44858314b.png](https://i-blog.csdnimg.cn/blog_migrate/68cd389bdb80c82347035de06941bd92.png)
image.png