A base template for Ansible Roles that builds correctly and can be imported on Ansible Galaxy.
- Python 2.7
- Ansible 2.x
Installing roles from Ansible Galaxy:
$ ansible-galaxy install username.rolename
You can specify a directory where you want the downloaded roles to be placed, this is very useful when you use this template as a starting point for creating new roles.
$ ansible-galaxy install username.rolename -p ~/ansible/roles/__template__
Testing on your local machine
$ ansible-playbook roles/__template__/tests/test.yml --extra-vars "rolename=roles/__template__" --syntax-check
Testing with Travis CI
$ ansible-playbook tests/test.yml -i tests/inventory --extra-vars "rolename=ansible-role-template" --syntax-check
Install all dependencies needed for this role.
$ cd ~/path/to/ansible/role
$ ansible-galaxy install -r requirements.yml
Required dependencies:
- none
(content taken from test.yml)
- hosts: localhost
remote_user: root
roles:
- "{{ rolename }}"
The primary use case for this codebase is Role Development.
-
Clone this repository into your ansible-playbook environment.
$ git clone https://github.com/terencewestphal/ansible-role-template.git roles/__template__
-
Make the appropriate changes to
meta/main.yml
.- author
- company
- platforms
- galaxy_tags
- dependencies
-
Add Files, Tasks, Vars, Templates etc to the role.
- defaults
- files
- handlers
- modules
- plugins
- tasks
- templates
- tests
- vars
-
Update the
README.md
to reflect the changes you made. -
Publish your new role.
- Push to Github
- Test with Travis CI
- Publish in Ansible Galaxy
MIT
- Author: Terence Westphal
- Company: 42 BV