top of page

How to verify the installation of an Ansible collection?

Ansible Collections

Ansible collections are a powerful way to organize and distribute Ansible content such as playbooks, roles, modules, and plugins. However, managing collections efficiently requires knowing whether a particular collection is installed or not. In this technical guide, we'll delve into methods to check if an Ansible collection is installed on your system.

Before diving into checking for installed collections, it's essential to grasp the concept of Ansible collections. Ansible collections are units of content managed through Ansible Galaxy or custom sources. They encapsulate reusable Ansible content and can be installed from various sources such as Galaxy, GitHub, or a local filesystem.

1.Show the name and version of each collection installed.

[root@siddhesh ~]# ansible-galaxy collection list
# /root/.ansible/collections/ansible_collections
Collection      Version
--------------- -------      7.3.0
community.mysql 3.8.0
[root@siddhesh ~]#

The provided output is from the command ansible-galaxy collection list executed on a system. This command lists the installed Ansible collections along with their respective versions.

In the output: is an Ansible collection related to Amazon Web Services (AWS), with version 7.3.0 installed.

community.mysql is an Ansible collection related to MySQL, with version 3.8.0 installed.

These collections are installed in the directory /root/.ansible/collections/ansible_collections, as indicated by the comment in the output. This directory typically stores collections installed at the user level.

2.Compare checksums with the collection(s) found on the server and the installed copy.

[root@siddhesh ~]# ansible-galaxy collection verify
Downloading to /root/.ansible/tmp/ansible-local-16318a519ri23/tmp5_jgrxoh/amazon-aws-7.3.0-iuzby00x
Verifying ''.
Installed collection found at '/root/.ansible/collections/ansible_collections/amazon/aws'
MANIFEST.json hash: 7825b21d33c616bab26806db95986e88941aed1f440fbb3bf4f124a2c312310e
Collection contains modified content in the following files:
[root@siddhesh ~]#

The ansible-galaxy collection verify command is used to ensure the authenticity and integrity of Ansible collections, verifying that they haven't been tampered with or corrupted.

Here's what each part of the output signifies:

Downloading: The command downloads the collection from the Galaxy server to a temporary directory (/root/.ansible/tmp/ansible-local-16318a519ri23/tmp5_jgrxoh/amazon-aws-7.3.0-iuzby00x) for verification.

Verifying '': This line indicates that the verification process is initiated for the specified collection and version.

Installed collection found: The verification process checks the installed collection found at /root/.ansible/collections/ansible_collections/amazon/aws.

MANIFEST.json hash: The hash value (7825b21d33c616bab26806db95986e88941aed1f440fbb3bf4f124a2c312310e) of the MANIFEST.json file is displayed. This file contains information about the contents of the collection.

Collection contains modified content: The verification process identifies modified content within the collection. In this case, it lists specific files and directories

(plugins/doc_fragments/__pycache__, plugins/doc_fragments/__pycache__/tags.cpython-39.pyc, plugins/doc_fragments/__pycache__/boto3.cpython-39.pyc, plugins/inventory/__pycache__, plugins/inventory/__pycache__/aws_ec2.cpython-39.pyc).

3.Install Ansible collection from Ansible-Galaxy

The command ansible-galaxy collection installs softing.linux is used in the below example to install Ansible collection softing.linux from Ansible-Galaxy.

[root@siddhesh ~]# ansible-galaxy collection install softing.linux
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Downloading to /root/.ansible/tmp/ansible-local-19313hlu88q9b/tmpf6rnuesm/softing-linux-1.0.5-p5l_0xo1
Installing 'softing.linux:1.0.5' to '/root/.ansible/collections/ansible_collections/softing/linux'
softing.linux:1.0.5 was installed successfully
[root@siddhesh ~]# ansible-galaxy collection list

# /root/.ansible/collections/ansible_collections
Collection      Version
--------------- -------      7.3.0
community.mysql 3.8.0
softing.linux   1.0.5
[root@siddhesh ~]#

4.Install Ansible collection from tarball.

[root@siddhesh ~]# ansible-galaxy collection install /home/centos/opentelekomcloud-backend-0.1.0.tar.gz
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Installing 'opentelekomcloud.backend:0.1.0' to '/root/.ansible/collections/ansible_collections/opentelekomcloud/backend'
opentelekomcloud.backend:0.1.0 was installed successfully
[root@siddhesh ~]#

The command ansible-galaxy collection install /home/centos/opentelekomcloud-backend-0.1.0.tar.gz is used to install an Ansible collection from a local file. Here's an explanation of each part of the command.

ansible-galaxy: This is the command-line interface (CLI) tool for Ansible Galaxy, a repository for sharing and distributing Ansible content such as roles, modules, and collections.

collection install: This part of the command specifies the action to be taken, which is to install a collection.

/home/centos/opentelekomcloud-backend-0.1.0.tar.gz: This is the path to the local file containing the Ansible collection to be installed. It specifies the exact location of the collection file on the filesystem. In this case, the collection is named opentelekomcloud-backend and has version 0.1.0, and it's in the .tar.gz compressed archive format.

1 Comment

Rated 0 out of 5 stars.
No ratings yet

Add a rating
Mar 20
Rated 5 out of 5 stars.
bottom of page