This guide walks us through the complete process of configuring Ansible to install collections from a virtual or remote JFrog Artifactory repository. The steps include creating the repository, configuring the Ansible client, authenticating securely, and finally installing the collection.
1. Create an Ansible Repository in Artifactory
-
Log in to your Artifactory UI.
-
Create the following repositories as needed:
-
Select Set Me Up to view the configuration instructions provided by Artifactory.
2. Configure Ansible to Use the Artifactory Repository
Edit or create your ansible.cfg file (either in your project directory or under /etc/ansible/ansible.cfg):
[galaxy]
server_list = test-ansible
[galaxy_server.test-ansible]
url = https://<JPD>/artifactory/api/ansible/test-ansible
token = <token>
3. Configure Authentication Using .netrc
Ansible uses .netrc to authenticate automatically when communicating with Galaxy servers.
-
Create or edit the .netrc file in your home directory:
-
Add your credentials to the file.
-
Set secure permissions (required): chmod 600 ~/.netrc
4. Install an Ansible Collection via the ansible.cfg File
Once configuration is complete, you can install collections directly from the Artifactory-backed Galaxy repository:
ansible-galaxy collection install <collection-name>
ansible-galaxy collection install community.crypto
If we want to enable the verbose mode while installing the collection, below is the command and the output:
ansible-galaxy collection install community.general -vv
Output:
ansible-galaxy [core 2.20.1]
config file = /Users/<username>/ansible.cfg
configured module search path = ['/Users/<username>/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /opt/homebrew/Cellar/ansible/13.1.0/libexec/lib/python3.14/site-packages/ansible
ansible collection location = /Users/<username>/.ansible/collections:/usr/share/ansible/collections
executable location = /opt/homebrew/bin/ansible-galaxy
python version = 3.14.2 (main, Dec 5 2025, 16:49:16) [Clang 17.0.0 (clang-1700.4.4.1)] (/opt/homebrew/Cellar/ansible/13.1.0/libexec/bin/python)
jinja version = 3.1.6
pyyaml version = 6.0.3 (with libyaml v0.2.5)
Using /Users/<username>/ansible.cfg as config file
Starting galaxy collection install process
Process install dependency map
Starting collection install process
Downloading https://<jpd>/artifactory/api/ansible/test-ansible/api/v3/plugin/ansible/content/published/collections/artifacts/community-general-12.1.0.tar.gz to /Users/<username>/.ansible/tmp/ansible-local-765894qb0ssv3/tmp36pjojsp/community-general-12.1.0-7j0ktkt1
Installing 'community.general:12.1.0' to '/Users/username/.ansible/collections/ansible_collections/community/general'
community.general:12.1.0 was installed successfully
5. Install an Ansible Collection via CLI:
Instead of passing credentials and Artifactory details through the ansible.cfg file, we can bypass the configuration file and provide these details directly in the install command. Ansible collections can be installed using the Ansible client CLI, which allows connection to any Ansible repository without relying on ansible.cfg
ansible-galaxy collection install <NAMESPACE.COLLECTION_NAME> -s https://[JFrogPlatformURL]/artifactory/api/ansible/<REPOSITORY_NAME> --token=<TOKEN>
Token can be either a set me up token, or we can use the Identity token
Eg:
ansible-galaxy collection install community.crypto -s https://<jpd>/artifactory/api/ansible/test-ansible --token=<token>
The screenshot below shows the installed package information in the UI.