- name: gather facts on our delegated download host
ansible.builtin.setup:
delegate_to: "{{ tcDelegate }}"
delegate_facts: True
when: hostvars[tcDelegate]['ansible_default_ipv4']['address'] is not defined
For reasons we’ve yet to determine, some time fairly recently, it quit populating hostvars[tcDelegate]. It’s still gathering the facts. It’s just that they don’t seem to be stored anywhere. After this task succeeds, tcDelegate is not one of the keys to hostvars.
Is this a known thing? We’re running ansible [core 2.12.6], python version = 3.8.12, jinja version = 3.1.2 on Red Hat 8.5.0-3.
We have 148 hosts in our inventory. I was throwing debug tasks all over the place dumping out hostvars.keys(), and I was always getting 37 hosts, and it never included the delegate. It was an strange but consistent hodge-podge of seemingly unrelated hosts.
4 × 37 = 148
We are running under AWX, and someone (with whom I’ll have a discussion on Monday) set Job Slicing=4 in the template for this project in an attempt to reduce resource requirements for this job. Job Slicing seems like a great way to split up a large inventory into a bunch of smaller ones so individual jobs aren’t so huge that you run out of resources. But it only works if all your hosts’ jobs are truly independent from all other hosts in your inventory. In our case, our delegate ended up in a separate slice from the hosts we were running on, so it’s effectively in a different inventory when Job Slicing>1. This is why when we gathered facts (ansible.builtin.setup) for that host they never showed up in hostvars. Dropping it back to 1 restored sanity.
It may be possible to rework some things so that individual hosts are truly independent throughout the job, and we can crank up Job Slicing again.