Created
October 15, 2013 15:52
-
-
Save darKoram/6993766 to your computer and use it in GitHub Desktop.
accessing .ansible.cfg variables in jinja2 templates
I don't understand why ansible_managed works and hostfile doesn't.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hostfile = /etc/ansible/hosts | |
ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
tasks: | |
- name: Try and template templ.j2 | |
local_action: template src=templ.j2 dest=files/output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This templates out to a handy message | |
{{ ansible_managed }} | |
# This causes [localhost] => {'msg': "One or more undefined variables: 'hostfile' is undefined", 'failed': True} | |
{{ hostfile }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment