Hello everybody,
My company’s making the swtich from Puppet to Ansible ; i’m one of those pushing the change.
As such, i’m trying to create an internal coding standard and a set of common building blocks that each team member should use when writing ansible plays and playbooks.
An example of the standards i’m thinking of can be found here :
https://github.com/gaspaio/ansible-repository
This is a repository of “Parts” : playbook reusable components.
The conventions for writing each part are :
-
4 directories and 1+ example playbook(s), nothing new here.
-
The tasks directory should contain a file called “setup.yml” : this installs and setups up the application the part is for.
-
Other task files can exist, scripting common actions with the application
-
Each task file should start with a header, describing the task, the variables, the dependencies, etc (cf. https://github.com/gaspaio/ansible-repository/blob/master/apache/tasks/setup.yml)
-
A vars/main.yml should exist and contain all variable default values. It should be well commented.
-
All local path files should use the global “repository_basedir” variable, defined in the playbook. Since local paths used in module “template” for example are relative to the playbook, this allows us to have a global system installation of the ansible repository and still have playbooks anywhere on our system.
-
Tasks should be simple and non specific. They should perform a basic installation of the application only. Anything more should be done by forking the part to a particular playbook or use case.
Does this sound coherent with the ansible projet best practices and usage guidelines ?
Rodolfo