How to port legacy playbooks to Ansible 4.3 (a primer)
No two Ansible playbooks (or roles or templates for that matter) are alike, and they vary in complexity from the simple to the intricate and complex. However, they are all important to their authors and users, and with all the major changes that were made in the transition from Ansible 2.9 through to 4.0, this book would not be complete without a primer on how to port your code to the newer Ansible versions.
Before we get too deep into this subject, let's look at an example. In the first ever edition of this book, written in 2015 about Ansible version 1.9, an example appeared that renders a Jinja2 template using a small Ansible playbook. We will still learn about an updated version of this code in Chapter 6, Unlocking the Power of Jinja2 Templates, of this book, but for now let's look at the original code. The template, called demo.j2
, looks like this:
setting = {{ setting }} {% if feature.enabled %} feature ...