One of the notes in the docs of the setup module reads: "the filter option filters only the first level subkey below ansible_facts." So you don't. Not that way at least.
Yeah, I’m aware of ansible_all_ipv4_addresses but that shows all interfaces and I just want eth0. Assuming that list is eth0, eth1, etc. etc. then I guess I could just take the first item in the list.
Igor, I’ve been googling a bit and can’t find what the difference between facter_ipaddress_eth1 and ansible_eth0.ipv4.address is. Could you please clarify?
Yes, that was a typo, but if it would have been ansible_eth1.ipv4.address,
would the expressions have been equivalent?
Unfortunately not:
# ansible me -m setup -a "filter=facter_ipaddress_eth1"
localhost | SUCCESS => {
"ansible_facts": {
"facter_ipaddress_eth1": "141.65.x.y"
},
"changed": false
}
ansible me -m setup -a "filter=ansible_eth1.ipv4.address"
localhost | SUCCESS => {
"ansible_facts": {},
"changed": false
}
I get a (lengthy) result for
# ansible me -m setup -a "filter=ansible_eth1"
but I don't get a result for
# ansible me -m setup -a "filter=ansible_eth1.ipv4"
# ansible me -m setup -a "filter=ansible_eth1.ipv4"
# ansible me -m setup -a "filter=ansible_eth1[ipv4]"
# ansible me -m setup -a "filter=ansible_eth1['ipv4']"
I got facter to install via playbook now on my CentOS 7 box and the first time it runs the playbook it doesn’t find the facter_ipaddress_eth1 but it does find it the second time I run the playbook. Do you know if there should be some waiting time after installing facter?
I am not aware of an after-installation pause. Do you use some cache for
facts, like redis?
There may be a timeout during the collection of facts, as I can see at
my box (not Centos, but SLES), the runtime is either short or quite long
- maybe some facts are hard to detect.