GithubHelp home page GithubHelp logo

iamgini / ansible-collection-custom-modules Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 6.0 30 KB

Ansible Collection with Customer modules and Test Playbooks

Home Page: https://galaxy.ansible.com/ginigangadharan/custom_modules

Shell 18.52% Python 60.03% Jinja 21.45%
ansible custom-module ansible-dev automation redhat-ansible

ansible-collection-custom-modules's Introduction

Ansible Collection

Collection Name: ginigangadharan.custom_modules

Install this collection locally:

ansible-galaxy collection install ginigangadharan.custom_modules

Testing Modules

$ ansible-playbook playbooks/3-hello-python yaml

Sample Playbooks

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 }}"

Sharing Collection to Ansible Galaxy

Always 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.

Publishing Ansible Collection using Ansible Playbook

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"

Publishing Ansible Collection Manually

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 ginigangadharan-custom_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 \
  ./ginigangadharan-custom_modules-{{ tag }}.tar.gz \
  --api-key $ANSIBLE_GALAXY_TOKEN \
  --ignore-certs

Appendix

Adding Roles as Submodules (Not used)

I had a plan to use roles as submodules here and fetching from other role repositories but this has not been implemented for now.

$ git submodule add https://github.com/ginigangadharan/setup-ansible-user

$ cat .gitmodules 
[submodule "roles/setup-ansible-user"]
        path = roles/setup-ansible-user
        url = https://github.com/ginigangadharan/setup-ansible-user

ansible-collection-custom-modules's People

Contributors

iamgini avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.