• 欢迎访问蜷缩的蜗牛博客 蜷缩的蜗牛
  • 微信搜索: 蜷缩的蜗牛 | 联系站长 kbsonlong@qq.com
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

实例学习ansible系列(7)常用模块之ping/setup

Ansible 蜷缩的蜗牛 9个月前 (01-23) 102次浏览 已收录

知识点:ping 模块,用于确认和对象机器之间是否能够 ping 通,正常情况会返回 pong
知识点:setup 模块,用于收集对象机器的基本设定信息。

ping 使用实例

<code class=" hljs coffeescript">[root<span class="hljs-property">@host31</span> ansible]<span class="hljs-comment"># ansible host32 -m ping</span>
host32 | SUCCESS<span class="hljs-function"> =></span> {
    <span class="hljs-string">"changed"</span>: <span class="hljs-literal">false</span>,
    <span class="hljs-string">"ping"</span>: <span class="hljs-string">"pong"</span>
}
[root<span class="hljs-property">@host31</span> ansible]<span class="hljs-comment">#</span></code>

setup 使用实例

不用 option 的情况会输出所有相关的对象机器的 facts

<code class=" hljs coffeescript">[root<span class="hljs-property">@host31</span> ~]<span class="hljs-comment"># ansible host32 -m setup</span>
host32 | SUCCESS<span class="hljs-function"> =></span> {
    <span class="hljs-string">"ansible_facts"</span>: {
        <span class="hljs-string">"ansible_all_ipv4_addresses"</span>: [
            <span class="hljs-string">"192.168.122.1"</span>,
            <span class="hljs-string">"172.16.96.1"</span>,
            <span class="hljs-string">"172.16.96.0"</span>,
            <span class="hljs-string">"192.168.32.32"</span>
        ],
        <span class="hljs-string">"ansible_all_ipv6_addresses"</span>: [
            <span class="hljs-string">"fe80::20:56ff:fe8a:59b"</span>,
            <span class="hljs-string">"fe80::20c:29ff:febe:1cff"</span>
        ],
        <span class="hljs-string">"ansible_architecture"</span>: <span class="hljs-string">"x86_64"</span>,
        <span class="hljs-string">"ansible_bios_date"</span>: <span class="hljs-string">"07/02/2015"</span>,
        <span class="hljs-string">"ansible_bios_version"</span>: <span class="hljs-string">"6.00"</span>,
        <span class="hljs-string">"ansible_cmdline"</span>: {
            <span class="hljs-string">"BOOT_IMAGE"</span>: <span class="hljs-string">"/vmlinuz-3.10.0-327.el7.x86_64"</span>,
            <span class="hljs-string">"LANG"</span>: <span class="hljs-string">"en_US.UTF-8"</span>,
            <span class="hljs-string">"quiet"</span>: <span class="hljs-literal">true</span>,
            <span class="hljs-string">"rd.lvm.lv"</span>: <span class="hljs-string">"centos/swap"</span>,
            <span class="hljs-string">"rhgb"</span>: <span class="hljs-literal">true</span>,
            <span class="hljs-string">"ro"</span>: <span class="hljs-literal">true</span>,
            <span class="hljs-string">"root"</span>: <span class="hljs-string">"/dev/mapper/centos-root"</span>
        },
        <span class="hljs-string">"ansible_date_time"</span>: {
            <span class="hljs-string">"date"</span>: <span class="hljs-string">"2016-07-30"</span>,
            <span class="hljs-string">"day"</span>: <span class="hljs-string">"30"</span>,
            <span class="hljs-string">"epoch"</span>: <span class="hljs-string">"1469884080"</span>,
            <span class="hljs-string">"hour"</span>: <span class="hljs-string">"09"</span>,
            <span class="hljs-string">"iso8601"</span>: <span class="hljs-string">"2016-07-30T13:08:00Z"</span>,
            <span class="hljs-string">"iso8601_basic"</span>: <span class="hljs-string">"20160730T090800352254"</span>,
            <span class="hljs-string">"iso8601_basic_short"</span>: <span class="hljs-string">"20160730T090800"</span>,
            <span class="hljs-string">"iso8601_micro"</span>: <span class="hljs-string">"2016-07-30T13:08:00.352338Z"</span>,
            <span class="hljs-string">"minute"</span>: <span class="hljs-string">"08"</span>,
            <span class="hljs-string">"month"</span>: <span class="hljs-string">"07"</span>,
            <span class="hljs-string">"second"</span>: <span class="hljs-string">"00"</span>,
            <span class="hljs-string">"time"</span>: <span class="hljs-string">"09:08:00"</span>,
            <span class="hljs-string">"tz"</span>: <span class="hljs-string">"EDT"</span>,
            <span class="hljs-string">"tz_offset"</span>: <span class="hljs-string">"-0400"</span>,
            <span class="hljs-string">"weekday"</span>: <span class="hljs-string">"Saturday"</span>,
            <span class="hljs-string">"weekday_number"</span>: <span class="hljs-string">"6"</span>,
            <span class="hljs-string">"weeknumber"</span>: <span class="hljs-string">"30"</span>,
            <span class="hljs-string">"year"</span>: <span class="hljs-string">"2016"</span>
        },
        <span class="hljs-string">"ansible_default_ipv4"</span>: {
            <span class="hljs-string">"address"</span>: <span class="hljs-string">"192.168.32.32"</span>,
            <span class="hljs-string">"alias"</span>: <span class="hljs-string">"eno16777736"</span>,
            <span class="hljs-string">"broadcast"</span>: <span class="hljs-string">"192.168.32.255"</span>,
            <span class="hljs-string">"gateway"</span>: <span class="hljs-string">"192.168.32.2"</span>,
            <span class="hljs-string">"interface"</span>: <span class="hljs-string">"eno16777736"</span>,
            <span class="hljs-string">"macaddress"</span>: <span class="hljs-string">"00:0c:29:be:1c:ff"</span>,
            <span class="hljs-string">"mtu"</span>: <span class="hljs-number">1500</span>,
            <span class="hljs-string">"netmask"</span>: <span class="hljs-string">"255.255.255.0"</span>,
            <span class="hljs-string">"network"</span>: <span class="hljs-string">"192.168.32.0"</span>,
            <span class="hljs-string">"type"</span>: <span class="hljs-string">"ether"</span>
        },
        <span class="hljs-string">"ansible_default_ipv6"</span>: {},
        <span class="hljs-string">"ansible_devices"</span>: {
            <span class="hljs-string">"sda"</span>: {
                <span class="hljs-string">"holders"</span>: [],
                <span class="hljs-string">"host"</span>: <span class="hljs-string">"SCSI storage controller: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)"</span>,
                <span class="hljs-string">"model"</span>: <span class="hljs-string">"VMware Virtual S"</span>,
                <span class="hljs-string">"partitions"</span>: {
                    <span class="hljs-string">"sda1"</span>: {
                        <span class="hljs-string">"sectors"</span>: <span class="hljs-string">"1024000"</span>,
                        <span class="hljs-string">"sectorsize"</span>: <span class="hljs-number">512</span>,
                        <span class="hljs-string">"size"</span>: <span class="hljs-string">"500.00 MB"</span>,
                        <span class="hljs-string">"start"</span>: <span class="hljs-string">"2048"</span>
                    },
                    <span class="hljs-string">"sda2"</span>: {
                        <span class="hljs-string">"sectors"</span>: <span class="hljs-string">"19945472"</span>,
                        <span class="hljs-string">"sectorsize"</span>: <span class="hljs-number">512</span>,
                        <span class="hljs-string">"size"</span>: <span class="hljs-string">"9.51 GB"</span>,
                        <span class="hljs-string">"start"</span>: <span class="hljs-string">"1026048"</span>
                    }
                },
                <span class="hljs-string">"removable"</span>: <span class="hljs-string">"0"</span>,
                <span class="hljs-string">"rotational"</span>: <span class="hljs-string">"1"</span>,
                <span class="hljs-string">"sas_address"</span>: <span class="hljs-literal">null</span>,
                <span class="hljs-string">"sas_device_handle"</span>: <span class="hljs-literal">null</span>,
                <span class="hljs-string">"scheduler_mode"</span>: <span class="hljs-string">"deadline"</span>,
                <span class="hljs-string">"sectors"</span>: <span class="hljs-string">"20971520"</span>,
                <span class="hljs-string">"sectorsize"</span>: <span class="hljs-string">"512"</span>,
                <span class="hljs-string">"size"</span>: <span class="hljs-string">"10.00 GB"</span>,
                <span class="hljs-string">"support_discard"</span>: <span class="hljs-string">"0"</span>,
                <span class="hljs-string">"vendor"</span>: <span class="hljs-string">"VMware,"</span>
            },
            <span class="hljs-string">"sr0"</span>: {
                <span class="hljs-string">"holders"</span>: [],
                <span class="hljs-string">"host"</span>: <span class="hljs-string">"IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)"</span>,
                <span class="hljs-string">"model"</span>: <span class="hljs-string">"VMware IDE CDR10"</span>,
                <span class="hljs-string">"partitions"</span>: {},
                <span class="hljs-string">"removable"</span>: <span class="hljs-string">"1"</span>,
                <span class="hljs-string">"rotational"</span>: <span class="hljs-string">"1"</span>,
                <span class="hljs-string">"sas_address"</span>: <span class="hljs-literal">null</span>,
                <span class="hljs-string">"sas_device_handle"</span>: <span class="hljs-literal">null</span>,
                <span class="hljs-string">"scheduler_mode"</span>: <span class="hljs-string">"cfq"</span>,
                <span class="hljs-string">"sectors"</span>: <span class="hljs-string">"2097151"</span>,
                <span class="hljs-string">"sectorsize"</span>: <span class="hljs-string">"512"</span>,
                <span class="hljs-string">"size"</span>: <span class="hljs-string">"1024.00 MB"</span>,
                <span class="hljs-string">"support_discard"</span>: <span class="hljs-string">"0"</span>,
                <span class="hljs-string">"vendor"</span>: <span class="hljs-string">"NECVMWar"</span>
            }
        },
        <span class="hljs-string">"ansible_distribution"</span>: <span class="hljs-string">"CentOS"</span>,
        <span class="hljs-string">"ansible_distribution_major_version"</span>: <span class="hljs-string">"7"</span>,
        <span class="hljs-string">"ansible_distribution_release"</span>: <span class="hljs-string">"Core"</span>,
        <span class="hljs-string">"ansible_distribution_version"</span>: <span class="hljs-string">"7.2.1511"</span>,
        <span class="hljs-string">"ansible_dns"</span>: {
            <span class="hljs-string">"nameservers"</span>: [
                <span class="hljs-string">"8.8.4.4"</span>
            ]
        },
        <span class="hljs-string">"ansible_docker0"</span>: {
            <span class="hljs-string">"active"</span>: <span class="hljs-literal">false</span>,
            <span class="hljs-string">"device"</span>: <span class="hljs-string">"docker0"</span>,
            <span class="hljs-string">"id"</span>: <span class="hljs-string">"8000.02425613a4da"</span>,
            <span class="hljs-string">"interfaces"</span>: [],
            <span class="hljs-string">"ipv4"</span>: {
                <span class="hljs-string">"address"</span>: <span class="hljs-string">"172.16.96.1"</span>,
                <span class="hljs-string">"broadcast"</span>: <span class="hljs-string">"global"</span>,
                <span class="hljs-string">"netmask"</span>: <span class="hljs-string">"255.255.255.0"</span>,
                <span class="hljs-string">"network"</span>: <span class="hljs-string">"172.16.96.0"</span>
            },
            <span class="hljs-string">"macaddress"</span>: <span class="hljs-string">"02:42:56:13:a4:da"</span>,
            <span class="hljs-string">"mtu"</span>: <span class="hljs-number">1500</span>,
            <span class="hljs-string">"promisc"</span>: <span class="hljs-literal">false</span>,
            <span class="hljs-string">"stp"</span>: <span class="hljs-literal">false</span>,
            <span class="hljs-string">"type"</span>: <span class="hljs-string">"bridge"</span>
        },
        <span class="hljs-string">"ansible_domain"</span>: <span class="hljs-string">""</span>,
        <span class="hljs-string">"ansible_eno16777736"</span>: {
            <span class="hljs-string">"active"</span>: <span class="hljs-literal">true</span>,
            <span class="hljs-string">"device"</span>: <span class="hljs-string">"eno16777736"</span>,
            <span class="hljs-string">"ipv4"</span>: {
                <span class="hljs-string">"address"</span>: <span class="hljs-string">"192.168.32.32"</span>,
                <span class="hljs-string">"broadcast"</span>: <span class="hljs-string">"192.168.32.255"</span>,
                <span class="hljs-string">"netmask"</span>: <span class="hljs-string">"255.255.255.0"</span>,
                <span class="hljs-string">"network"</span>: <span class="hljs-string">"192.168.32.0"</span>
            },
            <span class="hljs-string">"ipv6"</span>: [
                {
                    <span class="hljs-string">"address"</span>: <span class="hljs-string">"fe80::20c:29ff:febe:1cff"</span>,
                    <span class="hljs-string">"prefix"</span>: <span class="hljs-string">"64"</span>,
                    <span class="hljs-string">"scope"</span>: <span class="hljs-string">"link"</span>
                }
            ],
            <span class="hljs-string">"macaddress"</span>: <span class="hljs-string">"00:0c:29:be:1c:ff"</span>,
            <span class="hljs-string">"module"</span>: <span class="hljs-string">"e1000"</span>,
            <span class="hljs-string">"mtu"</span>: <span class="hljs-number">1500</span>,
            <span class="hljs-string">"pciid"</span>: <span class="hljs-string">"0000:02:01.0"</span>,
            <span class="hljs-string">"promisc"</span>: <span class="hljs-literal">false</span>,
            <span class="hljs-string">"type"</span>: <span class="hljs-string">"ether"</span>
        },
        <span class="hljs-string">"ansible_env"</span>: {
            <span class="hljs-string">"HOME"</span>: <span class="hljs-string">"/root"</span>,
            <span class="hljs-string">"LANG"</span>: <span class="hljs-string">"en_US.UTF-8"</span>,
            <span class="hljs-string">"LC_ALL"</span>: <span class="hljs-string">"en_US.UTF-8"</span>,
            <span class="hljs-string">"LC_MESSAGES"</span>: <span class="hljs-string">"en_US.UTF-8"</span>,
            <span class="hljs-string">"LESSOPEN"</span>: <span class="hljs-string">"||/usr/bin/lesspipe.sh %s"</span>,
            <span class="hljs-string">"LOGNAME"</span>: <span class="hljs-string">"root"</span>,
            <span class="hljs-string">"MAIL"</span>: <span class="hljs-string">"/var/mail/root"</span>,
            <span class="hljs-string">"PATH"</span>: <span class="hljs-string">"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"</span>,
            <span class="hljs-string">"PWD"</span>: <span class="hljs-string">"/root"</span>,
            <span class="hljs-string">"PYTHONPATH"</span>: <span class="hljs-string">""</span>,
            <span class="hljs-string">"SELINUX_LEVEL_REQUESTED"</span>: <span class="hljs-string">""</span>,
            <span class="hljs-string">"SELINUX_ROLE_REQUESTED"</span>: <span class="hljs-string">""</span>,
            <span class="hljs-string">"SELINUX_USE_CURRENT_RANGE"</span>: <span class="hljs-string">""</span>,
            <span class="hljs-string">"SHELL"</span>: <span class="hljs-string">"/bin/bash"</span>,
            <span class="hljs-string">"SHLVL"</span>: <span class="hljs-string">"2"</span>,
            <span class="hljs-string">"SSH_CLIENT"</span>: <span class="hljs-string">"192.168.32.31 48444 22"</span>,
            <span class="hljs-string">"SSH_CONNECTION"</span>: <span class="hljs-string">"192.168.32.31 48444 192.168.32.32 22"</span>,
            <span class="hljs-string">"SSH_TTY"</span>: <span class="hljs-string">"/dev/pts/0"</span>,
            <span class="hljs-string">"TERM"</span>: <span class="hljs-string">"xterm"</span>,
            <span class="hljs-string">"USER"</span>: <span class="hljs-string">"root"</span>,
            <span class="hljs-string">"XDG_RUNTIME_DIR"</span>: <span class="hljs-string">"/run/user/0"</span>,
            <span class="hljs-string">"XDG_SESSION_ID"</span>: <span class="hljs-string">"150"</span>,
            <span class="hljs-string">"_"</span>: <span class="hljs-string">"/usr/bin/python"</span>
        },
        <span class="hljs-string">"ansible_fips"</span>: <span class="hljs-literal">false</span>,
        <span class="hljs-string">"ansible_flannel.1"</span>: {
            <span class="hljs-string">"active"</span>: <span class="hljs-literal">true</span>,
            <span class="hljs-string">"device"</span>: <span class="hljs-string">"flannel.1"</span>,
            <span class="hljs-string">"ipv4"</span>: {
                <span class="hljs-string">"address"</span>: <span class="hljs-string">"172.16.96.0"</span>,
                <span class="hljs-string">"broadcast"</span>: <span class="hljs-string">"global"</span>,
                <span class="hljs-string">"netmask"</span>: <span class="hljs-string">"255.240.0.0"</span>,
                <span class="hljs-string">"network"</span>: <span class="hljs-string">"172.16.0.0"</span>
            },
            <span class="hljs-string">"ipv6"</span>: [
                {
                    <span class="hljs-string">"address"</span>: <span class="hljs-string">"fe80::20:56ff:fe8a:59b"</span>,
                    <span class="hljs-string">"prefix"</span>: <span class="hljs-string">"64"</span>,
                    <span class="hljs-string">"scope"</span>: <span class="hljs-string">"link"</span>
                }
            ],
            <span class="hljs-string">"macaddress"</span>: <span class="hljs-string">"02:20:56:8a:05:9b"</span>,
            <span class="hljs-string">"mtu"</span>: <span class="hljs-number">1450</span>,
            <span class="hljs-string">"promisc"</span>: <span class="hljs-literal">false</span>,
            <span class="hljs-string">"type"</span>: <span class="hljs-string">"ether"</span>
        },
        <span class="hljs-string">"ansible_form_factor"</span>: <span class="hljs-string">"Other"</span>,
        <span class="hljs-string">"ansible_fqdn"</span>: <span class="hljs-string">"host32"</span>,
        <span class="hljs-string">"ansible_gather_subset"</span>: [
            <span class="hljs-string">"hardware"</span>,
            <span class="hljs-string">"network"</span>,
            <span class="hljs-string">"virtual"</span>
        ],
        <span class="hljs-string">"ansible_hostname"</span>: <span class="hljs-string">"host32"</span>,
        <span class="hljs-string">"ansible_interfaces"</span>: [
            <span class="hljs-string">"docker0"</span>,
            <span class="hljs-string">"lo"</span>,
            <span class="hljs-string">"flannel.1"</span>,
            <span class="hljs-string">"eno16777736"</span>,
            <span class="hljs-string">"virbr0-nic"</span>,
            <span class="hljs-string">"virbr0"</span>
        ],
        <span class="hljs-string">"ansible_kernel"</span>: <span class="hljs-string">"3.10.0-327.el7.x86_64"</span>,
        <span class="hljs-string">"ansible_lo"</span>: {
            <span class="hljs-string">"active"</span>: <span class="hljs-literal">true</span>,
            <span class="hljs-string">"device"</span>: <span class="hljs-string">"lo"</span>,
            <span class="hljs-string">"ipv4"</span>: {
                <span class="hljs-string">"address"</span>: <span class="hljs-string">"127.0.0.1"</span>,
                <span class="hljs-string">"broadcast"</span>: <span class="hljs-string">"host"</span>,
                <span class="hljs-string">"netmask"</span>: <span class="hljs-string">"255.0.0.0"</span>,
                <span class="hljs-string">"network"</span>: <span class="hljs-string">"127.0.0.0"</span>
            },
            <span class="hljs-string">"ipv6"</span>: [
                {
                    <span class="hljs-string">"address"</span>: <span class="hljs-string">"::1"</span>,
                    <span class="hljs-string">"prefix"</span>: <span class="hljs-string">"128"</span>,
                    <span class="hljs-string">"scope"</span>: <span class="hljs-string">"host"</span>
                }
            ],
            <span class="hljs-string">"mtu"</span>: <span class="hljs-number">65536</span>,
            <span class="hljs-string">"promisc"</span>: <span class="hljs-literal">false</span>,
            <span class="hljs-string">"type"</span>: <span class="hljs-string">"loopback"</span>
        },
        <span class="hljs-string">"ansible_lvm"</span>: {
            <span class="hljs-string">"lvs"</span>: {
                <span class="hljs-string">"docker-poolmeta"</span>: {
                    <span class="hljs-string">"size_g"</span>: <span class="hljs-string">"0.01"</span>,
                    <span class="hljs-string">"vg"</span>: <span class="hljs-string">"centos"</span>
                },
                <span class="hljs-string">"root"</span>: {
                    <span class="hljs-string">"size_g"</span>: <span class="hljs-string">"8.47"</span>,
                    <span class="hljs-string">"vg"</span>: <span class="hljs-string">"centos"</span>
                },
                <span class="hljs-string">"swap"</span>: {
                    <span class="hljs-string">"size_g"</span>: <span class="hljs-string">"1.00"</span>,
                    <span class="hljs-string">"vg"</span>: <span class="hljs-string">"centos"</span>
                }
            },
            <span class="hljs-string">"vgs"</span>: {
                <span class="hljs-string">"centos"</span>: {
                    <span class="hljs-string">"free_g"</span>: <span class="hljs-string">"0.03"</span>,
                    <span class="hljs-string">"num_lvs"</span>: <span class="hljs-string">"3"</span>,
                    <span class="hljs-string">"num_pvs"</span>: <span class="hljs-string">"1"</span>,
                    <span class="hljs-string">"size_g"</span>: <span class="hljs-string">"9.51"</span>
                }
            }
        },
        <span class="hljs-string">"ansible_machine"</span>: <span class="hljs-string">"x86_64"</span>,
        <span class="hljs-string">"ansible_machine_id"</span>: <span class="hljs-string">"c7e3ea1209604e87aaad01ff134e9e3b"</span>,
        <span class="hljs-string">"ansible_memfree_mb"</span>: <span class="hljs-number">111</span>,
        <span class="hljs-string">"ansible_memory_mb"</span>: {
            <span class="hljs-string">"nocache"</span>: {
                <span class="hljs-string">"free"</span>: <span class="hljs-number">1103</span>,
                <span class="hljs-string">"used"</span>: <span class="hljs-number">882</span>
            },
            <span class="hljs-string">"real"</span>: {
                <span class="hljs-string">"free"</span>: <span class="hljs-number">111</span>,
                <span class="hljs-string">"total"</span>: <span class="hljs-number">1985</span>,
                <span class="hljs-string">"used"</span>: <span class="hljs-number">1874</span>
            },
            <span class="hljs-string">"swap"</span>: {
                <span class="hljs-string">"cached"</span>: <span class="hljs-number">0</span>,
                <span class="hljs-string">"free"</span>: <span class="hljs-number">1023</span>,
                <span class="hljs-string">"total"</span>: <span class="hljs-number">1023</span>,
                <span class="hljs-string">"used"</span>: <span class="hljs-number">0</span>
            }
        },
        <span class="hljs-string">"ansible_memtotal_mb"</span>: <span class="hljs-number">1985</span>,
        <span class="hljs-string">"ansible_mounts"</span>: [
            {
                <span class="hljs-string">"device"</span>: <span class="hljs-string">"/dev/mapper/centos-root"</span>,
                <span class="hljs-string">"fstype"</span>: <span class="hljs-string">"xfs"</span>,
                <span class="hljs-string">"mount"</span>: <span class="hljs-string">"/"</span>,
                <span class="hljs-string">"options"</span>: <span class="hljs-string">"rw,seclabel,relatime,attr2,inode64,noquota"</span>,
                <span class="hljs-string">"size_available"</span>: <span class="hljs-number">4573728768</span>,
                <span class="hljs-string">"size_total"</span>: <span class="hljs-number">9082765312</span>,
                <span class="hljs-string">"uuid"</span>: <span class="hljs-string">"badd077b-0a3e-40ee-99f7-dab08665cee5"</span>
            },
            {
                <span class="hljs-string">"device"</span>: <span class="hljs-string">"/dev/sda1"</span>,
                <span class="hljs-string">"fstype"</span>: <span class="hljs-string">"xfs"</span>,
                <span class="hljs-string">"mount"</span>: <span class="hljs-string">"/boot"</span>,
                <span class="hljs-string">"options"</span>: <span class="hljs-string">"rw,seclabel,relatime,attr2,inode64,noquota"</span>,
                <span class="hljs-string">"size_available"</span>: <span class="hljs-number">374276096</span>,
                <span class="hljs-string">"size_total"</span>: <span class="hljs-number">520794112</span>,
                <span class="hljs-string">"uuid"</span>: <span class="hljs-string">"15d4410f-795d-4e37-8731-1d104b525b3f"</span>
            }
        ],
        <span class="hljs-string">"ansible_nodename"</span>: <span class="hljs-string">"host32"</span>,
        <span class="hljs-string">"ansible_os_family"</span>: <span class="hljs-string">"RedHat"</span>,
        <span class="hljs-string">"ansible_pkg_mgr"</span>: <span class="hljs-string">"yum"</span>,
        <span class="hljs-string">"ansible_processor"</span>: [
            <span class="hljs-string">"GenuineIntel"</span>,
            <span class="hljs-string">"Intel(R) Core(TM) i7-4710MQ CPU @ 2.50GHz"</span>
        ],
        <span class="hljs-string">"ansible_processor_cores"</span>: <span class="hljs-number">1</span>,
        <span class="hljs-string">"ansible_processor_count"</span>: <span class="hljs-number">1</span>,
        <span class="hljs-string">"ansible_processor_threads_per_core"</span>: <span class="hljs-number">1</span>,
        <span class="hljs-string">"ansible_processor_vcpus"</span>: <span class="hljs-number">1</span>,
        <span class="hljs-string">"ansible_product_name"</span>: <span class="hljs-string">"VMware Virtual Platform"</span>,
        <span class="hljs-string">"ansible_product_serial"</span>: <span class="hljs-string">"VMware-56 4d d6 c3 21 f3 9c bf-0b 6b e1 a7 ee be 1c ff"</span>,
        <span class="hljs-string">"ansible_product_uuid"</span>: <span class="hljs-string">"564DD6C3-21F3-9CBF-0B6B-E1A7EEBE1CFF"</span>,
        <span class="hljs-string">"ansible_product_version"</span>: <span class="hljs-string">"None"</span>,
        <span class="hljs-string">"ansible_python"</span>: {
            <span class="hljs-string">"executable"</span>: <span class="hljs-string">"/usr/bin/python"</span>,
            <span class="hljs-string">"has_sslcontext"</span>: <span class="hljs-literal">true</span>,
            <span class="hljs-string">"type"</span>: <span class="hljs-string">"CPython"</span>,
            <span class="hljs-string">"version"</span>: {
                <span class="hljs-string">"major"</span>: <span class="hljs-number">2</span>,
                <span class="hljs-string">"micro"</span>: <span class="hljs-number">5</span>,
                <span class="hljs-string">"minor"</span>: <span class="hljs-number">7</span>,
                <span class="hljs-string">"releaselevel"</span>: <span class="hljs-string">"final"</span>,
                <span class="hljs-string">"serial"</span>: <span class="hljs-number">0</span>
            },
            <span class="hljs-string">"version_info"</span>: [
                <span class="hljs-number">2</span>,
                <span class="hljs-number">7</span>,
                <span class="hljs-number">5</span>,
                <span class="hljs-string">"final"</span>,
                <span class="hljs-number">0</span>
            ]
        },
        <span class="hljs-string">"ansible_python_version"</span>: <span class="hljs-string">"2.7.5"</span>,
        <span class="hljs-string">"ansible_selinux"</span>: {
            <span class="hljs-string">"config_mode"</span>: <span class="hljs-string">"permissive"</span>,
            <span class="hljs-string">"mode"</span>: <span class="hljs-string">"permissive"</span>,
            <span class="hljs-string">"policyvers"</span>: <span class="hljs-number">28</span>,
            <span class="hljs-string">"status"</span>: <span class="hljs-string">"enabled"</span>,
            <span class="hljs-string">"type"</span>: <span class="hljs-string">"targeted"</span>
        },
        <span class="hljs-string">"ansible_service_mgr"</span>: <span class="hljs-string">"systemd"</span>,
        <span class="hljs-string">"ansible_ssh_host_key_ecdsa_public"</span>: <span class="hljs-string">"AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBGSR3DThz2RLoPAZKtY6jIFJun355SHQlrY3ATc4nEmERiscRviOWZaLRL1d6NwGZxFAIrpHqQ8tYr2VGZIcYPk="</span>,
        <span class="hljs-string">"ansible_ssh_host_key_ed25519_public"</span>: <span class="hljs-string">"AAAAC3NzaC1lZDI1NTE5AAAAIBkXu5pAOmK96YZJmws0QruTPUtf8CAaUZ0d5iPp6C1Q"</span>,
        <span class="hljs-string">"ansible_ssh_host_key_rsa_public"</span>: <span class="hljs-string">"AAAAB3NzaC1yc2EAAAADAQABAAABAQDjiG6UaDQakAGpi0RMarJwdzv6XBayhLFL0+uwzqrS0LdC4PMyoqU9rQQrpugXht0JKCbRs/pi4/bNt1x3YrWjkpIGUE88jgq9JSnzPkcWh1ffpCFih7Tr4PZkVp2NeeyuJXgvxiXVw34ZpZ8Kcl0wOAyyYGJNbIS38zAl3SmFTbrEEZCQhXxCA/m5GUYkjnoJxXezeE3uAdQ5vVU/k20tfPEpEeYR9RPaCgEUteHh9fKIHD8f4kXaiD3vT2tG9JHU35V3vI/EkJLtKBsUAXDgUaydOYrmn9xJb92kWFMTug5aBllwuf5O1Ws98xOzPANp4EWUrbAzLf/MFhzxBIwH"</span>,
        <span class="hljs-string">"ansible_swapfree_mb"</span>: <span class="hljs-number">1023</span>,
        <span class="hljs-string">"ansible_swaptotal_mb"</span>: <span class="hljs-number">1023</span>,
        <span class="hljs-string">"ansible_system"</span>: <span class="hljs-string">"Linux"</span>,
        <span class="hljs-string">"ansible_system_capabilities"</span>: [
            <span class="hljs-string">"cap_chown"</span>,
            <span class="hljs-string">"cap_dac_override"</span>,
            <span class="hljs-string">"cap_dac_read_search"</span>,
            <span class="hljs-string">"cap_fowner"</span>,
            <span class="hljs-string">"cap_fsetid"</span>,
            <span class="hljs-string">"cap_kill"</span>,
            <span class="hljs-string">"cap_setgid"</span>,
            <span class="hljs-string">"cap_setuid"</span>,
            <span class="hljs-string">"cap_setpcap"</span>,
            <span class="hljs-string">"cap_linux_immutable"</span>,
            <span class="hljs-string">"cap_net_bind_service"</span>,
            <span class="hljs-string">"cap_net_broadcast"</span>,
            <span class="hljs-string">"cap_net_admin"</span>,
            <span class="hljs-string">"cap_net_raw"</span>,
            <span class="hljs-string">"cap_ipc_lock"</span>,
            <span class="hljs-string">"cap_ipc_owner"</span>,
            <span class="hljs-string">"cap_sys_module"</span>,
            <span class="hljs-string">"cap_sys_rawio"</span>,
            <span class="hljs-string">"cap_sys_chroot"</span>,
            <span class="hljs-string">"cap_sys_ptrace"</span>,
            <span class="hljs-string">"cap_sys_pacct"</span>,
            <span class="hljs-string">"cap_sys_admin"</span>,
            <span class="hljs-string">"cap_sys_boot"</span>,
            <span class="hljs-string">"cap_sys_nice"</span>,
            <span class="hljs-string">"cap_sys_resource"</span>,
            <span class="hljs-string">"cap_sys_time"</span>,
            <span class="hljs-string">"cap_sys_tty_config"</span>,
            <span class="hljs-string">"cap_mknod"</span>,
            <span class="hljs-string">"cap_lease"</span>,
            <span class="hljs-string">"cap_audit_write"</span>,
            <span class="hljs-string">"cap_audit_control"</span>,
            <span class="hljs-string">"cap_setfcap"</span>,
            <span class="hljs-string">"cap_mac_override"</span>,
            <span class="hljs-string">"cap_mac_admin"</span>,
            <span class="hljs-string">"cap_syslog"</span>,
            <span class="hljs-string">"35"</span>,
            <span class="hljs-string">"36+ep"</span>
        ],
        <span class="hljs-string">"ansible_system_capabilities_enforced"</span>: <span class="hljs-string">"True"</span>,
        <span class="hljs-string">"ansible_system_vendor"</span>: <span class="hljs-string">"VMware, Inc."</span>,
        <span class="hljs-string">"ansible_uptime_seconds"</span>: <span class="hljs-number">56290</span>,
        <span class="hljs-string">"ansible_user_dir"</span>: <span class="hljs-string">"/root"</span>,
        <span class="hljs-string">"ansible_user_gecos"</span>: <span class="hljs-string">"root"</span>,
        <span class="hljs-string">"ansible_user_gid"</span>: <span class="hljs-number">0</span>,
        <span class="hljs-string">"ansible_user_id"</span>: <span class="hljs-string">"root"</span>,
        <span class="hljs-string">"ansible_user_shell"</span>: <span class="hljs-string">"/bin/bash"</span>,
        <span class="hljs-string">"ansible_user_uid"</span>: <span class="hljs-number">0</span>,
        <span class="hljs-string">"ansible_userspace_architecture"</span>: <span class="hljs-string">"x86_64"</span>,
        <span class="hljs-string">"ansible_userspace_bits"</span>: <span class="hljs-string">"64"</span>,
        <span class="hljs-string">"ansible_virbr0"</span>: {
            <span class="hljs-string">"active"</span>: <span class="hljs-literal">false</span>,
            <span class="hljs-string">"device"</span>: <span class="hljs-string">"virbr0"</span>,
            <span class="hljs-string">"id"</span>: <span class="hljs-string">"8000.000000000000"</span>,
            <span class="hljs-string">"interfaces"</span>: [],
            <span class="hljs-string">"ipv4"</span>: {
                <span class="hljs-string">"address"</span>: <span class="hljs-string">"192.168.122.1"</span>,
                <span class="hljs-string">"broadcast"</span>: <span class="hljs-string">"192.168.122.255"</span>,
                <span class="hljs-string">"netmask"</span>: <span class="hljs-string">"255.255.255.0"</span>,
                <span class="hljs-string">"network"</span>: <span class="hljs-string">"192.168.122.0"</span>
            },
            <span class="hljs-string">"mtu"</span>: <span class="hljs-number">1500</span>,
            <span class="hljs-string">"promisc"</span>: <span class="hljs-literal">false</span>,
            <span class="hljs-string">"stp"</span>: <span class="hljs-literal">true</span>,
            <span class="hljs-string">"type"</span>: <span class="hljs-string">"bridge"</span>
        },
        <span class="hljs-string">"ansible_virbr0_nic"</span>: {
            <span class="hljs-string">"active"</span>: <span class="hljs-literal">false</span>,
            <span class="hljs-string">"device"</span>: <span class="hljs-string">"virbr0-nic"</span>,
            <span class="hljs-string">"macaddress"</span>: <span class="hljs-string">"52:54:00:6b:d9:6c"</span>,
            <span class="hljs-string">"mtu"</span>: <span class="hljs-number">1500</span>,
            <span class="hljs-string">"promisc"</span>: <span class="hljs-literal">false</span>,
            <span class="hljs-string">"type"</span>: <span class="hljs-string">"ether"</span>
        },
        <span class="hljs-string">"ansible_virtualization_role"</span>: <span class="hljs-string">"guest"</span>,
        <span class="hljs-string">"ansible_virtualization_type"</span>: <span class="hljs-string">"VMware"</span>,
        <span class="hljs-string">"module_setup"</span>: <span class="hljs-literal">true</span>
    },
    <span class="hljs-string">"changed"</span>: <span class="hljs-literal">false</span>
}
[root<span class="hljs-property">@host31</span> ~]<span class="hljs-comment">#</span></code>

setup 常用 Option:filter
比如收集对象机器的环境变量信息

<code class=" hljs coffeescript">[root<span class="hljs-property">@host31</span> ~]<span class="hljs-comment"># ansible host32 -m setup -a "filter=ansible_env"</span>
host32 | SUCCESS<span class="hljs-function"> =></span> {
    <span class="hljs-string">"ansible_facts"</span>: {
        <span class="hljs-string">"ansible_env"</span>: {
            <span class="hljs-string">"HOME"</span>: <span class="hljs-string">"/root"</span>,
            <span class="hljs-string">"LANG"</span>: <span class="hljs-string">"en_US.UTF-8"</span>,
            <span class="hljs-string">"LC_ALL"</span>: <span class="hljs-string">"en_US.UTF-8"</span>,
            <span class="hljs-string">"LC_MESSAGES"</span>: <span class="hljs-string">"en_US.UTF-8"</span>,
            <span class="hljs-string">"LESSOPEN"</span>: <span class="hljs-string">"||/usr/bin/lesspipe.sh %s"</span>,
            <span class="hljs-string">"LOGNAME"</span>: <span class="hljs-string">"root"</span>,
            <span class="hljs-string">"MAIL"</span>: <span class="hljs-string">"/var/mail/root"</span>,
            <span class="hljs-string">"PATH"</span>: <span class="hljs-string">"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"</span>,
            <span class="hljs-string">"PWD"</span>: <span class="hljs-string">"/root"</span>,
            <span class="hljs-string">"PYTHONPATH"</span>: <span class="hljs-string">""</span>,
            <span class="hljs-string">"SELINUX_LEVEL_REQUESTED"</span>: <span class="hljs-string">""</span>,
            <span class="hljs-string">"SELINUX_ROLE_REQUESTED"</span>: <span class="hljs-string">""</span>,
            <span class="hljs-string">"SELINUX_USE_CURRENT_RANGE"</span>: <span class="hljs-string">""</span>,
            <span class="hljs-string">"SHELL"</span>: <span class="hljs-string">"/bin/bash"</span>,
            <span class="hljs-string">"SHLVL"</span>: <span class="hljs-string">"2"</span>,
            <span class="hljs-string">"SSH_CLIENT"</span>: <span class="hljs-string">"192.168.32.31 48482 22"</span>,
            <span class="hljs-string">"SSH_CONNECTION"</span>: <span class="hljs-string">"192.168.32.31 48482 192.168.32.32 22"</span>,
            <span class="hljs-string">"SSH_TTY"</span>: <span class="hljs-string">"/dev/pts/0"</span>,
            <span class="hljs-string">"TERM"</span>: <span class="hljs-string">"xterm"</span>,
            <span class="hljs-string">"USER"</span>: <span class="hljs-string">"root"</span>,
            <span class="hljs-string">"XDG_RUNTIME_DIR"</span>: <span class="hljs-string">"/run/user/0"</span>,
            <span class="hljs-string">"XDG_SESSION_ID"</span>: <span class="hljs-string">"151"</span>,
            <span class="hljs-string">"_"</span>: <span class="hljs-string">"/usr/bin/python"</span>
        }
    },
    <span class="hljs-string">"changed"</span>: <span class="hljs-literal">false</span>
}
[root<span class="hljs-property">@host31</span> ~]<span class="hljs-comment">#</span></code>

本文转载自 实例学习 ansible 系列(7)常用模块之 ping/setup


蜷缩的蜗牛 , 版权所有丨如未注明 , 均为原创丨 转载请注明实例学习 ansible 系列(7)常用模块之 ping/setup
喜欢 (0)
[]
分享 (0)