Installation

We can install Sensu Go Ansible collection using the ansible-galaxy tool that comes bundled with Ansible. This tool can install Ansible collections from different sources.

Installing from Ansible Galaxy

Ansible Galaxy is the default source of Ansible collections for the ansible-galaxy tool. We can install Sensu Go Ansible collection by running:

$ ansible-galaxy collection install sensu.sensu_go

After the command finishes, we will have the latest version of the Sensu Go Ansible collection installed and ready to be used.

We can also install a specific version of the collection by appending a version after the name:

$ ansible-galaxy collection install sensu.sensu_go:1.0.0

Note

ansible-galaxy command will not overwrite the existing collection if it is already installed. We can change this default behavior by adding a --force command line switch:

$ ansible-galaxy collection install --force sensu.sensu_go:1.0.0

The official Ansible documentation contains more information about the installation options in the Using collections document.

Installing from Automation Hub

If we have a valid Red Hat subscription, we can also install Sensu Go Ansible collection from Red Hat Ansible Automation Hub. But before we can do that, we need to tell Ansible about the second source of collections. We do this by placing the following content into the ansible.cfg configuration file:

[galaxy]
server_list = automation_hub, galaxy

[galaxy_server.automation_hub]
url=https://cloud.redhat.com/api/automation-hub/
auth_url=https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token
token=AABBccddeeff112233gghh...

[galaxy_server.galaxy]
url=https://galaxy.ansible.com/

Make sure you replace the token value in the above configuration with the value obtained from the token Automation Hub UI.

From here on, we can follow the steps from the previous section.

Installing from a local file

This last method of installation might come in handy in situations where our Ansible control node cannot access Ansible Galaxy or Automation Hub.

First, we need to download the Sensu Go Ansible collection archive from the GitHub releases page and then transfer that archive to the Ansible control node. Once we have that archive on our control node, we can install the Sensu Go collection by running:

$ ansible-galaxy collection install path/to/sensu-sensu_go-1.0.0.tar.gz

Installing the Windows Ansible Collection

If we are using Ansible Base or Ansible Core, we need to install the ansible.windows Ansible Collection manually:

$ ansible-galaxy collection install ansible.windows

Why is this manual step needed? While it is technically possible to declare collection dependencies, this may pose a problem for Automation Hub users. The Windows Ansible Collection is not yet certified, so we had to make it an optional dependency for the time being.