ansible模块--setup模块

网友投稿 926 2022-10-10

ansible模块--setup模块

ansible模块--setup模块

1.setup获取ipv4信息

[root@ansible ~]# ansible mysql -m setup -a "filter=ansible_all_ipv4_addresses"192.168.56.88 | SUCCESS => { "ansible_facts": { "ansible_all_ipv4_addresses": [ "192.168.56.88" ], "discovered_interpreter_python": "/usr/bin/python" }, "changed": false}

2.获取内存信息

[root@ansible ~]# ansible mysql -m setup -a "filter=ansible_memory_mb"192.168.56.88 | SUCCESS => { "ansible_facts": { "ansible_memory_mb": { "nocache": { "free": 7541, "used": 440 }, "real": { "free": 7216, "total": 7981, "used": 765 }, "swap": { "cached": 0, "free": 8063, "total": 8063, "used": 0 } }, "discovered_interpreter_python": "/usr/bin/python" }, "changed": false}

3.通过通配符实现模糊匹配,比如以”mb”关键字结尾的信息。

[root@ansible ~]# ansible mysql -m setup -a "filter=*mb"192.168.56.88 | SUCCESS => { "ansible_facts": { "ansible_memfree_mb": 7218, "ansible_memory_mb": { "nocache": { "free": 7543, "used": 438 }, "real": { "free": 7218, "total": 7981, "used": 763 }, "swap": { "cached": 0, "free": 8063, "total": 8063, "used": 0 } }, "ansible_memtotal_mb": 7981, "ansible_swapfree_mb": 8063, "ansible_swaptotal_mb": 8063, "discovered_interpreter_python": "/usr/bin/python" }, "changed": false}

4.获取CPU信息​

[root@ansible ~]# ansible mysql -m setup -a "filter=ansible_processor_vcpus"192.168.56.88 | SUCCESS => { "ansible_facts": { "ansible_processor_vcpus": 10, "discovered_interpreter_python": "/usr/bin/python" }, "changed": false}

5.filter的各种

ansible_all_ipv4_addresses:仅显示ipv4的信息。ansible_devices:仅显示磁盘设备信息。ansible_distribution:显示是什么系统,例:centos,suse等。ansible_distribution_major_version:显示是系统主版本。ansible_distribution_version:仅显示系统版本。ansible_machine:显示系统类型,例:32位,还是64位。ansible_eth0:仅显示eth0的信息。ansible_hostname:仅显示主机名。ansible_kernel:仅显示内核版本。ansible_lvm:显示lvm相关信息。ansible_memtotal_mb:显示系统总内存。ansible_memfree_mb:显示可用系统内存。ansible_memory_mb:详细显示内存情况。ansible_swaptotal_mb:显示总的swap内存。ansible_swapfree_mb:显示swap内存的可用内存。ansible_mounts:显示系统磁盘挂载情况。ansible_processor:显示cpu个数(具体显示每个cpu的型号)。ansible_processor_vcpus:显示cpu个数(只显示总的个数)。

ansible

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:给微信小程序开发提供 TypeScript 支持(给微信小程序开发提供服务)
下一篇:Hashmap非线程安全关于hash值冲突处理
相关文章

 发表评论

暂时没有评论,来抢沙发吧~