An Ansible role supports Debian Stretch and Buster.
It is not able to do the job on Jessie or older versions.
Which is the best way to tell the user that the role cannot be used on a given old version?
- Do nothing in
main.yml
file (controlling the distro version usingwhen:
declarations) - Let the role explicitly fail using the fail module
- Do not check for a supported distro version and let tasks fail themselves
2
Answers
Developers should place the supported/tested versions in the Readme. Then users should always read the Readme. Then, common sense should be used.
But we all know that’s not the case.
You could configure the host(s) which are too old skip to the role, to ensure the hosts do not execute any command for that role. But the way to go would be to built another role, or update that role, to let that playbook support that OS version.
This method is the least desired one:
Do not check for a supported distro version and let tasks fail themselves
. Because when you go down this path, then some unsupported tasks are executed on the host and then you can’t guarantee the state of the system anymore. In short; you’ll create a mess.To simply prevent the nightmare, indeed, let the play fail:
A: It’s a good idea to end the host or play when the platform and version is not supported. In most cases, this means such a platform and version hasn’t been tested yet. It’s up to the user to add a new platform and version to the metadata, test it and optionally contribute to the development.
In a role, it’s possible to read the variable
galaxy_info
from the role’s filemeta/main.yml
and test the supported platforms and versions.For example the tasks in the role below
with the playbook
give