Skip to content

Instantly share code, notes, and snippets.

@Kahn
Last active October 18, 2017 14:19
Show Gist options
  • Save Kahn/8856851 to your computer and use it in GitHub Desktop.
Save Kahn/8856851 to your computer and use it in GitHub Desktop.
Working jinja template using Ansible hostvars
{% for host in groups['switches'] %}
define host {
use generic-switch
host_name {{ host }}
alias {{ hostvars[host]['label'] }}
address {{ host }}
hostgroups SWITCHES
contact_groups networkadmins
}
@Kahn
Copy link
Author

Kahn commented Feb 7, 2014

13:07 < bcoca> swilson_au: host is just a string, host.label doesnt exist
13:08 < bcoca> hostvars[host]['label'] might be what you want

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment