github twitter linkedin 500px
Check the Ansible version number in a playbook
Nov 18, 2019
One minute read

My Ansible playbooks sometimes use features that are available only in a very recent versions of Ansible.

To prevent unecessary troubles to the team mates that will execute them, I like to add a task at the very beginning of my playbooks to check the Ansible version number and abort if the requirements are not met.

- name: Verify that Ansible version is >= 2.4.6
  assert:
    that: "ansible_version.full is version_compare('2.4.6', '>=')"
    msg: >-
      This module requires at least Ansible 2.4.6. The version that comes
      with RHEL and CentOS by default (2.4.2) has a known bug that prevent
      this role from running properly.

Back to posts