Last active
May 4, 2016 15:48
This file contains hidden or 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
--- a/template/template.py 2016-05-04 15:18:58.000000000 +0000 | |
+++ b/template/template.py 2016-05-04 15:25:04.918007068 +0000 | |
@@ -33,5 +33,7 @@ | |
''' | |
def new_context(self, vars=None, shared=False, locals=None): | |
- return jinja2.runtime.Context(self.environment, vars.add_locals(locals), self.name, self.blocks) | |
+ if vars is not None: | |
+ vars = vars.add_locals(locals) | |
+ return jinja2.runtime.Context(self.environment, vars, self.name, self.blocks) |
This file contains hidden or 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
{% macro hello() %} | |
hello, world! | |
{% endmacro %} |
This file contains hidden or 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
root@677539bf52ab:~# ansible-playbook t.yml -DCvv | |
Using /etc/ansible/ansible.cfg as config file | |
[WARNING]: provided hosts list is empty, only localhost is available | |
PLAYBOOK: t.yml **************************************************************** | |
1 plays in t.yml | |
PLAY [localhost] *************************************************************** | |
TASK [template] **************************************************************** | |
task path: /root/t.yml:4 | |
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "AttributeError: 'NoneType' object has no attribute 'add_locals'"} | |
NO MORE HOSTS LEFT ************************************************************* | |
to retry, use: --limit @t.retry | |
PLAY RECAP ********************************************************************* | |
localhost : ok=0 changed=0 unreachable=0 failed=1 |
This file contains hidden or 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
root@677539bf52ab:~# ansible-playbook t.yml -DCvv | |
Using /etc/ansible/ansible.cfg as config file | |
[WARNING]: provided hosts list is empty, only localhost is available | |
PLAYBOOK: t.yml **************************************************************** | |
1 plays in t.yml | |
PLAY [localhost] *************************************************************** | |
TASK [template] **************************************************************** | |
task path: /root/t.yml:4 | |
changed: [localhost] => {"changed": true, "diff": {"after": "hello, world!\n", "after_header": "dynamically generated", "before": ""}} | |
--- before | |
+++ after: dynamically generated | |
@@ -0,0 +1 @@ | |
+hello, world! | |
PLAY RECAP ********************************************************************* | |
localhost : ok=1 changed=1 unreachable=0 failed=0 |
This file contains hidden or 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
{% import 'macros.j2' as macros %} | |
{{ macros.hello() }} |
This file contains hidden or 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: localhost | |
gather_facts: false | |
tasks: | |
- template: | |
src: t.j2 | |
dest: /tmp/foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment