Hello Ansible Developers,
I am from the Developer Experience team at Oracle Cloud Infrastructure and wanted to get dev community’s take on code generation and idempotency in Ansible modules, and any future improvements around those.
I work specifically in the Terraform Provider team for OCI, and we have maintained an internal code-generation project based on Golang-templating and Swagger to achieve reasonable amount of parity, but any API inconsistencies are hard to generate, and hence are applied manually on top.
Up until now, due to business priorities we were building Ansible modules manually but recently started to explore code-generation for Ansible modules as well.
Here are my questions for the community to help bridge my knowledge gap on Ansible and figure out next possible steps:
- While Ansible is able to provide reasonable playbook replay and facts gathering, however, the guarantees haven’t been as strong as I found with Terraform due to the Terraform’s state file and usage of resource IDs. While facts can be gathered, cached, the responsibility is not clear between the module provider and the user on idempotency.
- Due to varying degrees of API behaviors, facts sometimes don’t match the resource, how are you dealing with this? Does it remain best effort from module perspective?
- What is a good developer guide/article for module developer that can cover how to tackle this.1. Code-generation: From my initial experimentation, Ansible felt closer to a richer CLI experience that is user-intent driven versus Terraform which gears more towards infrastructure. Hence a code-generator with CLI in mind felt more apt than re-using our Terraform code-generator as Terraform can’t really do actions which are not state oriented that well.
- For those who have attempted code-generation for Ansible modules using Swagger, what has your experience been?
- Do you prefer adding additional actions in same module with different state values than present/absent to indicate user intent and avoid duplication, or do you prefer having the resource module separate geared towards actions or customized functions.
Thanks,
Ravi