企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
功能:收集远程主机的信息 Gathers facts about remote hosts 案例1:获取IP地址 ~~~ [admin@node1 tmp]$ ansible 192.168.20.138 -m setup -a 'filter=ansible_default_ipv4' 192.168.20.138 | SUCCESS => { "ansible_facts": { "ansible_default_ipv4": { "address": "10.2.13.186", "alias": "eth0", "broadcast": "10.2.13.255", "gateway": "10.2.13.1", "interface": "eth0", "macaddress": "52:54:00:7d:e2:a7", "mtu": 1500, "netmask": "255.255.255.0", "network": "10.2.13.0", "type": "ether" } }, "changed": false } ~~~ 案例2: 获取内存信息 ~~~ [admin@node1 tmp]$ ansible 192.168.20.138 -m setup -a 'filter=ansible_memory_mb' 192.168.20.138 | SUCCESS => { "ansible_facts": { "ansible_memory_mb": { "nocache": { "free": 803, "used": 189 }, "real": { "free": 504, "total": 992, "used": 488 }, "swap": { "cached": 0, "free": 1535, "total": 1535, "used": 0 } } }, "changed": false } ~~~ 案例3: 完整的 ~~~ [admin@node1 tmp]$ ansible 192.168.20.138 -m setup 192.168.20.138 | SUCCESS => { "ansible_facts": { "ansible_all_ipv4_addresses": [ "192.168.20.138", "10.2.13.186" ], "ansible_all_ipv6_addresses": [ "fe80::2d17:cf1e:d607:74cd", "fe80::5054:ff:fe7d:e2a7" ], "ansible_apparmor": { "status": "disabled" }, "ansible_architecture": "x86_64", "ansible_bios_date": "01/01/2011", "ansible_bios_version": "0.5.1", "ansible_cmdline": { "BOOT_IMAGE": "/vmlinuz-3.10.0-514.el7.x86_64", "LANG": "en_US.UTF-8", "quiet": true, "rd.lvm.lv": "cl/swap", "rhgb": true, "ro": true, "root": "/dev/mapper/cl-root" }, "ansible_date_time": { "date": "2018-03-17", "day": "17", "epoch": "1521276322", "hour": "16", "iso8601": "2018-03-17T08:45:22Z", "iso8601_basic": "20180317T164522002600", "iso8601_basic_short": "20180317T164522", "iso8601_micro": "2018-03-17T08:45:22.002706Z", "minute": "45", "month": "03", "second": "22", "time": "16:45:22", "tz": "CST", "tz_offset": "+0800", "weekday": "Saturday", "weekday_number": "6", "weeknumber": "11", "year": "2018" }, "ansible_default_ipv4": { "address": "10.2.13.186", "alias": "eth0", "broadcast": "10.2.13.255", "gateway": "10.2.13.1", "interface": "eth0", "macaddress": "52:54:00:7d:e2:a7", "mtu": 1500, "netmask": "255.255.255.0", "network": "10.2.13.0", "type": "ether" }, "ansible_default_ipv6": {}, "ansible_device_links": { "ids": { "dm-0": [ "dm-name-cl-root", "dm-uuid-LVM-iCL46nigPYk5g5fGbSL9cfhfmA0Bea920WBurpJ59HDHoxsqEQwSPC1wolrBatx9" ], "dm-1": [ "dm-name-cl-swap", "dm-uuid-LVM-iCL46nigPYk5g5fGbSL9cfhfmA0Bea92hfwtV112mK8Ujdhcq4XQjEeC7rl3rcpa" ], "sr0": [ "ata-QEMU_DVD-ROM_QM00004" ], "vda2": [ "lvm-pv-uuid-0iD7At-VxDi-H7wR-Fiqz-EceB-5Rho-IS7QYY" ] }, "labels": { "sr0": [ "CentOS\\x207\\x20x86_64" ] }, "masters": { "vda2": [ "dm-0", "dm-1" ] }, "uuids": { "dm-0": [ "774d1665-4719-40d5-b538-e85016756755" ], "dm-1": [ "74717b34-a707-4dd3-ab6b-c5f1eaa1610e" ], "sr0": [ "2016-12-05-13-52-39-00" ], "vda1": [ "16f3c4ed-7b9b-44ce-b92f-3c08efaac495" ] } }, "ansible_devices": { "dm-0": { "holders": [], "host": "", "links": { "ids": [ "dm-name-cl-root", "dm-uuid-LVM-iCL46nigPYk5g5fGbSL9cfhfmA0Bea920WBurpJ59HDHoxsqEQwSPC1wolrBatx9" ], "labels": [], "masters": [], "uuids": [ "774d1665-4719-40d5-b538-e85016756755" ] }, "model": null, "partitions": {}, "removable": "0", "rotational": "1", "sas_address": null, "sas_device_handle": null, "scheduler_mode": "", "sectors": "26206208", "sectorsize": "512", "size": "12.50 GB", "support_discard": "0", "vendor": null, "virtual": 1 }, "dm-1": { "holders": [], "host": "", "links": { "ids": [ "dm-name-cl-swap", "dm-uuid-LVM-iCL46nigPYk5g5fGbSL9cfhfmA0Bea92hfwtV112mK8Ujdhcq4XQjEeC7rl3rcpa" ], "labels": [], "masters": [], "uuids": [ "74717b34-a707-4dd3-ab6b-c5f1eaa1610e" ] }, "model": null, "partitions": {}, "removable": "0", "rotational": "1", "sas_address": null, "sas_device_handle": null, "scheduler_mode": "", "sectors": "3145728", "sectorsize": "512", "size": "1.50 GB", "support_discard": "0", "vendor": null, "virtual": 1 }, "sr0": { "holders": [], "host": "IDE interface: Intel Corporation 82371SB PIIX3 IDE [Natoma/Triton II]", "links": { "ids": [ "ata-QEMU_DVD-ROM_QM00004" ], "labels": [ "CentOS\\x207\\x20x86_64" ], "masters": [], "uuids": [ "2016-12-05-13-52-39-00" ] }, "model": "QEMU DVD-ROM", "partitions": {}, "removable": "1", "rotational": "1", "sas_address": null, "sas_device_handle": null, "scheduler_mode": "cfq", "sectors": "16173056", "sectorsize": "2048", "size": "30.85 GB", "support_discard": "0", "vendor": "QEMU", "virtual": 1 }, "vda": { "holders": [], "host": "SCSI storage controller: Red Hat, Inc Virtio block device", "links": { "ids": [], "labels": [], "masters": [], "uuids": [] }, "model": null, "partitions": { "vda1": { "holders": [], "links": { "ids": [], "labels": [], "masters": [], "uuids": [ "16f3c4ed-7b9b-44ce-b92f-3c08efaac495" ] }, "sectors": "2097152", "sectorsize": 512, "size": "1.00 GB", "start": "2048", "uuid": "16f3c4ed-7b9b-44ce-b92f-3c08efaac495" }, "vda2": { "holders": [ "cl-root", "cl-swap" ], "links": { "ids": [ "lvm-pv-uuid-0iD7At-VxDi-H7wR-Fiqz-EceB-5Rho-IS7QYY" ], "labels": [], "masters": [ "dm-0", "dm-1" ], "uuids": [] }, "sectors": "29358080", "sectorsize": 512, "size": "14.00 GB", "start": "2099200", "uuid": null } }, "removable": "0", "rotational": "1", "sas_address": null, "sas_device_handle": null, "scheduler_mode": "", "sectors": "31457280", "sectorsize": "512", "size": "15.00 GB", "support_discard": "0", "vendor": "0x1af4", "virtual": 1 } }, "ansible_distribution": "CentOS", "ansible_distribution_file_parsed": true, "ansible_distribution_file_path": "/etc/redhat-release", "ansible_distribution_file_variety": "RedHat", "ansible_distribution_major_version": "7", "ansible_distribution_release": "Core", "ansible_distribution_version": "7.3.1611", "ansible_dns": { "nameservers": [ "10.1.10.6" ] }, "ansible_domain": "51yuki.cn", "ansible_effective_group_id": 1010, "ansible_effective_user_id": 1010, "ansible_env": { "HOME": "/home/admin", "LANG": "en_US.UTF-8", "LESSOPEN": "||/usr/bin/lesspipe.sh %s", "LOGNAME": "admin", "LS_COLORS": "rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:", "MAIL": "/var/mail/admin", "PATH": "/usr/local/bin:/usr/bin", "PWD": "/home/admin", "SELINUX_LEVEL_REQUESTED": "", "SELINUX_ROLE_REQUESTED": "", "SELINUX_USE_CURRENT_RANGE": "", "SHELL": "/bin/bash", "SHLVL": "2", "SSH_CLIENT": "192.168.20.130 52248 1050", "SSH_CONNECTION": "192.168.20.130 52248 192.168.20.138 1050", "SSH_TTY": "/dev/pts/2", "TERM": "xterm", "USER": "admin", "XDG_RUNTIME_DIR": "/run/user/1010", "XDG_SESSION_ID": "104", "_": "/usr/bin/python" }, "ansible_eth0": { "active": true, "device": "eth0", "features": { "busy_poll": "off [fixed]", "fcoe_mtu": "off [fixed]", "generic_receive_offload": "on", "generic_segmentation_offload": "on", "highdma": "on [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 [fixed]", "rx_checksumming": "on [fixed]", "rx_fcs": "off [fixed]", "rx_vlan_filter": "on [fixed]", "rx_vlan_offload": "off [fixed]", "rx_vlan_stag_filter": "off [fixed]", "rx_vlan_stag_hw_parse": "off [fixed]", "scatter_gather": "on", "tcp_segmentation_offload": "on", "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_fcoe_segmentation": "off [fixed]", "tx_gre_segmentation": "off [fixed]", "tx_gso_robust": "off [fixed]", "tx_ipip_segmentation": "off [fixed]", "tx_lockless": "off [fixed]", "tx_mpls_segmentation": "off [fixed]", "tx_nocache_copy": "off", "tx_scatter_gather": "on", "tx_scatter_gather_fraglist": "off [fixed]", "tx_sctp_segmentation": "off [fixed]", "tx_sit_segmentation": "off [fixed]", "tx_tcp6_segmentation": "on", "tx_tcp_ecn_segmentation": "on", "tx_tcp_segmentation": "on", "tx_udp_tnl_segmentation": "off [fixed]", "tx_vlan_offload": "off [fixed]", "tx_vlan_stag_hw_insert": "off [fixed]", "udp_fragmentation_offload": "on", "vlan_challenged": "off [fixed]" }, "hw_timestamp_filters": [], "ipv4": { "address": "10.2.13.186", "broadcast": "10.2.13.255", "netmask": "255.255.255.0", "network": "10.2.13.0" }, "ipv6": [ { "address": "fe80::5054:ff:fe7d:e2a7", "prefix": "64", "scope": "link" } ], "macaddress": "52:54:00:7d:e2:a7", "module": "virtio_net", "mtu": 1500, "pciid": "virtio0", "promisc": false, "timestamping": [ "rx_software", "software" ], "type": "ether" }, "ansible_eth1": { "active": true, "device": "eth1", "features": { "busy_poll": "off [fixed]", "fcoe_mtu": "off [fixed]", "generic_receive_offload": "on", "generic_segmentation_offload": "on", "highdma": "on [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 [fixed]", "rx_checksumming": "on [fixed]", "rx_fcs": "off [fixed]", "rx_vlan_filter": "on [fixed]", "rx_vlan_offload": "off [fixed]", "rx_vlan_stag_filter": "off [fixed]", "rx_vlan_stag_hw_parse": "off [fixed]", "scatter_gather": "on", "tcp_segmentation_offload": "on", "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_fcoe_segmentation": "off [fixed]", "tx_gre_segmentation": "off [fixed]", "tx_gso_robust": "off [fixed]", "tx_ipip_segmentation": "off [fixed]", "tx_lockless": "off [fixed]", "tx_mpls_segmentation": "off [fixed]", "tx_nocache_copy": "off", "tx_scatter_gather": "on", "tx_scatter_gather_fraglist": "off [fixed]", "tx_sctp_segmentation": "off [fixed]", "tx_sit_segmentation": "off [fixed]", "tx_tcp6_segmentation": "on", "tx_tcp_ecn_segmentation": "on", "tx_tcp_segmentation": "on", "tx_udp_tnl_segmentation": "off [fixed]", "tx_vlan_offload": "off [fixed]", "tx_vlan_stag_hw_insert": "off [fixed]", "udp_fragmentation_offload": "on", "vlan_challenged": "off [fixed]" }, "hw_timestamp_filters": [], "ipv4": { "address": "192.168.20.138", "broadcast": "192.168.20.255", "netmask": "255.255.255.0", "network": "192.168.20.0" }, "ipv6": [ { "address": "fe80::2d17:cf1e:d607:74cd", "prefix": "64", "scope": "link" } ], "macaddress": "52:54:00:86:f1:1b", "module": "virtio_net", "mtu": 1500, "pciid": "virtio3", "promisc": false, "timestamping": [ "rx_software", "software" ], "type": "ether" }, "ansible_fips": false, "ansible_form_factor": "Other", "ansible_fqdn": "node2.51yuki.cn", "ansible_hostname": "node2", "ansible_interfaces": [ "lo", "eth1", "eth0" ], "ansible_kernel": "3.10.0-514.el7.x86_64", "ansible_lo": { "active": true, "device": "lo", "features": { "busy_poll": "off [fixed]", "fcoe_mtu": "off [fixed]", "generic_receive_offload": "on", "generic_segmentation_offload": "on", "highdma": "on [fixed]", "hw_tc_offload": "off [fixed]", "l2_fwd_offload": "off [fixed]", "large_receive_offload": "off [fixed]", "loopback": "on [fixed]", "netns_local": "on [fixed]", "ntuple_filters": "off [fixed]", "receive_hashing": "off [fixed]", "rx_all": "off [fixed]", "rx_checksumming": "on [fixed]", "rx_fcs": "off [fixed]", "rx_vlan_filter": "off [fixed]", "rx_vlan_offload": "off [fixed]", "rx_vlan_stag_filter": "off [fixed]", "rx_vlan_stag_hw_parse": "off [fixed]", "scatter_gather": "on", "tcp_segmentation_offload": "on", "tx_checksum_fcoe_crc": "off [fixed]", "tx_checksum_ip_generic": "on [fixed]", "tx_checksum_ipv4": "off [fixed]", "tx_checksum_ipv6": "off [fixed]", "tx_checksum_sctp": "on [fixed]", "tx_checksumming": "on", "tx_fcoe_segmentation": "off [fixed]", "tx_gre_segmentation": "off [fixed]", "tx_gso_robust": "off [fixed]", "tx_ipip_segmentation": "off [fixed]", "tx_lockless": "on [fixed]", "tx_mpls_segmentation": "off [fixed]", "tx_nocache_copy": "off [fixed]", "tx_scatter_gather": "on [fixed]", "tx_scatter_gather_fraglist": "on [fixed]", "tx_sctp_segmentation": "on", "tx_sit_segmentation": "off [fixed]", "tx_tcp6_segmentation": "on", "tx_tcp_ecn_segmentation": "on", "tx_tcp_segmentation": "on", "tx_udp_tnl_segmentation": "off [fixed]", "tx_vlan_offload": "off [fixed]", "tx_vlan_stag_hw_insert": "off [fixed]", "udp_fragmentation_offload": "on", "vlan_challenged": "on [fixed]" }, "hw_timestamp_filters": [], "ipv4": { "address": "127.0.0.1", "broadcast": "host", "netmask": "255.0.0.0", "network": "127.0.0.0" }, "ipv6": [ { "address": "::1", "prefix": "128", "scope": "host" } ], "mtu": 65536, "promisc": false, "timestamping": [ "rx_software", "software" ], "type": "loopback" }, "ansible_local": {}, "ansible_lsb": {}, "ansible_machine": "x86_64", "ansible_machine_id": "c5a5266d29fead998cbfc3f24951ca75", "ansible_memfree_mb": 503, "ansible_memory_mb": { "nocache": { "free": 803, "used": 189 }, "real": { "free": 503, "total": 992, "used": 489 }, "swap": { "cached": 0, "free": 1535, "total": 1535, "used": 0 } }, "ansible_memtotal_mb": 992, "ansible_mounts": [ { "block_available": 2875644, "block_size": 4096, "block_total": 3273216, "block_used": 397572, "device": "/dev/mapper/cl-root", "fstype": "xfs", "inode_available": 6495928, "inode_total": 6551552, "inode_used": 55624, "mount": "/", "options": "rw,seclabel,relatime,attr2,inode64,noquota", "size_available": 11778637824, "size_total": 13407092736, "uuid": "774d1665-4719-40d5-b538-e85016756755" }, { "block_available": 228734, "block_size": 4096, "block_total": 259584, "block_used": 30850, "device": "/dev/vda1", "fstype": "xfs", "inode_available": 523959, "inode_total": 524288, "inode_used": 329, "mount": "/boot", "options": "rw,seclabel,relatime,attr2,inode64,noquota", "size_available": 936894464, "size_total": 1063256064, "uuid": "16f3c4ed-7b9b-44ce-b92f-3c08efaac495" } ], "ansible_nodename": "node2.51yuki.cn", "ansible_os_family": "RedHat", "ansible_pkg_mgr": "yum", "ansible_processor": [ "0", "GenuineIntel", "Westmere E56xx/L56xx/X56xx (Nehalem-C)" ], "ansible_processor_cores": 1, "ansible_processor_count": 1, "ansible_processor_threads_per_core": 1, "ansible_processor_vcpus": 1, "ansible_product_name": "KVM", "ansible_product_serial": "NA", "ansible_product_uuid": "NA", "ansible_product_version": "RHEL 7.0.0 PC (i440FX + PIIX, 1996)", "ansible_python": { "executable": "/usr/bin/python", "has_sslcontext": true, "type": "CPython", "version": { "major": 2, "micro": 5, "minor": 7, "releaselevel": "final", "serial": 0 }, "version_info": [ 2, 7, 5, "final", 0 ] }, "ansible_python_version": "2.7.5", "ansible_real_group_id": 1010, "ansible_real_user_id": 1010, "ansible_selinux": { "config_mode": "enforcing", "mode": "permissive", "policyvers": 28, "status": "enabled", "type": "targeted" }, "ansible_selinux_python_present": true, "ansible_service_mgr": "systemd", "ansible_ssh_host_key_ecdsa_public": "AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBD1Eiv8XrgFYh/26kUAM5CXcDnxdtTmNaoVVPsl2QuhysgbcpXCjjXXJiNGDrXpPWsafEddWoV9M1VcYDelsu+g=", "ansible_ssh_host_key_ed25519_public": "AAAAC3NzaC1lZDI1NTE5AAAAIGCSJNdCDASMlzHze0rwqfSuoB9u9iAdWfhUfAx8Xs5m", "ansible_ssh_host_key_rsa_public": "AAAAB3NzaC1yc2EAAAADAQABAAABAQDQgbZL4KxGzPrdyxyju5uexmy1ebiuVn890TbNMUbu93TMTtnJRcOjG9JfOTD+2Fu1nSiH1+NtVKNghU2SzXAqzh5UN4axUdWQmBAwS51NNwuKVaAXrzijbNHRhlL4gbjQTLPiEt2rp55daG8hY6u/vN99YvuiuPCnKiehy0kCz6oiA7ir4tqC5NO+LklDVkBR5rzm+FMToBOyoSYXiyHvRmVmumCBbOqlmHSA1Nl0sYaV+srgAUaMzksLykKO5Q159ZVa+8qfTz6hrfRjxC3E1bKiv3zgQ51uuq6SaqihIckqovYIKtQkMUsJu/sUjLJGT6a5PfQiy+yazB1fnBit", "ansible_swapfree_mb": 1535, "ansible_swaptotal_mb": 1535, "ansible_system": "Linux", "ansible_system_capabilities": [ "" ], "ansible_system_capabilities_enforced": "True", "ansible_system_vendor": "Red Hat", "ansible_uptime_seconds": 81013, "ansible_user_dir": "/home/admin", "ansible_user_gecos": "", "ansible_user_gid": 1010, "ansible_user_id": "admin", "ansible_user_shell": "/bin/bash", "ansible_user_uid": 1010, "ansible_userspace_architecture": "x86_64", "ansible_userspace_bits": "64", "ansible_virtualization_role": "guest", "ansible_virtualization_type": "kvm", "gather_subset": [ "all" ], "module_setup": true }, "changed": false } ~~~