Skip to content

Comments

Lazy loading of variables from Ansible's HostVars object#2

Open
wbh1 wants to merge 4 commits intoquale1:ansible-apifrom
wbh1:ansible-api
Open

Lazy loading of variables from Ansible's HostVars object#2
wbh1 wants to merge 4 commits intoquale1:ansible-apifrom
wbh1:ansible-api

Conversation

@wbh1
Copy link

@wbh1 wbh1 commented May 17, 2022

This takes advantage of lazy loading host variables from inventory so that
only variables whose values are accessed by the template are actually loaded AND
they go through the Jinja templater when they are loaded.

Allows for correct representation of things like:

cat inventory/group_vars/mgmt_network.yml
ipv4:
- '{{ip_address_mgmt}}'

wbh1 added 4 commits May 17, 2022 17:00
/usr/bin/python is not guaranteed to exist. Should use /usr/bin/env to handle
virtualenvironments and python3-only installs.
This takes advantage of lazy loading host variables from inventory so that
only ones that need to be loaded by the template are actually loaded AND
they go through the Jinja templater when they are loaded.
Don't try to parse inventory cache files as if they were fact cache files.
If an inventory is specified, we should exclude discovered facts for hosts not in the inventory.

This helps with situations in which old facts are cached but the host(s) is no
longer in the inventory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant