Collection Name: iamgini.collection_demo_roles_modules
Install this collection locally:
ansible-galaxy collection install iamgini.collection_demo_roles_modules
$ ansible-playbook playbooks/3-hello-python.yaml
Sample playbooks are available in playbooks directory.
---
- name: Testing Custom Module
hosts: nodes
gather_facts: false
tasks:
- name: Calling customhello2 module
hello_message:
message: "Hello"
name: "John"
register: custom_value
- debug:
msg: "{{ custom_value }}"
Contribute back to the community !
You can use either the GUI method (browsing the Zip file and upload to Ansible Galaxy) or the CLI method with API token.
I have an Ansible playbook which will build and publish the Ansible Collection with proper version tag.
$ ansible-playbook utilities/update-collection.yaml -e "tag=1.0.10"
# or use the Private Automation Hub
$ ansible-playbook utilities/update-collection.yaml -e "tag=0.0.1 server=https://pah.lab.local/api/galaxy/content/published/"
Configure ANSIBLE_GALAXY_TOKEN
$ export ANSIBLE_GALAXY_TOKEN='YOUR_ANSIBLE_GALAXY_API_TOKEN'
Building the collection archive
ansible-galaxy collection build
command will create the collection archive with version information which you can publish to Ansible Galaxy.
$ ansible-galaxy collection build
# --force to overwrite if any existing archive with same version
% ls -la *.tar.gz
-rw-r--r-- 1 gini staff 7023 8 Sep 11:12 iamgini-collection_demo_roles_modules-1.0.10.tar.gz
Publish the Collection to Ansible Galaxy
Make sure you have created the Ansible Galaxy API Token and exported as environment variable ANSIBLE_GALAXY_TOKEN
before you call the publish command.
$ ansible-galaxy collection publish \
./iamgini-collection_demo_roles_modules-{{ tag }}.tar.gz \
--api-key $ANSIBLE_GALAXY_TOKEN \
--ignore-certs