LoginSignup
20
17

More than 5 years have passed since last update.

[Ansible] ansible_*変数の値を確認するには

Last updated at Posted at 2013-08-09

FAQのHow do I see a list of all of the ansible_ variables?に書いてありました。

$ ansible -m setup _YOUR_HOST_NAME_HERE_

出力例はこんな感じです。

_YOUR_HOST_NAME_HERE_ | success >> {
    "ansible_facts": {
        "ansible_all_ipv4_addresses": [
            "10.0.2.15", 
            "192.168.33.12"
        ], 
        "ansible_all_ipv6_addresses": [
            "fe80::a00:27ff:fec5:1e96", 
            "fe80::a00:27ff:feb6:3bf5"
        ], 
        "ansible_architecture": "x86_64", 
        "ansible_bios_date": "12/01/2006", 
        "ansible_bios_version": "VirtualBox", 
        "ansible_cmdline": {
            "KEYBOARDTYPE": "pc", 
            "KEYTABLE": "us", 
            "LANG": "en_US.UTF-8", 
            "SYSFONT": "latarcyrheb-sun16", 
            "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": "2013-08-09", 
            "day": "09", 
            "epoch": "1376034531", 
            "hour": "16", 
            "iso8601": "2013-08-09T07:48:51Z", 
            "iso8601_micro": "2013-08-09T07:48:51.221906Z", 
            "minute": "48", 
            "month": "08", 
            "second": "51", 
            "time": "16:48:51", 
            "tz": "JST", 
            "year": "2013"
        }, 
        "ansible_default_ipv4": {
            "address": "10.0.2.15", 
            "alias": "eth0", 
            "gateway": "10.0.2.2", 
            "interface": "eth0", 
            "macaddress": "08:00:27:c5:1e:96", 
            "mtu": 1500, 
            "netmask": "255.255.255.0", 
            "network": "10.0.2.0", 
            "type": "ether"
        }, 
        "ansible_default_ipv6": {}, 
        "ansible_devices": {
            "sda": {
                "holders": [], 
                "host": "", 
                "model": "VBOX HARDDISK", 
                "partitions": {
                    "sda1": {
                        "sectors": "1024000", 
                        "sectorsize": 512, 
                        "size": "500.00 MB", 
                        "start": "2048"
                    }, 
                    "sda2": {
                        "sectors": "81958912", 
                        "sectorsize": 512, 
                        "size": "39.08 GB", 
                        "start": "1026048"
                    }
                }, 
                "removable": "0", 
                "rotational": "1", 
                "scheduler_mode": "cfq", 
                "sectors": "82984960", 
                "sectorsize": "512", 
                "size": "39.57 GB", 
                "support_discard": "0", 
                "vendor": "ATA"
            }, 
            "sr0": {
                "holders": [], 
                "host": "", 
                "model": "CD-ROM", 
                "partitions": {}, 
                "removable": "1", 
                "rotational": "1", 
                "scheduler_mode": "cfq", 
                "sectors": "2097151", 
                "sectorsize": "512", 
                "size": "1024.00 MB", 
                "support_discard": "0", 
                "vendor": "VBOX"
            }
        }, 
        "ansible_distribution": "CentOS", 
        "ansible_distribution_release": "Final", 
        "ansible_distribution_version": "6.4", 
        "ansible_domain": "localdomain", 
        "ansible_eth0": {
            "active": true, 
            "device": "eth0", 
            "ipv4": {
                "address": "10.0.2.15", 
                "netmask": "255.255.255.0", 
                "network": "10.0.2.0"
            }, 
            "ipv6": [
                {
                    "address": "fe80::a00:27ff:fec5:1e96", 
                    "prefix": "64", 
                    "scope": "link"
                }
            ], 
            "macaddress": "08:00:27:c5:1e:96", 
            "module": "e1000", 
            "mtu": 1500, 
            "type": "ether"
        }, 
        "ansible_eth1": {
            "active": true, 
            "device": "eth1", 
            "ipv4": {
                "address": "192.168.33.12", 
                "netmask": "255.255.255.0", 
                "network": "192.168.33.0"
            }, 
            "ipv6": [
                {
                    "address": "fe80::a00:27ff:feb6:3bf5", 
                    "prefix": "64", 
                    "scope": "link"
                }
            ], 
            "macaddress": "08:00:27:b6:3b:f5", 
            "module": "e1000", 
            "mtu": 1500, 
            "type": "ether"
        }, 
        "ansible_form_factor": "Other", 
        "ansible_fqdn": "localhost.localdomain", 
        "ansible_hostname": "localhost", 
        "ansible_interfaces": [
            "lo", 
            "eth1", 
            "eth0"
        ], 
        "ansible_kernel": "2.6.32-358.el6.x86_64", 
        "ansible_lo": {
            "active": true, 
            "device": "lo", 
            "ipv4": {
                "address": "127.0.0.1", 
                "netmask": "255.0.0.0", 
                "network": "127.0.0.0"
            }, 
            "ipv6": [
                {
                    "address": "::1", 
                    "prefix": "128", 
                    "scope": "host"
                }
            ], 
            "mtu": 16436, 
            "type": "loopback"
        }, 
        "ansible_machine": "x86_64", 
        "ansible_memfree_mb": 28, 
        "ansible_memtotal_mb": 490, 
        "ansible_mounts": [
            {
                "device": "/dev/mapper/VolGroup-lv_root", 
                "fstype": "ext4", 
                "mount": "/", 
                "options": "rw", 
                "size_available": 36703879168, 
                "size_total": 40277303296
            }, 
            {
                "device": "/dev/sda1", 
                "fstype": "ext4", 
                "mount": "/boot", 
                "options": "rw", 
                "size_available": 448808960, 
                "size_total": 507744256
            }, 
            {
                "device": "/vagrant", 
                "fstype": "vboxsf", 
                "mount": "/vagrant", 
                "options": "uid=501,gid=501,rw", 
                "size_available": 146711470080, 
                "size_total": 250140434432
            }
        ], 
        "ansible_os_family": "RedHat", 
        "ansible_pkg_mgr": "yum", 
        "ansible_processor": [
            "Intel(R) Core(TM) i7-4650U CPU @ 1.70GHz"
        ], 
        "ansible_processor_cores": "NA", 
        "ansible_processor_count": 1, 
        "ansible_product_name": "VirtualBox", 
        "ansible_product_serial": "NA", 
        "ansible_product_uuid": "NA", 
        "ansible_product_version": "1.2", 
        "ansible_python_version": "2.6.6", 
        "ansible_selinux": false, 
        "ansible_ssh_host_key_dsa_public": "AAAAB3NzaC1kc3MAAACBAMQJqkf5Apjk/CkCT63ToiBTSE7sCabTSjMBmuzs8V/hT+kKEnJHKUOOCpAxc1lNR0tn25bSxEwIm94KnR3dsZNpFr7NF7CiPOPGbiDnOt/Ue+9AsuzWjQobPxIk3x7qxLtlggAwRT/3PcEEtkoKoFGMEz8hWuScA7vBidlYr/LtAAAAFQDRGkYGTNVPtlXPoq9fsu/M0umjqQAAAIBVP6hgotLT3/jvGsaXnKI/AXEk5ZZ4z8Xr6v+lwXLqcLk2z7Y7czTQc4rSaSSbqzf9L3eyJGi5veF92ot1wOPgzwsGbYXlC92uG2wt06ZAiTK1yIx/bL0Tdp/QV0i6fVwiXK43X+x5y556Dxejq3pczZFbDL+ppaFMRZQOsdIRUgAAAIEAiib8fzGEryAGx4XvVEYeMOXoW7LZEB1jXFxR19/MwfsnSwBgHL21TJWtRBrNlY0HbRVeRKzuDhzwB2mLIck9098qmHJa5O4aoOX1FvuCKgnZyqsjNNUvs3M/wq+QQXcTNAHF7aOE9fJoAsxuU+OJKaRm9tbrXYMlwXSeDwdEzVk=", 
        "ansible_ssh_host_key_rsa_public": "AAAAB3NzaC1yc2EAAAABIwAAAQEAzMGk2XHnrtE3kUgbbs+Ld7uNQIDQAEp/9VCgQ3AxU5gAnjHLHCMUEg6DIl8rPqmTIHcvxxY091/gg+afoq6mWTP6FSa8OHaYEnPmOo0HZcODfLryXpb7jZy4aIn7Bjh92WY2mrw470Mu3cJmppewA72tY8dtVqCWNbhqZGBtyh1J3OmIw8ID09ySXFlSjt5w8UqIYttv+EeKj+eVnKEfvsArp/NsCF7BlimhR0ochJp6cwiRf9U/bSwLWzG2zxXCzn7oHIAqsuIGlYN3v9DhaGiEZlp4bRJ0BZZxxW25WZ5thHWN9di02gJLDY00q1t6RKhKxOv84asxgilw2eawtw==", 
        "ansible_swapfree_mb": 990, 
        "ansible_swaptotal_mb": 991, 
        "ansible_system": "Linux", 
        "ansible_system_vendor": "innotek GmbH", 
        "ansible_user_id": "vagrant", 
        "ansible_userspace_architecture": "x86_64", 
        "ansible_userspace_bits": "64", 
        "ansible_virtualization_role": "guest", 
        "ansible_virtualization_type": "virtualbox"
    }, 
    "changed": false
}
20
17
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
17