1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
| #打印192.168.98.201机器的所有信息 [root@manage01 ~]# ansible -m setup 192.168.98.201
#使用filter过滤输出 #打印192.168.98.201机器的CPU信息 [root@manage01 ~]# ansible -m setup 192.168.98.201 -a "filter='ansible_processor'" 192.168.98.201 | SUCCESS => { "ansible_facts": { "ansible_processor": [ "0", "GenuineIntel", "Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz", "1", "GenuineIntel", "Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz", "2", "GenuineIntel", "Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz", "3", "GenuineIntel", "Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz" ], "discovered_interpreter_python": "/usr/libexec/platform-python" }, "changed": false } #打印192.168.98.201机器的内核信息 [root@manage01 ~]# ansible -m setup 192.168.98.201 -a "filter='ansible_kernel'" 192.168.98.201 | SUCCESS => { "ansible_facts": { "ansible_kernel": "4.18.0-80.el8.x86_64", "discovered_interpreter_python": "/usr/libexec/platform-python" }, "changed": false } #打印192.168.98.201机器的主机名 [root@manage01 ~]# ansible -m setup 192.168.98.201 -a "filter='ansible_hostname'" 192.168.98.201 | SUCCESS => { "ansible_facts": { "ansible_hostname": "node1", "discovered_interpreter_python": "/usr/libexec/platform-python" }, "changed": false } #打印192.168.98.201机器的网卡信息 [root@manage01 ~]# ansible -m setup 192.168.98.201 -a "filter='ansible_ens*'" 192.168.98.201 | SUCCESS => { "ansible_facts": { "ansible_ens33": { "active": true, "device": "ens33", "features": { "esp_hw_offload": "off [fixed]", "esp_tx_csum_hw_offload": "off [fixed]", "fcoe_mtu": "off [fixed]", "generic_receive_offload": "on", "generic_segmentation_offload": "on", "highdma": "off [fixed]", "hw_tc_offload": "off [fixed]", "l2_fwd_offload": "off [fixed]", "large_receive_offload": "off [fixed]", "loopback": "off [fixed]", "netns_local": "off [fixed]", "ntuple_filters": "off [fixed]", "receive_hashing": "off [fixed]", "rx_all": "off", "rx_checksumming": "off", "rx_fcs": "off", "rx_gro_hw": "off [fixed]", "rx_udp_tunnel_port_offload": "off [fixed]", "rx_vlan_filter": "on [fixed]", "rx_vlan_offload": "on", "rx_vlan_stag_filter": "off [fixed]", "rx_vlan_stag_hw_parse": "off [fixed]", "scatter_gather": "on", "tcp_segmentation_offload": "on", "tls_hw_record": "off [fixed]", "tls_hw_tx_offload": "off [fixed]", "tx_checksum_fcoe_crc": "off [fixed]", "tx_checksum_ip_generic": "on", "tx_checksum_ipv4": "off [fixed]", "tx_checksum_ipv6": "off [fixed]", "tx_checksum_sctp": "off [fixed]", "tx_checksumming": "on", "tx_esp_segmentation": "off [fixed]", "tx_fcoe_segmentation": "off [fixed]", "tx_gre_csum_segmentation": "off [fixed]", "tx_gre_segmentation": "off [fixed]", "tx_gso_partial": "off [fixed]", "tx_gso_robust": "off [fixed]", "tx_ipxip4_segmentation": "off [fixed]", "tx_ipxip6_segmentation": "off [fixed]", "tx_lockless": "off [fixed]", "tx_nocache_copy": "off", "tx_scatter_gather": "on", "tx_scatter_gather_fraglist": "off [fixed]", "tx_sctp_segmentation": "off [fixed]", "tx_tcp6_segmentation": "off [fixed]", "tx_tcp_ecn_segmentation": "off [fixed]", "tx_tcp_mangleid_segmentation": "off", "tx_tcp_segmentation": "on", "tx_udp_segmentation": "off [fixed]", "tx_udp_tnl_csum_segmentation": "off [fixed]", "tx_udp_tnl_segmentation": "off [fixed]", "tx_vlan_offload": "on [fixed]", "tx_vlan_stag_hw_insert": "off [fixed]", "udp_fragmentation_offload": "off", "vlan_challenged": "off [fixed]" }, "hw_timestamp_filters": [], "ipv4": { "address": "192.168.98.201", "broadcast": "192.168.98.255", "netmask": "255.255.255.0", "network": "192.168.98.0" }, "ipv6": [ { "address": "fe80::357b:9443:2232:f0c0", "prefix": "64", "scope": "link" } ], "macaddress": "00:0c:29:b8:d0:45", "module": "e1000", "mtu": 1500, "pciid": "0000:02:01.0", "promisc": false, "speed": 1000, "timestamping": [ "tx_software", "rx_software", "software" ], "type": "ether" }, "discovered_interpreter_python": "/usr/libexec/platform-python" }, "changed": false }
其它常见的过滤条件 ansible_all_ipv4_addresses:显示ipv4的信息。 ansible_devices:显示磁盘设备信息。 ansible_distribution_major_version:显示是系统主版本。 ansible_distribution_version:仅显示系统版本。 ansible_machine:显示系统类型,例:32位,还是64位。 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个数(只显示总的个数)。
|