During my last Ansible training the students needed to create some Ansible templates for them selfs. As I do not want to run a testing template against some, or all, machines under Ansible control I created a small Ansible playbook to test templates.
This is the playbook:
--- # # This playbook renders a template and shows the results # Run this playbook with: # # ansible-playbook -e templ=<name of the template> template_test.yml # - hosts: localhost become: false connection: local tasks: - fail: msg: "Bailing out. The play requires a template name (templ=...)" when: templ is undefined - name: do template template: src: "{{ templ }}" dest: "/tmp/{{ templ }}" - name: get template command: cat "/tmp/{{ templ }}" register: tmplt - name: show template debug: msg: "{{ tmplt.stdout.split('\n') }}" - name: remove template file: path: "/tmp/{{ templ }}" state: absent
I called this playbook template_test.yml
. We where discussing the
inner workings of this playbook, when one of the trainees said: Why
don’t you call it TAttr? Hmm, TAttr? Yeah, he said,
Ton’s Ansible Template Tester.
And see, a new tool is born!