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

本文详细介绍了Ansible中的ping模块和setup模块。ping模块用于验证与目标主机的连接,通常返回pong。而setup模块则用于收集目标主机的基础配置信息。在不指定选项时,setup模块会返回所有相关事实。通过filter选项,可以定制收集特定如环境变量等信息。
摘要由CSDN通过智能技术生成

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

ping使用实例

[root@host31 ansible]# ansible host32 -m ping
host32 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}
[root@host31 ansible]#

setup使用实例

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

[root@host31 ~]# ansible host32 -m setup
host32 | SUCCESS => {
    "ansible_facts": {
        "ansible_all_ipv4_addresses": [
            "192.168.122.1",
            "172.16.96.1",
            "172.16.96.0",
            "192.168.32.32"
        ],
        "ansible_all_ipv6_addresses": [
            "fe80::20:56ff:fe8a:59b",
            "fe80::20c:29ff:febe:1cff"
        ],
        "ansible_architecture": "x86_64",
        "ansible_bios_date": "07/02/2015",
        "ansible_bios_version": "6.00",
        "ansible_cmdline": {
            "BOOT_IMAGE": "/vmlinuz-3.10.0-327.el7.x86_64",
            "LANG": "en_US.UTF-8",
            "quiet": true,
            "rd.lvm.lv": "centos/swap",
            "rhgb": true,
            "ro": true,
            "root": "/dev/mapper/centos-root"
        },
        "ansible_date_time": {
            "date": "2016-07-30",
            "day": "30",
            "epoch": "1469884080",
            "hour": "09",
            "iso8601": "2016-07-30T13:08:00Z",
            "iso8601_basic": "20160730T090800352254",
            "iso8601_basic_short": "20160730T090800",
            "iso8601_micro": "2016-07-30T13:08:00.352338Z",
            "minute": "08",
            "month": "07",
            "second": "00",
            "time": "09:08:00",
            "tz": "EDT",
            "tz_offset": "-0400",
            "weekday": "Saturday",
            "weekday_number": "6",
            "weeknumber": "30",
            "year": "2016"
        },
        "ansible_default_ipv4": {
            "address": "192.168.32.32",
            "alias": "eno16777736",
            "broadcast": "192.168.32.255",
            "gateway": "192.168.32.2",
            "interface": "eno16777736",
            "macaddress": "00:0c:29:be:1c:ff",
            "mtu": 1500,
            "netmask": "255.255.255.0",
            "network": "192.168.32.0",
            "type": "ether"
        },
        "ansible_default_ipv6": {},
        "ansible_devices": {
            "sda": {
                "holders": [],
                "host": "SCSI storage controller: LSI Logic / Symbios Logic 53c1030 PCI-X Fusion-MPT Dual Ultra320 SCSI (rev 01)",
                "model": "VMware Virtual S",
                "partitions": {
                    "sda1": {
                        "sectors": "1024000",
                        "sectorsize": 512,
                        "size": "500.00 MB",
                        "start": "2048"
                    },
                    "sda2": {
                        "sectors": "19945472",
                        "sectorsize": 512,
                        "size": "9.51 GB",
                        "start": "1026048"
                    }
                },
                "removable": "0",
                "rotational": "1",
                "sas_address": null,
                "sas_device_handle": null,
                "scheduler_mode
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值