A template for creating new Ansible roles.
  • PowerShell 57.4%
  • Shell 42.6%
Find a file Use this template
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-09-01 12:10:39 +02:00
defaults Initial commit 2026-09-01 11:07:45 +02:00
files Initial commit 2026-09-01 11:07:45 +02:00
handlers Initial commit 2026-09-01 11:07:45 +02:00
meta Update meta/main.yml 2026-09-01 12:10:39 +02:00
molecule/default Initial commit 2026-09-01 11:07:45 +02:00
tasks Initial commit 2026-09-01 11:07:45 +02:00
templates Initial commit 2026-09-01 11:07:45 +02:00
vars Initial commit 2026-09-01 11:07:45 +02:00
.ansible-lint update 2026-09-01 12:09:05 +02:00
.gitignore update 2026-09-01 12:09:05 +02:00
.yamllint update 2026-09-01 12:09:05 +02:00
BEST_PRACTICES.md Initial commit 2026-09-01 11:07:45 +02:00
CHANGELOG.md Initial commit 2026-09-01 11:07:45 +02:00
CODE_OF_CONDUCT.md Initial commit 2026-09-01 11:07:45 +02:00
CONTRIBUTING.md Initial commit 2026-09-01 11:07:45 +02:00
IMPROVEMENTS.md Initial commit 2026-09-01 11:07:45 +02:00
LICENSE Initial commit 2026-09-01 11:07:45 +02:00
molecule.sh Initial commit 2026-09-01 11:07:45 +02:00
README.md Initial commit 2026-09-01 11:07:45 +02:00
rename.ps1 Initial commit 2026-09-01 11:07:45 +02:00
rename.sh Initial commit 2026-09-01 11:07:45 +02:00
requirements.txt Initial commit 2026-09-01 11:07:45 +02:00
SECURITY.md Initial commit 2026-09-01 11:07:45 +02:00

Ansible Role Template

A professional Ansible role template for SPIE DataSolutions. This template provides a structured foundation for creating new Ansible roles with best practices, testing, and CI/CD integration.

Quick Start

To use this template as a base for your new role:

# Clone or download this template
git clone <repository-url> my-new-role
cd my-new-role

# Run the rename script to customize the template
powershell -ExecutionPolicy Bypass -File rename.ps1
# or on Linux:
./rename.sh

Supported Platforms

  • Debian
    • Debian 12 (Bookworm)
    • Debian 13 (Trixie)
  • Ubuntu
    • Ubuntu 22.04 LTS (Jammy)
    • Ubuntu 24.04 LTS (Noble)
  • Enterprise Linux
    • RHEL/Rocky Linux 9

Requirements

  • Ansible >= 2.10
  • Python 3.8+
  • Docker (for local testing with Molecule)
  • pip packages: see requirements.txt

Installation

From Galaxy

ansible-galaxy role install spie-ds.<role_name>

From Git

ansible-galaxy install git+https://git.ds.spie-nl.com/datasolutions/ansible-role-<role_name>.git

Role Variables

Default values are defined in defaults/main.yml. Override these in your playbook or inventory:

# Example: defaults/main.yml
role_name_example_var: "default_value"

For detailed variable documentation, see the comments in:

  • defaults/main.yml - Default configuration values
  • vars/main.yml - Internal role variables (not meant to be overridden)

Dependencies

None. This role is designed to be self-contained.

Example Playbook

Basic usage:

---
- name: Configure systems with role
  hosts: all
  become: true
  gather_facts: true

  roles:
    - role: spie-ds.<role_name>
      vars:
        role_name_example_var: "custom_value"

With tags for selective execution:

---
- name: Configure systems with role
  hosts: all
  become: true
  gather_facts: true

  roles:
    - role: spie-ds.<role_name>
      tags:
        - configuration
        - packages

Testing

This role uses Molecule for testing with the following platforms:

  • Debian 12 (Bookworm)
  • Ubuntu 22.04 LTS (Jammy)
  • Rocky Linux 9

Running Tests Locally

Prerequisites

Install the Python dependencies:

python -m pip install --upgrade -r requirements.txt

Ensure Docker daemon is running:

sudo systemctl start docker

Running Molecule Tests

Run complete test suite for all platforms:

molecule test

Run tests for specific distribution:

# For Debian 12
MOLECULE_DISTRO=debian12 molecule test

# For Ubuntu 22.04
MOLECULE_DISTRO=ubuntu2404 molecule test

# For Rocky Linux 9
MOLECULE_DISTRO=rocky9 molecule test

Run without destroying containers (for debugging):

molecule converge
molecule verify

Linting

Check code quality:

ansible-lint
yamllint .

The CI pipeline automatically tests all supported distributions.

Troubleshooting

Common Issues

Molecule container won't start:

  • Ensure Docker is running: sudo systemctl start docker
  • Check permissions: sudo usermod -aG docker $USER
  • Recreate containers: molecule destroy && molecule test

Ansible connection errors:

  • Verify SSH keys are configured
  • Check firewall rules
  • Ensure ansible_user is set correctly

Galaxy role import fails:

  • Verify meta/main.yml is valid
  • Check namespace and role naming conventions
  • Ensure version is valid SemVer

For more help, open an issue or contact support.ds.nl@spie.com

License

MIT - See LICENSE file for details.

Copyright (c) 2026 SPIE DataSolutions B.V.

Changelog

See CHANGELOG.md for a list of all notable changes to this project.

Security

Please see our Security Policy for reporting security vulnerabilities.

Contributing

Please read our Contributing Guide and Code of Conduct before submitting a Pull Request.

Support

For questions or support, contact: support.ds.nl@spie.com