A template to simplify the start of role developing.
Find a file Use this template
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2024-09-01 19:23:53 +02:00
defaults initial commit 2024-07-06 13:57:00 +02:00
files initial commit 2024-07-06 13:57:00 +02:00
handlers initial commit 2024-07-06 13:57:00 +02:00
meta Clarify metadata as context dependent 2024-09-01 19:23:53 +02:00
tasks Include configuration tasks 2024-08-21 05:44:43 +02:00
templates initial commit 2024-07-06 13:57:00 +02:00
vars initial commit 2024-07-06 13:57:00 +02:00
.gitignore add .gitignore 2024-07-06 13:59:26 +02:00
LICENSE add LICENE 2024-07-06 13:57:23 +02:00
README.md Pre-Check Variables use host config as example 2024-09-01 16:07:18 +02:00

Ansible Role: Template

Template for an Ansible role.

Features

Limitations

Requirements

None.

Role Variables

External Variables

Public Role Variables

Internal Role Variables

Tags

To simplify the testing of this role, all tasks are tagged. See the Ansible documentation on Tags for reference. The following tags are available:

  • checks: Added to all tasks that perform checks or gather information for subsequent checks. This tag contains a superset of tasks whose tag begins with checks-.
  • checks-syntax: Added only to tasks that perform simple syntax checks on variables, such as whether they are defined and have the correct data type.
  • checks-host-config: Added to tasks that verify that the host configuration meets the requirements of this role for further configuration.
  • configure: Added to tasks that actually make or prepare changes on the target host.

Dependencies

None.

Example Playbook

Host configuration (host_vars/somehost.mydomain.tld/main.yaml):

## TODO: Add real example!
template_examples:
  - name: bar
    owner: foo
    group: foo

Playbook (playbook.yaml):

- name: Configure
  hosts: somehost.mydomain.tld
  tasks:
    - name: Include role template
      ansible.builtin.include_role:
        name: template

Pre-Check Variable

In a larger playbook, it may be desirable to check variable syntax at an early stage. This prevents the playbook from aborting in the middle of a run. Two files are provided for this purpose:

For example, the following task can be added at the desired position in the playbook to perform the host configuration checks separately:

- name: Include template role host configuration checks
  ansible.builtin.include_role:
    name: template
    tasks_from: checks-host-config.yaml

License

The Unlicense

Author Information

lingling (Codeberg, GitHub)