Reference: Adam’s Tech Blog

The Minimum Viable Playbook (MVP) is the shortest, most useful Ansible playbook I have. Whenever I need to write some Ansible code and I’m not entirely sure I’m doing it right (which is often), I implement it first in the MVP so I can test it quickly. Here’s my latest iteration:

- hosts: localhost
  connection: local
  gather_facts: no
  vars:
    my_name: a_b_c
  tasks:
    - debug: msg={{ my_name|replace('_', '-') }}

I keep the MVP saved as ~/tmp/test.yml , from which it can be run with:

$ ansible-playbook -i localhost, ~/tmp/test.yml

Two things make the MVP particularly fast:

  1. When running tasks locally, Ansible always uses the local connection type, which means there is no SSH overhead.
  2. I’ve disabled fact-gathering which means my tasks are executed immediately. This saves about a second per run, which isn’t much but you do notice it.

As always, if you have any questions or have a topic that you would like me to discuss, please feel free to post a comment at the bottom of this blog entry, e-mail at will@oznetnerd.com, or drop me a message on Reddit (OzNetNerd).

Note: The opinions expressed in this blog are my own and not those of my employer.

Leave a comment