Skip to content

Instantly share code, notes, and snippets.

@darKoram
Created October 15, 2013 15:52
Show Gist options
  • Save darKoram/6993766 to your computer and use it in GitHub Desktop.
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.
hostfile = /etc/ansible/hosts
ansible_managed = Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}
---
- hosts: all
tasks:
- name: Try and template templ.j2
local_action: template src=templ.j2 dest=files/output
# 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