xiaodouya33 发表于 2018-7-30 07:22:30

ansible搭建高效运维平台,附批量免密码登陆脚本

# ansible 2_cluster -m setup  
192.168.2.93 | SUCCESS => {
  
    "ansible_facts": {
  
      "ansible_all_ipv4_addresses": [
  
            "192.168.2.93"
  
      ],
  
      "ansible_all_ipv6_addresses": [
  
            "fe80::250:56ff:fe8e:79be"
  
      ],
  
      "ansible_architecture": "x86_64",
  
      "ansible_bios_date": "08/16/2013",
  
      "ansible_bios_version": "6.00",
  
      "ansible_cmdline": {
  
            "KEYBOARDTYPE": "pc",
  
            "KEYTABLE": "us",
  
            "LANG": "en_US.UTF-8",
  
            "SYSFONT": "latarcyrheb-sun16",
  
            "crashkernel": "129M@0M",
  
            "quiet": true,
  
            "rd_LVM_LV": "VolGroup/lv_root",
  
            "rd_NO_DM": true,
  
            "rd_NO_LUKS": true,
  
            "rd_NO_MD": true,
  
            "rhgb": true,
  
            "ro": true,
  
            "root": "/dev/mapper/VolGroup-lv_root"
  
      },
  
      "ansible_date_time": {
  
            "date": "2016-11-02",
  
            "day": "02",
  
            "epoch": "1478071697",
  
            "hour": "15",
  
            "iso8601": "2016-11-02T07:28:17Z",
  
            "iso8601_basic": "20161102T152817376320",
  
            "iso8601_basic_short": "20161102T152817",
  
            "iso8601_micro": "2016-11-02T07:28:17.376402Z",
  
            "minute": "28",
  
            "month": "11",
  
            "second": "17",
  
            "time": "15:28:17",
  
            "tz": "CST",
  
            "tz_offset": "+0800",
  
            "weekday": "Wednesday",
  
            "weekday_number": "3",
  
            "weeknumber": "44",
  
            "year": "2016"
  
      },
  
      "ansible_default_ipv4": {
  
            "address": "192.168.2.93",
  
            "alias": "eth2",
  
            "broadcast": "192.168.2.255",
  
            "gateway": "192.168.2.1",
  
            "interface": "eth2",
  
            "macaddress": "00:50:56:8e:79:be",
  
            "mtu": 1500,
  
            "netmask": "255.255.255.0",
  
            "network": "192.168.2.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": "Virtual disk",
  
                "partitions": {
  
                  "sda1": {
  
                        "sectors": "1024000",
  
                        "sectorsize": 512,
  
                        "size": "500.00 MB",
  
                        "start": "2048"
  
                  },
  
                  "sda2": {
  
                        "sectors": "628119552",
  
                        "sectorsize": 512,
  
                        "size": "299.51 GB",
  
                        "start": "1026048"
  
                  }
  
                },
  
                "removable": "0",
  
                "rotational": "1",
  
                "sas_address": null,
  
                "sas_device_handle": null,
  
                "scheduler_mode": "cfq",
  
                "sectors": "629145600",
  
                "sectorsize": "512",
  
                "size": "300.00 GB",
  
                "support_discard": "0",
  
                "vendor": "VMware"
  
            },
  
            "sr0": {
  
                "holders": [],
  
                "host": "IDE interface: Intel Corporation 82371AB/EB/MB PIIX4 IDE (rev 01)",
  
                "model": "VMware IDE CDR10",
  
                "partitions": {},
  
                "removable": "1",
  
                "rotational": "1",
  
                "sas_address": null,
  
                "sas_device_handle": null,
  
                "scheduler_mode": "cfq",
  
                "sectors": "2097151",
  
                "sectorsize": "512",
  
                "size": "1024.00 MB",
  
                "support_discard": "0",
  
                "vendor": "NECVMWar"
  
            }
  
      },
  
      "ansible_distribution": "CentOS",
  
      "ansible_distribution_major_version": "6",
  
      "ansible_distribution_release": "Final",
  
      "ansible_distribution_version": "6.7",
  
      "ansible_dns": {
  
            "nameservers": [
  
                "192.168.2.20",
  
                "8.8.8.8"
  
            ]
  
      },
  
      "ansible_domain": "",
  
      "ansible_env": {
  
            "G_BROKEN_FILENAMES": "1",
  
            "HOME": "/root",
  
            "LANG": "en_US.UTF-8",
  
            "LC_ALL": "en_US.UTF-8",
  
            "LC_MESSAGES": "en_US.UTF-8",
  
            "LESSOPEN": "||/usr/bin/lesspipe.sh %s",
  
            "LOGNAME": "root",
  
            "MAIL": "/var/mail/root",
  
            "PATH": "/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin",
  
            "PWD": "/root",
  
            "PYTHONPATH": "",
  
            "SHELL": "/bin/bash",
  
            "SHLVL": "2",
  
            "SSH_CLIENT": "192.168.2.223 55940 22",
  
            "SSH_CONNECTION": "192.168.2.223 55940 192.168.2.93 22",
  
            "SSH_TTY": "/dev/pts/0",
  
            "TERM": "xterm",
  
            "USER": "root",
  
            "_": "/usr/bin/python"
  
      },
  
      "ansible_eth2": {
  
            "active": true,
  
            "device": "eth2",
  
            "ipv4": {
  
                "address": "192.168.2.93",
  
                "broadcast": "192.168.2.255",
  
                "netmask": "255.255.255.0",
  
                "network": "192.168.2.0"
  
            },
  
            "ipv6": [
  
                {
  
                  "address": "fe80::250:56ff:fe8e:79be",
  
                  "prefix": "64",
  
                  "scope": "link"
  
                }
  
            ],
  
            "macaddress": "00:50:56:8e:79:be",
  
            "module": "vmxnet3",
  
            "mtu": 1500,
  
            "pciid": "0000:03:00.0",
  
            "promisc": false,
  
            "type": "ether"
  
      },
  
      "ansible_fips": false,
  
      "ansible_form_factor": "Other",
  
      "ansible_fqdn": "mycatcluster26",
  
      "ansible_gather_subset": [
  
            "hardware",
  
            "network",
  
            "virtual"
  
      ],
  
      "ansible_hostname": "mycatcluster26",
  
      "ansible_interfaces": [
  
            "lo",
  
            "eth2"
  
      ],
  
      "ansible_kernel": "2.6.32-573.el6.x86_64",
  
      "ansible_lo": {
  
            "active": true,
  
            "device": "lo",
  
            "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,
  
            "type": "loopback"
  
      },
  
      "ansible_lvm": {
  
            "lvs": {
  
                "lv_root": {
  
                  "size_g": "291.66",
  
                  "vg": "VolGroup"
  
                },
  
                "lv_swap": {
  
                  "size_g": "7.85",
  
                  "vg": "VolGroup"
  
                }
  
            },
  
            "vgs": {
  
                "VolGroup": {
  
                  "free_g": "0",
  
                  "num_lvs": "2",
  
                  "num_pvs": "1",
  
                  "size_g": "299.51"
  
                }
  
            }
  
      },
  
      "ansible_machine": "x86_64",
  
      "ansible_memfree_mb": 6893,
  
      "ansible_memory_mb": {
  
            "nocache": {
  
                "free": 7157,
  
                "used": 714
  
            },
  
            "real": {
  
                "free": 6893,
  
                "total": 7871,
  
                "used": 978
  
            },
  
            "swap": {
  
                "cached": 0,
  
                "free": 8039,
  
                "total": 8039,
  
                "used": 0
  
            }
  
      },
  
      "ansible_memtotal_mb": 7871,
  
      "ansible_mounts": [
  
            {
  
                "device": "/dev/mapper/VolGroup-lv_root",
  
                "fstype": "ext4",
  
                "mount": "/",
  
                "options": "rw",
  
                "size_available": 270789632000,
  
                "size_total": 308114112512,
  
                "uuid": "8ded72c8-a452-4038-9edc-4d90233f3e98"
  
            },
  
            {
  
                "device": "/dev/sda1",
  
                "fstype": "ext4",
  
                "mount": "/boot",
  
                "options": "rw",
  
                "size_available": 442224640,
  
                "size_total": 499355648,
  
                "uuid": "05b2397a-c913-4dcf-aee2-a1cf6a0d8a99"
  
            }
  
      ],
  
      "ansible_nodename": "mycatcluster26",
  
      "ansible_os_family": "RedHat",
  
      "ansible_pkg_mgr": "yum",
  
      "ansible_processor": [
  
            "GenuineIntel",
  
            "Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz",
  
            "GenuineIntel",
  
            "Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz",
  
            "GenuineIntel",
  
            "Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz",
  
            "GenuineIntel",
  
            "Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz",
  
            "GenuineIntel",
  
            "Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz",
  
            "GenuineIntel",
  
            "Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz",
  
            "GenuineIntel",
  
            "Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz",
  
            "GenuineIntel",
  
            "Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz"
  
      ],
  
      "ansible_processor_cores": 2,
  
      "ansible_processor_count": 4,
  
      "ansible_processor_threads_per_core": 1,
  
      "ansible_processor_vcpus": 8,
  
      "ansible_product_name": "VMware Virtual Platform",
  
      "ansible_product_serial": "VMware-42 0e 75 05 61 04 d0 4b-17 00 c9 58 01 61 23 b1",
  
      "ansible_product_uuid": "420E7505-6104-D04B-1700-C958016123B1",
  
      "ansible_product_version": "None",
  
      "ansible_python": {
  
            "executable": "/usr/bin/python",
  
            "has_sslcontext": false,
  
            "type": "CPython",
  
            "version": {
  
                "major": 2,
  
                "micro": 6,
  
                "minor": 6,
  
                "releaselevel": "final",
  
                "serial": 0
  
            },
  
            "version_info": [
  
                2,
  
                6,
  
                6,
  
                "final",
  
                0
  
            ]
  
      },
  
      "ansible_python_version": "2.6.6",
  
      "ansible_selinux": false,
  
      "ansible_service_mgr": "upstart",
  
      "ansible_ssh_host_key_dsa_public": "AAAAB3NzaC1kc3MAAACBAPAkBHfLDqSJbKdBGA0OmDHl3OGEK9Js+5TUVLuX2kkPOBZJ2gRKzTpRYnu+PieWNv6/r0zaZTW7oR7PFKk/j/MYLjieMcX4ozrr4A8RjI8V/NaOG/WKM2Bqe4WweK2wRiCvqlO2kq4P3AcfCHuaRV4RMKg9QJDmVgWABA7vTftBAAAAFQDZ1AhlZFwBR7rhRA0C9/GZhZr3zwAAAIBjnRmc0UbTJuuIH3ckANIOer4OJJhQYf4bEg1tDfvuqZGC9I+1+TIKaN31ORvNXFidoeNiESVtmov70YhZuCqOSwtUcNC5nkmZVECZW5jyvy5nQF6Ly/fXBVZ9tW6uOzk75nDttVidYswLZeslgdVrr92d3JwHmGC8Rqxqy1nI2gAAAIAiHYnJJyuqjypq2qArClD2umSlfYuJfmwNEAqq4Bo9t9e2cDvXosQdqmZG15DdaTwgUrwOIiVZWYvq0eJlqg34Z1aQFp5QrQspaIV4XNRSS8NkMgcNEYo9YlCFh9SITUFKFuPrCKwAUHrNTiRpOzbz23/FGWchQxR8JLraMKZoGw==",
  
      "ansible_ssh_host_key_rsa_public": "AAAAB3NzaC1yc2EAAAABIwAAAQEAqu7dCDG6tP3kEc/K8f/phvgPpRMJedPbrRDBdw37iusm0/5GM/AqPGzkZ5tcFCjRwnvmVAlD9IZtOEAUk/JjzRdyPQnlhMq9ZkpuKa7o2OmLzLlpilwds8FH1hY3DVh043uosVY/DZ+RWp7LVY/keRaN3PSx5e0wBXzAmhh3AthL1UR4xTSALQ3uAULVFJytgKvphPfitwbFB7pmV9txcrLOqdlFrUkGdS/wD3WJF6XBjIXOOWHi3PIQuzdMbnTd0LlBlEvw7OqqoXDd66KHxxIVdpbIjSRtaS7itSmxYhxToZSRklkdZi6gUarH8qMRcyJn4uBPCPV6hnSryHh1QQ==",
  
      "ansible_swapfree_mb": 8039,
  
      "ansible_swaptotal_mb": 8039,
  
      "ansible_system": "Linux",
  
      "ansible_system_capabilities": [],
  
      "ansible_system_capabilities_enforced": "False",
  
      "ansible_system_vendor": "VMware, Inc.",
  
      "ansible_uptime_seconds": 4901602,
  
      "ansible_user_dir": "/root",
  
      "ansible_user_gecos": "root",
  
      "ansible_user_gid": 0,
  
      "ansible_user_id": "root",
  
      "ansible_user_shell": "/bin/bash",
  
      "ansible_user_uid": 0,
  
      "ansible_userspace_architecture": "x86_64",
  
      "ansible_userspace_bits": "64",
  
      "ansible_virtualization_role": "guest",
  
      "ansible_virtualization_type": "VMware",
  
      "module_setup": true
  
    },
  
    "changed": false
  
}
页: [1]
查看完整版本: ansible搭建高效运维平台,附批量免密码登陆脚本