Low commit activity in last 3 years
No release in over a year
ansible-make-role process a single-file role definition file and generate an Ansible role from it. The role is defined in the role.yml file and contain a section for each Ansible main.yml file: 'defaults', 'vars', 'tasks', and 'handlers'. Definitions outside of those sections (notably 'dependencies') are going to the meta/main.yml file
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
>= 0

Runtime

 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 file

Example:

---
dependencies: # Goes to meta/main.yml
  - role: rails-server

defaults: # 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=yes

handlers: # 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')