A template to simplify the start of role developing.
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| defaults | ||
| files | ||
| handlers | ||
| meta | ||
| tasks | ||
| templates | ||
| vars | ||
| .gitignore | ||
| LICENSE | ||
| README.md | ||
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 withchecks-.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:
- checks-syntax.yaml: Checks the syntax of role variables.
- checks-host-config.yaml: Checks the host configuration.
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