Hello,
I’d like to refactor our Ansible project to improve our use of best practices and include testing with Molecule. We’ve been using Ansible for more than 2 years, and some bad practices have made the project a bit hard to maintain.
We’d like to start by refactoring the biggest role we have in the project that manages the application our company develop. This role currently does everything—installation, deployment, backup, restore, database migrations, user creation, etc.
We’re unsure about how to split this role. Should we really create one role per objective? I’ve read recommendations suggesting roles like web_app_backup
, web_app_install
, web_app_database_migration
, etc., but I’m not fully convinced.
Also, when reading Ansible best practices, the term idempotence comes up a lot. Should the entire project strictly follow idempotence? Only the roles? Is it acceptable (from an Ansible best practice perspective) to have playbooks outside of roles that are not fully idempotent, performing isolated actions that only apply in specific states of the system (e.g., updating a web app)? Or should those playbooks be limited to orchestrating multiple roles instead?
Thanks a lot for your help!