From ansible-skills
Scaffold new Ansible collections following Red Hat Communities of Practice structure and standards. Use this skill when the user asks to: "create a collection", "new collection", "scaffold collection", "ansible collection structure", "build a collection", "collection template", "initialize collection", or wants to create a new Ansible content collection. Always invoke this skill for collection scaffolding tasks.
npx claudepluginhub stoleas/ansible-skillsThis skill is limited to using the following tools:
Scaffold complete Ansible collections following Red Hat Communities of Practice (CoP) standards with proper structure, documentation, and testing setup.
Creates isolated Git worktrees for feature branches with prioritized directory selection, gitignore safety checks, auto project setup for Node/Python/Rust/Go, and baseline verification.
Executes implementation plans in current session by dispatching fresh subagents per independent task, with two-stage reviews: spec compliance then code quality.
Dispatches parallel agents to independently tackle 2+ tasks like separate test failures or subsystems without shared state or dependencies.
Scaffold complete Ansible collections following Red Hat Communities of Practice (CoP) standards with proper structure, documentation, and testing setup.
An Ansible Collection is a distribution format for Ansible content that can contain:
Collections enable:
Format: namespace.collection_name
Rules:
company.infrastructure, redhat.rhel_system_roles, community.generalComplete Red Hat CoP compliant collection:
namespace/
└── collection_name/
├── galaxy.yml # Collection metadata (REQUIRED)
├── README.md # Collection documentation (REQUIRED)
├── docs/ # Additional documentation
│ ├── getting_started.md
│ └── guides/
├── meta/
│ └── runtime.yml # Runtime metadata
├── roles/ # Collection roles
│ ├── role_name_1/
│ │ ├── defaults/
│ │ ├── handlers/
│ │ ├── meta/
│ │ │ ├── main.yml
│ │ │ └── argument_specs.yml
│ │ ├── tasks/
│ │ ├── templates/
│ │ ├── vars/
│ │ ├── README.md
│ │ └── molecule/
│ └── role_name_2/
├── plugins/ # Collection plugins
│ ├── modules/ # Custom modules
│ │ └── module_name.py
│ ├── module_utils/ # Shared module utilities
│ ├── filter/ # Jinja2 filters
│ ├── lookup/ # Lookup plugins
│ ├── inventory/ # Inventory plugins
│ ├── callback/ # Callback plugins
│ └── action/ # Action plugins
├── playbooks/ # Example playbooks
│ ├── example_1.yml
│ └── example_2.yml
├── tests/ # Collection-level tests
│ ├── integration/
│ │ └── targets/
│ └── unit/
│ └── plugins/
├── changelogs/ # Changelog management
│ ├── config.yaml
│ └── changelog.yaml
├── .ansible-lint # Linting configuration
├── .yamllint # YAML linting configuration
├── .gitignore
└── LICENSE
Required fields:
---
namespace: company
name: infrastructure
version: 1.0.0
readme: README.md
authors:
- Your Name <your.email@company.com>
description: >
Infrastructure automation collection for managing servers,
networking, and cloud resources following Red Hat CoP standards.
license:
- MIT
license_file: LICENSE
tags:
- infrastructure
- automation
- cloud
- networking
dependencies: {}
# Other collections this depends on
# ansible.posix: ">=1.0.0"
repository: https://github.com/company/ansible-infrastructure
documentation: https://docs.company.com/ansible-infrastructure
homepage: https://company.com/automation
issues: https://github.com/company/ansible-infrastructure/issues
Optional but recommended:
# Collection build configuration
build_ignore:
- .git
- .gitignore
- .DS_Store
- '*.pyc'
- '*.retry'
- tests/output
- .vscode
- .idea
Defines collection requirements and redirects:
---
requires_ansible: '>=2.11.0'
plugin_routing:
# Redirect old module names to new ones
modules:
old_module_name:
redirect: namespace.collection.new_module_name
deprecation:
removal_version: "2.0.0"
warning_text: Use namespace.collection.new_module_name instead
action_groups:
# Group modules for easier reference
cloud:
- aws_ec2
- azure_vm
- gcp_compute
# Ansible Collection: namespace.collection_name
Description of what this collection provides and its purpose.
## Included Content
### Roles
- **role_name_1** - Description of role 1
- **role_name_2** - Description of role 2
### Modules
- **module_name** - Description of module
### Plugins
- **filter/custom_filter** - Description of filter
## Requirements
- Ansible 2.11 or higher
- Python 3.8 or higher
- Supported platforms: RHEL 8/9, Debian 11/12, Ubuntu 20.04/22.04
## Installation
### From Ansible Galaxy
```bash
ansible-galaxy collection install namespace.collection_name
ansible-galaxy collection install git+https://github.com/company/collection.git
cd path/to/namespace/collection_name
ansible-galaxy collection build
ansible-galaxy collection install namespace-collection_name-1.0.0.tar.gz
---
- name: Example playbook
hosts: servers
become: true
roles:
- role: namespace.collection_name.role_name_1
variable_name: value
---
- name: Example module usage
hosts: localhost
tasks:
- name: Use custom module
namespace.collection_name.module_name:
parameter: value
ansible-galaxy collection build
# Lint
ansible-lint
# Run role tests
cd roles/role_name
molecule test
# Integration tests
ansible-test integration
Contributions welcome! Please:
[License Name]
## Collection Roles
Roles in collections must follow the same Red Hat CoP standards:
**Key Requirements:**
- Variable names prefixed: `rolename_variable`
- Internal variables: `__rolename_internal`
- Idempotency required
- Multi-platform support
- Argument specs defined
- Molecule tests included
- Comprehensive README
**Reference:** Use the `role-developer` skill for creating collection roles.
## Collection Modules
Custom modules for collection-specific functionality.
### Module Structure
```python
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2026, Your Name <your.email@company.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
DOCUMENTATION = r'''
---
module: module_name
short_description: Short description of what the module does
description:
- Detailed description of the module
- What it accomplishes
- Use cases
version_added: "1.0.0"
author:
- Your Name (@github_handle)
options:
parameter_name:
description:
- Description of the parameter
type: str
required: true
another_parameter:
description:
- Another parameter description
type: bool
required: false
default: true
'''
EXAMPLES = r'''
- name: Example usage
namespace.collection_name.module_name:
parameter_name: value
another_parameter: true
'''
RETURN = r'''
result:
description: The result of the operation
returned: always
type: dict
sample: {"status": "success"}
'''
from ansible.module_utils.basic import AnsibleModule
def run_module():
module_args = dict(
parameter_name=dict(type='str', required=True),
another_parameter=dict(type='bool', required=False, default=True),
)
result = dict(
changed=False,
result=dict()
)
module = AnsibleModule(
argument_spec=module_args,
supports_check_mode=True
)
if module.check_mode:
module.exit_json(**result)
# Module logic here
result['changed'] = True
result['result'] = {'status': 'success'}
module.exit_json(**result)
def main():
run_module()
if __name__ == '__main__':
main()
# plugins/filter/custom_filters.py
from __future__ import absolute_import, division, print_function
__metaclass__ = type
class FilterModule(object):
"""Custom Jinja2 filters"""
def filters(self):
return {
'custom_transform': self.custom_transform,
}
def custom_transform(self, value):
"""
Transform value in custom way
Args:
value: Input value
Returns:
Transformed value
"""
return value.upper()
---
profile: production # Strictest for collections
exclude_paths:
- .git/
- .github/
- tests/output/
- changelogs/
kinds:
- playbook: "playbooks/*.yml"
- tasks: "roles/*/tasks/*.yml"
- vars: "roles/*/vars/*.yml"
- meta: "roles/*/meta/main.yml"
---
extends: default
rules:
line-length:
max: 160
level: warning
indentation:
spaces: 2
indent-sequences: true
comments:
min-spaces-from-content: 1
# From collection root directory
ansible-galaxy collection build
# Creates: namespace-collection_name-1.0.0.tar.gz
# Publish to Galaxy
ansible-galaxy collection publish namespace-collection_name-1.0.0.tar.gz --token <galaxy-token>
# Install from tarball
ansible-galaxy collection install namespace-collection_name-1.0.0.tar.gz
# Or install in development mode
ansible-galaxy collection install -p ./collections /path/to/namespace/collection_name
Use antsibull-changelog for automated changelog generation:
# Initialize changelog
antsibull-changelog init .
# Add changelog fragment
cat > changelogs/fragments/feature-name.yml <<EOF
---
minor_changes:
- Add new role for database management
bugfixes:
- Fix idempotency issue in web_server role
EOF
# Generate changelog
antsibull-changelog release
# Create collection skeleton
ansible-galaxy collection init namespace.collection_name
# Navigate to collection
cd namespace/collection_name
# Create role within collection
cd roles
ansible-galaxy role init role_name --init-path .
# Or use role-developer skill
# Add role following CoP standards
# Create module
touch plugins/modules/module_name.py
# Create plugin
touch plugins/filter/custom_filters.py
# Lint
ansible-lint
# Test roles
cd roles/role_name
molecule test
# Integration tests
ansible-test integration
# Update README.md
# Add docs/ content
# Update galaxy.yml
# Build collection
ansible-galaxy collection build
# Verify build
tar -tzf namespace-collection_name-1.0.0.tar.gz
# Publish to Galaxy
ansible-galaxy collection publish namespace-collection_name-1.0.0.tar.gz
Recommended patterns:
company.infrastructure, company.securitycompany.network_team, company.platform_opscompany.kubernetes, company.cloud_awsFollow semantic versioning (MAJOR.MINOR.PATCH):
Minimize external dependencies:
Must include:
Wrong:
my-collection # Dashes not allowed
MyCollection # Capital letters not allowed
Right:
my_collection # Underscores OK, lowercase
Collection cannot build without galaxy.yml. Always include:
Wrong:
roles:
- role_name # Missing namespace
Right:
roles:
- namespace.collection_name.role_name
Wrong:
- module_name: # Ambiguous
Right:
- namespace.collection_name.module_name:
When scaffolding a collection, create:
Provide clear next steps for:
When asked to scaffold a collection, analyze requirements, create complete structure following Red Hat CoP standards, and provide comprehensive guidance for development and distribution.