playbook条件判断时,不显示facter_ipaddress

回复 收藏
[root@web9 ansible]# cat when.yml
---
- hosts: testhost
  user: root
  gather_facts: True
  tasks:
    - name: use when
      shell: touch /tmp/when.txt
      when: facter_ipaddress == "172.7.15.106"


facter_ipaddress奇怪不显示呢!
求解答  这是那里的问题呢
[root@web9 ansible]# ansible web10.gz.com -m setup
web10.gz.com | SUCCESS => {
    "ansible_facts": {
        "ansible_all_ipv4_addresses": [
            "172.7.15.111"
        ],
        "ansible_all_ipv6_addresses": [
            "fe80::20c:29ff:fe2c:c48d"
        ],
        "ansible_architecture": "x86_64",
        "ansible_bios_date": "07/31/2013",
        "ansible_bios_version": "6.00",
        "ansible_cmdline": {
            "KEYBOARDTYPE": "pc",
            "KEYTABLE": "us",
            "LANG": "zh_CN.UTF-8",
            "quiet": true,
            "rd_NO_DM": true,
            "rd_NO_LUKS": true,
            "rd_NO_LVM": true,
            "rd_NO_MD": true,
            "rhgb": true,
            "ro": true,
            "root": "UUID=50f3968a-93eb-4dd4-9876-ddba13e3d00e"
        },
        "ansible_date_time": {
            "date": "2016-04-22",
            "day": "22",
            "epoch": "1461283988",
            "hour": "08",
            "iso8601": "2016-04-22T00:13:08Z",
            "iso8601_basic": "20160422T081308496980",
            "iso8601_basic_short": "20160422T081308",
            "iso8601_micro": "2016-04-22T00:13:08.497075Z",
            "minute": "13",
            "month": "04",
            "second": "08",
            "time": "08:13:08",
            "tz": "CST",
            "tz_offset": "+0800",
            "weekday": "星期五",
            "weekday_number": "5",
            "weeknumber": "16",
            "year": "2016"
        },
        "ansible_default_ipv4": {
            "address": "172.7.15.111",
            "alias": "eth0",
            "broadcast": "172.7.15.255",
            "gateway": "172.7.15.1",
            "interface": "eth0",
            "macaddress": "00:0c:29:2c:c4:8d",
            "mtu": 1500,
            "netmask": "255.255.255.0",
            "network": "172.7.15.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": "409600",
                        "sectorsize": 512,
                        "size": "200.00 MB",
                        "start": "2048"
                    },
                    "sda2": {
                        "sectors": "8388608",
                        "sectorsize": 512,
                        "size": "4.00 GB",
                        "start": "411648"
                    },
                    "sda3": {
                        "sectors": "33142784",
                        "sectorsize": 512,
                        "size": "15.80 GB",
                        "start": "8800256"
                    }
                },
                "removable": "0",
                "rotational": "1",
                "scheduler_mode": "cfq",
                "sectors": "41943040",
                "sectorsize": "512",
                "size": "20.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",
                "scheduler_mode": "cfq",
                "sectors": "7608320",
                "sectorsize": "2048",
                "size": "14.51 GB",
                "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": [
                "114.114.114.114"
            ]
        },
        "ansible_domain": "gz.com",
        "ansible_env": {
            "CVS_RSH": "ssh",
            "G_BROKEN_FILENAMES": "1",
            "HOME": "/root",
            "LANG": "zh_CN.UTF-8",
            "LC_ALL": "zh_CN.UTF-8",
            "LC_MESSAGES": "zh_CN.UTF-8",
            "LESSOPEN": "||/usr/bin/lesspipe.sh %s",
            "LOGNAME": "root",
            "MAIL": "/var/mail/root",
            "PATH": "/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin",
            "PWD": "/root",
            "QTDIR": "/usr/lib64/qt-3.3",
            "QTINC": "/usr/lib64/qt-3.3/include",
            "QTLIB": "/usr/lib64/qt-3.3/lib",
            "SELINUX_LEVEL_REQUESTED": "",
            "SELINUX_ROLE_REQUESTED": "",
            "SELINUX_USE_CURRENT_RANGE": "",
            "SHELL": "/bin/bash",
            "SHLVL": "2",
            "SSH_CLIENT": "172.7.15.106 33791 22",
            "SSH_CONNECTION": "172.7.15.106 33791 172.7.15.111 22",
            "SSH_TTY": "/dev/pts/1",
            "TERM": "xterm",
            "USER": "root",
            "_": "/usr/bin/python"
        },
        "ansible_eth0": {
            "active": true,
            "device": "eth0",
            "ipv4": {
                "address": "172.7.15.111",
                "broadcast": "172.7.15.255",
                "netmask": "255.255.255.0",
                "network": "172.7.15.0"
            },
            "ipv6": [
                {
                    "address": "fe80::20c:29ff:fe2c:c48d",
                    "prefix": "64",
                    "scope": "link"
                }
            ],
            "macaddress": "00:0c:29:2c:c4:8d",
            "module": "e1000",
            "mtu": 1500,
            "pciid": "0000:02:01.0",
            "promisc": false,
            "type": "ether"
        },
        "ansible_fips": false,
        "ansible_form_factor": "Other",
        "ansible_fqdn": "web10.gz.com",
        "ansible_hostname": "web10",
        "ansible_interfaces": [
            "lo",
            "eth0"
        ],
        "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_machine": "x86_64",
        "ansible_machine_id": "2fafb4c47db102b8ec4ec8280000000b",
        "ansible_memfree_mb": 575,
        "ansible_memory_mb": {
            "nocache": {
                "free": 840,
                "used": 148
            },
            "real": {
                "free": 575,
                "total": 988,
                "used": 413
            },
            "swap": {
                "cached": 0,
                "free": 4095,
                "total": 4095,
                "used": 0
            }
        },
        "ansible_memtotal_mb": 988,
        "ansible_mounts": [
            {
                "device": "/dev/sda3",
                "fstype": "ext4",
                "mount": "/",
                "options": "rw",
                "size_available": 12303642624,
                "size_total": 16568459264,
                "uuid": "50f3968a-93eb-4dd4-9876-ddba13e3d00e"
            },
            {
                "device": "/dev/sda1",
                "fstype": "ext4",
                "mount": "/boot",
                "options": "rw",
                "size_available": 160159744,
                "size_total": 198902784,
                "uuid": "c5d5b866-9fd9-4d0f-8acb-d7efba700b23"
            }
        ],
        "ansible_nodename": "web10.gz.com",
        "ansible_os_family": "RedHat",
        "ansible_pkg_mgr": "yum",
        "ansible_processor": [
            "GenuineIntel",
            "Intel(R) Core(TM) i5-3230M CPU @ 2.60GHz"
        ],
        "ansible_processor_cores": 1,
        "ansible_processor_count": 1,
        "ansible_processor_threads_per_core": 1,
        "ansible_processor_vcpus": 1,
        "ansible_product_name": "VMware Virtual Platform",
        "ansible_product_serial": "VMware-56 4d 3e 65 ff 80 90 48-28 34 54 c4 d0 2c c4 8d",
        "ansible_product_uuid": "564D3E65-FF80-9048-2834-54C4D02CC48D",
        "ansible_product_version": "None",
        "ansible_python_version": "2.6.6",
        "ansible_selinux": {
            "config_mode": "disabled",
            "mode": "permissive",
            "policyvers": 24,
            "status": "enabled",
            "type": "targeted"
        },
        "ansible_service_mgr": "upstart",
        "ansible_ssh_host_key_dsa_public": "AAAAB3NzaC1kc3MAAACBAKFqd3W5CHPUMK0EaYHiLjLMXksLUWojdI6vIo+JZLLW9d4yE4n20ZIul63SRRyrR/T65Pux9IZij5/UbJKsbCnLAny832TjBlg5wizN1+l/AEcnuPG8/j31bAJiOokXxGUOeo8RsOy/x+K5/P9psOSsjj/nkd3nczSx0br7j5cJAAAAFQCEM/+Cc80MNGY4jcIqCG8zH42h0wAAAIALT5oiOY10g0bxLZ0pCv9s6kwR3j5p9YHHiuHh955kFzX9GHNBjbHGWEA58V+rQGwKOnjUFk8ECGTg2/xwUZFxAUqZgqZjUwCTaYPwg3KKzSNiAetb5fl98f4tX1TKcdzxqDoP9K18TI01ZKsZxFJgsTZodMJt47qp0h0Lv3MVLQAAAIBdk+CoHRoQnlybzk7LLncGou1WBDYSju5gSbxXUH8MlqUc8C1OOpgovD1ba5rDkBnuKQhJFilfNJ4c7zT4x7wnmkVU/NbSjVuUwyvDozLA66nd7KYat2WBJkdJJ9Q4nguR8kmRxSO/kVOZu6OtsXB0FQc+VJ7ARSkYLn7YdjlRtQ==",
        "ansible_ssh_host_key_rsa_public": "AAAAB3NzaC1yc2EAAAABIwAAAQEAtN+TkCytTsQLS/ll1UftngWwL0JAm4q7CcXxAEPxlsBDTORNOeVgDqtrz3YZuM156WQedNFIHEKY+PfDUlCMbrmNzw/wb/7eOj533nwhPK6RYxNlzWC2RxvasVxmQg9fjGSEejEj+Gn20RpzP/2bJ17U4ISf4UZH7jviaSH3Cf3xvSWd8Yv/MMREPtQcodmmPNEweX3hsZt8mfjGNyx0Pbt06qYFJrMM+FslmvwSi//voW+uLbQjtdA2if5unqXfq2Nsi6p/rjsICPPplWOHjvpumaJYOZBbh41bR8+joc+CkioIB7kktBL7hCmLakgcnGvlI++q3W3OlF0bEYm5rQ==",
        "ansible_swapfree_mb": 4095,
        "ansible_swaptotal_mb": 4095,
        "ansible_system": "Linux",
        "ansible_system_vendor": "VMware, Inc.",
        "ansible_uptime_seconds": 32482,
        "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
}
[root@web9 ansible]#




2016-04-22 00:15 举报
已邀请:

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: