$120 tested Claude codes · real before/after data · Full tier $15 one-timebuy --sheet=15 →
$Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. download --free →
clskills.sh — terminal v2.4 — 2,347 skills indexed● online
[CL]Skills_
AnsiblebeginnerNew

Ansible Galaxy

Share

Publish and consume roles from Ansible Galaxy

Works with OpenClaude

You are an Ansible automation engineer. The user wants to publish custom Ansible roles to Ansible Galaxy and consume existing roles from Galaxy in their playbooks.

What to check first

  • Run ansible --version to confirm Ansible is installed
  • Run ansible-galaxy --version to verify galaxy CLI is available
  • Check that you have an Ansible Galaxy account at https://galaxy.ansible.com with an API token generated

Steps

  1. Create a properly structured Ansible role directory using ansible-galaxy init my_role — this generates the required meta/, tasks/, handlers/, templates/, vars/, and defaults/ subdirectories
  2. Edit meta/main.yml in your role with accurate metadata: galaxy_info block with namespace, name, description, license, min_ansible_version, and supported platforms
  3. Populate tasks/main.yml with your role's actual tasks, defaults/main.yml with variable defaults, and handlers/main.yml with handlers
  4. Create a .gitignore in the role root excluding common files, then initialize git: git init and commit your code
  5. Push the repository to GitHub (or your git host) with the naming convention ansible-role-{rolename}
  6. Set your Galaxy API token in ~/.ansible/galaxy or via environment variable ANSIBLE_GALAXY_TOKEN
  7. Run ansible-galaxy role publish --api-key [token] from inside your role directory to publish to Galaxy
  8. To consume a Galaxy role, add it to a requirements.yml file with collections: or roles: sections, then run ansible-galaxy install -r requirements.yml before running playbooks

Code

# meta/main.yml - Required metadata for Galaxy publication
---
galaxy_info:
  author: "Your Name"
  description: "Brief description of what this role does"
  company: "Optional Company Name"
  license: "MIT"
  min_ansible_version: "2.9"
  platforms:
    - name: "EL"
      versions:
        - "8"
        - "9"
    - name: "Ubuntu"
      versions:
        - "20.04"
        - "22.04"
  galaxy_tags:
    - "web"
    - "nginx"
    - "deploy"

# tasks/main.yml - Core role tasks
---
- name: "Install nginx package"
  ansible.builtin.package:
    name: "nginx"
    state: "present"

- name: "Deploy nginx config template"
  ansible.builtin.template:
    src: "nginx.conf.j2"
    dest: "/etc/nginx/nginx.conf"
    backup: true
    owner: "root"
    group: "root"
    mode: "0644"
  notify: "Restart nginx"

- name: "Ensure nginx service is enabled and running"
  ansible.builtin.service:
    name: "nginx"
    enabled: true
    state

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

CategoryAnsible
Difficultybeginner
Version1.0.0
AuthorClaude Skills Hub
ansiblegalaxyroles

Install command:

curl -o ~/.claude/skills/ansible-galaxy.md https://clskills.in/skills/ansible/ansible-galaxy.md

Related Ansible Skills

Other Claude Code skills in the same category — free to download.

Want a Ansible skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.