Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/clrgit/ansible_make_role
Pre-compiler that turns single-file role.yml definitions into Ansible roles
https://github.com/clrgit/ansible_make_role
ansible ansible-roles
Last synced: about 2 months ago
JSON representation
Pre-compiler that turns single-file role.yml definitions into Ansible roles
- Host: GitHub
- URL: https://github.com/clrgit/ansible_make_role
- Owner: clrgit
- Created: 2020-02-13T14:11:33.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2024-03-24T01:26:05.000Z (10 months ago)
- Last Synced: 2024-05-02T01:38:13.281Z (9 months ago)
- Topics: ansible, ansible-roles
- Language: Ruby
- Homepage: https://rubygems.org/gems/ansible_make_role
- Size: 59.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ansible-make-role
Pre-compiler that turns a single-file role definition into Ansible role files.
The single-file `role.yml` file combines the Ansible `main.yml` files from the
`defaults`, `vars`, `tasks`, and `meta` subdirectories with a YAML top-level
section for each file (`defaults:`, `vars:`, `tasks:` etc.)## Usage
```
ansible-make-role -c|--clean -f|--force -g|--git -r|--roles=DIR -v|--verbose --version DIR...
````ansible-make-role` expects a `role.yml` file in each of the given directories
and generates an Ansible role in it. Existing `main.yml` files will be
overwritten or removed but other files won't be touched. `ansible-make-role`
search subdirectories of `./roles` if no dirctories was given on the command
line## Description
The `make.yml` contains a section for each generated file so that eg. the
`tasks` section becomes the `tasks/main.yml` file. The supported sections are
`defaults`, `vars`, `tasks`, and `handlers`. Anything outside of those sections
(notably `dependencies`) goes to the `meta/main.yml` fileExample:
```yaml
---
dependencies: # Goes to meta/main.yml
- role: rails-serverdefaults: # Goes to defaults/main.yml
appl_name: "myapp"
appl_domain: "mydomain.com"vars: # Goes to vars/main.yml
appl_host: "{{ appl_name}}.{{ appl_domain }}"tasks: # Goes to tasks/main.yml
- name: "Ensure Apache"
yum: name=httpd state=present
notify: restart_httpd- name: "Ensure Apache is enabled"
service: name=httpd enabled=yeshandlers: # Goes to handlers/main.yml"
- name: restart_httpd
servide name=httpd state=restarted...
```## Options
`-c, --clean`
Clean the project by removing autogenerated files`-f, --force`
Re-generate all files even if not needed. Useful if you forgot a
`--git` option`-g, --git`
Also handle per-role .gitignore files. Note that existing .gitignore
files are overwritten`-r, --roles=DIR`
Use DIR instead of default `./roles``-v, --verbose`
Report progress`--version`
Print version## Installation
Install it for the current ruby using:
$ gem install ansible_make_role
Please note that the gem name uses underscores but the command uses dashes ('ansible-make-role')