bradfordwagner.github-runner
Template Ansible Role
This document describes a basic structure and setup for creating an Ansible role. Ansible roles are a way to organize your automation code and make it reusable. Below are the simple key components for a template Ansible role.
Directory Structure
your_role/
├── defaults/
│ └── main.yml
├── files/
├── handlers/
│ └── main.yml
├── meta/
│ └── main.yml
├── tasks/
│ └── main.yml
├── templates/
├── tests/
│ └── test.yml
└── vars/
└── main.yml
Description of Each Directory
- defaults/: Contains default variables for the role, set in
main.yml
. - files/: Use this directory to store files that can be copied to the remote server.
- handlers/: Special tasks that need to be run when notified, like restarting a service, stored in
main.yml
. - meta/: Contains metadata about the role like dependencies, set in
main.yml
. - tasks/: This is where you define the main tasks to execute, in
main.yml
. - templates/: Holds Jinja2 templates that can be dynamically created before being sent to the target hosts.
- tests/: Contains tests for verifying the role works as expected, such as
test.yml
. - vars/: Contains variables specific to the role.
Steps to Create a Simple Role
- Create the directory structure as shown above.
- Fill in the
defaults/main.yml
file with default variable values. - Add any files you want to copy to the remote server in the
files/
directory. - Define any handlers you need in
handlers/main.yml
. - Write your tasks in
tasks/main.yml
. - Use Jinja2 templates in the
templates/
directory if needed. - (Optional) Define any role-specific variables in
vars/main.yml
. - Write tests in the
tests/
directory.
This template helps structure your automation tasks clearly and effectively.
Installa
ansible-galaxy install bradfordwagner.github-runner
Licenza
Unknown
Download
249
Proprietario