Groesbeek, view of the 'National Liberation Museum 1944-1945' in Groesbeek. © Ton Kersten
Fork me on GitHub

Did you run it through TAttr

2017-08-15 (145) by Ton Kersten, tagged as ansible, sysadm

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

    - fail:
        msg: "Bailing out. The play requires a template name (templ=...)"
      when: templ is undefined

    - name: do template
        src: "{{ templ }}"
        dest: "/tmp/{{ templ }}"

    - name: get template
      command: cat "/tmp/{{ templ }}"
      register: tmplt

    - name: show template
        msg: "{{ tmplt.stdout.split('\n') }}"

    - name: remove template
        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!