The author has never been a fan of dynamic languages in general and Python in particular. But working a lot with Ansible he feels that sometimes an ansible role doesn’t cut it, and it would be better to write a module. I’ve recently started playing around with Golang, and I feel it could potentially be utilized for such a task. Hence, I’ve made this project to experiment and provide examples of how Ansible modules could be written in Golang.
He is going to utilize ansible’s binary modules, the same principles can be used to write Ansible modules in any other programming language that can build code as native executables.
For example, one could in theory write ansible modules in java, build them as native images with Graal, and use those images as ansible binary modules. In practice, though, it’s probably an overkill to write Ansible modules in java.
It is worth noting that in many cases python is still much more preferable to use when developing ansible modules.
Golang/Ansible Code Structure
This repo consists of the following:
- ansible-collection-helloworld – basic “hello-world” ansible collection
- test-playbook-git-source – a playbook that runs the
helloworld
module from the collection which is installed from the git repository source. - test-playbook-local-library – a test playbook that runs the
helloworld
module which is downloaded to the ansible controller. - test-playbook-local-source – a test playbook that runs the
helloworld
module from the collection which is installed from the local directory source. - test-playbook-role-helper – a test playbook that utilizes a role in a collection for building
helloworld
module executable
There is no ads to display, Please add some