Using Ansible doesn’t require you create everything from scratch. Ansible Galaxy encourages users to share pre-configured Ansible roles and collections for popular tasks and applications you can implement within playbooks immediately. These community submitted roles can save time when configuring playbooks for deployment.
Remember, when browsing roles on Ansible Galaxy, it’s important to check stats such as last commit, quality score, community score, and download count. These stats help you understand the quality of submitted content.
Below we’ll cover how to install content from the Ansible Galaxy community with examples:
Install Ansible Galaxy Roles
- Visit https://galaxy.ansible.com
- Search for a role you wish to use
- Select the role name for more details
- Open your terminal (or SSH)
- Install the Ansible Galaxy role:
ansible-galaxy install author.role
– e.g. ansible-galaxy install geerlingguy.securityYou’ll see the URL for the downloaded role and extraction destination.
- Add the role in an Ansible playbook:
tasks: name: Include geerlingguy's Security role include_role: geerlingguy.security
Install Ansible Galaxy Collections
An Ansible collection is a package of playbooks, roles, modules, and plugins for distribution. Collections show up in Galaxy searches alongside roles. When you select a collection, you’ll have two download options:
- Install the collection role from your terminal:
ansible-galaxy collection install authorname.collectionname
– e.g. ansible-galaxy collection install awx.awx - Select Download Tarball to download the compressed archive to your home folder, and install it from your terminal:
ansible-galaxy collection install packagename.tar.gz
– e.g. ansible-galaxy collection install awx-awx-9.2.0.tar.gz
Here are two ways to implement Ansible collections in your playbooks:
tasks: import_role: name: awx.awx
collections: name: awx.awx tasks:
Learn more about IT automation in our Ansible Education Channel.
Looking to improve performance with your Ansible agent? Manage your Ansible agent with the Cloud Server that fits your needs.