SHARE
TWEET

Untitled

a guest Jan 12th, 2017 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. root@jinja2fix:/opt/test_jinja# cat templates/setincl.j2
  2. {% set myvar = "foo" %}
  3. {{ myvar }}
  4. {% include "include.j2" %}
  5. root@jinja2fix:/opt/test_jinja# cat templates/include.j2
  6. bar
  7. root@jinja2fix:/opt/test_jinja# pip list | grep Jinja2
  8. Jinja2 (2.9.4)
  9.  
  10. root@jinja2fix:/opt/test_jinja# ansible -vvvvvvv localhost -m template -a "src=setincl.j2 dest=/tmp/test.file"
  11. Loading callback plugin minimal of type stdout, v2.0 from /opt/ansible-runtime/lib/python2.7/site-packages/ansible/plugins/callback/__init__.pyc
  12. looking for "setincl.j2" at "/opt/test_jinja/templates/setincl.j2"
  13. localhost | FAILED! => {
  14.     "changed": false,
  15.     "failed": true,
  16.     "invocation": {
  17.         "module_args": {
  18.             "dest": "/tmp/test.file",
  19.             "src": "setincl.j2"
  20.         },
  21.         "module_name": "template"
  22.     },
  23.     "msg": "KeyError: 'undefined variable: 0'"
  24. }
  25.  
  26. root@jinja2fix:/opt/test_jinja# pip install Jinja2==2.8
  27. Collecting Jinja2==2.8
  28.   Using cached Jinja2-2.8-py2.py3-none-any.whl
  29. Requirement already satisfied: MarkupSafe in /opt/ansible-runtime/lib/python2.7/site-packages (from Jinja2==2.8)
  30. Installing collected packages: Jinja2
  31.   Found existing installation: Jinja2 2.9.4
  32.     Uninstalling Jinja2-2.9.4:
  33.       Successfully uninstalled Jinja2-2.9.4
  34. Successfully installed Jinja2-2.8
  35.  
  36. root@jinja2fix:/opt/test_jinja# ansible localhost -m template -a "src=setincl.j2 dest=/tmp/test.file"
  37. localhost | SUCCESS => {
  38.     "changed": true,
  39.     "checksum": "4e48e2c9a3d2ca8a708cb0cc545700544efb5021",
  40.     "dest": "/tmp/test.file",
  41.     "gid": 0,
  42.     "group": "root",
  43.     "md5sum": "f47c75614087a8dd938ba4acff252494",
  44.     "mode": "0644",
  45.     "owner": "root",
  46.     "size": 8,
  47.     "src": "/root/.ansible/tmp/ansible-tmp-1484217092.13-31545377976138/source",
  48.     "state": "file",
  49.     "uid": 0
  50. }
  51. root@jinja2fix:/opt/test_jinja# cat /tmp/test.file
  52. foo
  53. bar
RAW Paste Data
Top