3

Ansible supports custom modules written in Python .

For execution types which are not local( local mean connection: local & hosts: localhost), ansible ssh's python packages to remote node, for every play.


  1. Does ansible support writing modules in Go?

  2. if yes, can these modules be remote execution type? Because Go artifacts are binary artifacts.

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
overexchange
  • 15,768
  • 30
  • 152
  • 347

2 Answers2

4

Tasks are implemented using modules. Most modules are written in Python, but you can use another language if you wish.

From the Building A Simple Module guide, it states:

We are going to use Python here but any language is possible. Only File I/O and outputting to standard out are required. So, bash, C++, clojure, Python, Ruby, whatever you want is fine.

d4nyll
  • 11,811
  • 6
  • 54
  • 68
2

Yes, you can write Ansible modules in Go and run a binary in a remote host. Per Get Yourself GOing with Ansible:

There are at least four different ways that you can run a Go program from Ansible. You can either:

  1. Install Go and run your Go code with the go run command from Ansible.
  2. Cross compile your Go code for different platforms before execution. Then call the proper binary from Ansible, based on the facts you collect from the host.
  3. Run your Go code or compiled binary from a container with the containers.podman collection.
  4. Create an RPM package of your Go code with something like NFPM and install it in the system of the target host. You can then call it with Ansible modules shell or command.