setup 輸出 facts 變數

  1. setup 模組可以列印所有 ansible_facts 變數內容。
    [deyu1@kvm19 ansible]$ ansible dev -m setup
    
  2. setup 模組列印 ansible_facts 變數,增加參數 filter=ansible_default_ipv4,取得其內容。
    [deyu1@kvm19 ansible]$ ansible dev -m setup -a "filter=ansible_default_ipv4"
    kvm11 | SUCCESS => {
        "ansible_facts": {
            "ansible_default_ipv4": {
                "address": "192.168.122.11",
                "alias": "ens3",
                "broadcast": "192.168.122.255",
                "gateway": "192.168.122.1",
                "interface": "ens3",
                "macaddress": "52:54:00:18:6e:94",
                "mtu": 1500,
                "netmask": "255.255.255.0",
                "network": "192.168.122.0",
                "type": "ether"
            },
            "discovered_interpreter_python": "/usr/libexec/platform-python"
        },
        "changed": false
    }
    
  3. setup 模組列印 ansible_facts 變數,增加參數 filter=ansible_fqdn,取得其內容。
    [deyu1@kvm19 ansible]$ ansible dev -m setup -a "filter=ansible_fqdn"
    kvm11 | SUCCESS => {
        "ansible_facts": {
            "ansible_fqdn": "kvm11.deyu.wang",
            "discovered_interpreter_python": "/usr/libexec/platform-python"
        },
        "changed": false
    }
    
  4. setup 模組列印 ansible_facts 變數,增加參數 filter=ansible_hostname,取得其內容。
    [deyu1@kvm19 ansible]$ ansible dev -m setup -a "filter=ansible_hostname"
    kvm11 | SUCCESS => {
        "ansible_facts": {
            "ansible_hostname": "kvm11",
            "discovered_interpreter_python": "/usr/libexec/platform-python"
        },
        "changed": false
    }