πŸ‘©β€πŸ’» Contributor Guide: Adding a New Ansible Role

πŸ“– Purpose

This guide explains how to add a new Ansible role to the homelab repository and ensure its documentation is automatically generated by our GitHub Action workflow.


πŸ›  Steps to Add a New Role

  1. Create the role folder
    • Add a new directory under roles/ with your role name:
      roles/my_new_role/
      
  2. Add required files
    • At minimum, include:
      • meta/main.yml β†’ defines role metadata (name, description, author, license, supported platforms, dependencies).
      • tasks/main.yml β†’ defines tasks for the role.
      • defaults/main.yml β†’ optional, for default variables.
      • vars/main.yml β†’ optional, for constant variables.
      • handlers/main.yml β†’ optional, for handlers.
  3. Fill in metadata
    • Example meta/main.yml:
      galaxy_info:
        role_name: my_new_role
        author: Your Name
        description: Short description of what this role does.
        license: MIT
        min_ansible_version: "2.9"
        platforms:
          - name: Ubuntu
            versions:
              - focal
              - jammy
      dependencies: []
      
  4. Commit your changes
    • Push your branch or open a pull request.

βš™οΈ What Happens Next


βœ… Contributor Expectations


πŸš€ Example

After adding roles/my_new_role/ and pushing, you’ll see:


πŸ“‘ meta/main.yml Starter Template

galaxy_info:
  role_name: my_new_role
  author: Your Name
  description: >
    Short description of what this role does.
    (Keep it concise but clear for auto-generated docs.)
  license: MIT
  min_ansible_version: "2.9"

  platforms:
    - name: Ubuntu
      versions:
        - focal
        - jammy
    - name: EL
      versions:
        - "7"
        - "8"

# List other roles this one depends on.
# These will be documented automatically in the README.
dependencies: []

πŸ”‘ Key Fields Explained


πŸš€ Contributor Tip