Skip to content

Template for Ansible roles which ensures a common structure and some useful utilities. Click "Use this template", then run `./init-template.sh` to initialize

License

Notifications You must be signed in to change notification settings

netr0m/ansible-role-template

Repository files navigation

Ansible Role: Template

CI

Ansible role template

Installation

$ ansible-galaxy install git+https://github.com/netr0m/ansible-role-template.git

Requirements

None

Role Variables

Available variables are listed in docs/default-variables.md (see defaults/main.yml)

Dependencies

See ansible-requirements.yml for a list

Installation

ansible-galaxy collection install -r ansible-requirements.yml
ansible-galaxy role install -r ansible-requirements.yml

Example Playbook

---
- name: Example Playbook
  hosts: all
  become: true
  gather facts: true

  roles:
    - { role: netr0m.template }
...

Development

This project uses pre-commit.

Currently, there are three hooks:

To run pre-commit manually, run pre-commit run -a

Requirements

To run pre-commit, you need three things:

  1. A virtual environment in the parent directory of this repository
  • $ python3 -m venv ../.venv
  • $ source ../.venv/bin/activate
  1. The Python dependencies (see requirements.txt)
  • $ pip install -r requirements.txt
  1. Pre-commit hooks installed
  • $ pre-commit install

Updating the 'variables' docs

This project provides a script for generating markdown files representing ansible (YAML) variable definitions.

An example can be seen in docs/default-variables.md, which is generated from the variables defined in defaults/main.yml.

Running the script

To run the generator, issue the following command. If no parameters are specified, this will generate a markdown file based on the variables in defaults/main.yml, and write it to docs/default-variables.md.

$ python3 generate-vars-md.py

# Display help message
$ python3 generate-vars-md.py --help

# Specify alternative input and output paths
$ python3 generate-vars-md.py --in-file vars/debian.yml --out-file docs/debian-vars.md --title "Debian Variables"

License

MIT

Author Information

This role was created in 2022 by netr0m

About

Template for Ansible roles which ensures a common structure and some useful utilities. Click "Use this template", then run `./init-template.sh` to initialize

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published