Ansible playbook vars not working in templates -
i have problem getting variables work in templates. variables work in playbook in templates, rendered 'as is' without getting replaced values. here simple test-playbook.yml trying.
--- - name: test playbook vars hosts: webservers vars: hello_var: hello world hello_file_path: /tmp/hello_file.txt tasks: - name: copy hello world file copy: src=templates/hello_world.txt.j2 dest={{ hello_file_path }} in templates/hello_world.txt.j2, have following contents
hi {{ hello_var }} after running playbook, have on host @ /tmp/hello_world.txt same content in template
hi {{ hello_var }} the variable hello_file_path used in playbook works variable hello_var used in template not working.
inside task using copy module copies file without template processing. in order use template need use template module.
- name: copy hello world file template: src=templates/hello_world.txt.j2 dest={{ hello_file_path }}
Comments
Post a Comment