Using host vars in ansible playbooks with dynamic inventory #13185
Replies: 1 comment
-
This was resolved with hostvars[inventory_hostname]["sites"][0]["facility"] |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello all -
I have configured dynamic inventory for ansible, and it works fine.
plugin: netbox.netbox.nb_inventory
api_endpoint: https://netbox
token: token
validate_certs: false
config_context: false
group_by:
site_data: true
In a playbook I use to have a variable called FACTS_OUT_PATH that I want to replace with the sites.facility variable, but not sure how to do that.
I tried just replacing with this, but /data/configbackups/{{ sites.facility }}
then I get below when running the playbook.
"The task includes an option with an undefined variable. The error was: 'facility' is undefined"
"router1": {
"ansible_host": "2.2.2.2",
"custom_fields": {
"in_dnac": false,
"in_logicmonitor": false
},
"device_roles": [
"core"
],
"device_types": [
"switch"
],
"is_virtual": false,
"local_context_data": [
null
],
"locations": [],
"manufacturers": [
"cisco"
],
"primary_ip4": "2.2.2.2",
"regions": [
"region-5",
Beta Was this translation helpful? Give feedback.
All reactions