Skip to content

Instantly share code, notes, and snippets.

@skamithi
Created April 23, 2014 01:59
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save skamithi/11200462 to your computer and use it in GitHub Desktop.
Save skamithi/11200462 to your computer and use it in GitHub Desktop.
script to create ansible playbook structure
#!/bin/bash
# Script to create ansible playbook directories
# define your roles here
roles=(upgrade packages)
directories=(tasks handlers files default vars templates)
# create playbook
mkdir global_vars
for i in ${roles[@]}; do
for j in ${directories[@]}; do
mkdir -p ${i}/${j}
done
done
exit 0
@marafa
Copy link

marafa commented Jan 17, 2017

one liner : mkdir group_vars host_vars plugins library roles/role{1..3}/{tasks,templates,handlers,files,vars,defaults,meta} -p

@aioue
Copy link

aioue commented Jun 27, 2017

ansible-galaxy create rolename

@MrTB
Copy link

MrTB commented Jul 17, 2017

u can run

ansible-galaxy init <rollename>

by ansible-galaxy version 2.2.1.0

@holms
Copy link

holms commented Feb 6, 2018

@MrTB well ansible-galaxy generates role not a playbook.

@oneyb
Copy link

oneyb commented Jul 25, 2018

👍 @MrTB
@holms the wording of the gist's title is off.

@Hobadee
Copy link

Hobadee commented Aug 21, 2019

This is a top result on Google when searching for an easy way to create Ansible playbooks. I have seriously tweaked it to make it a user-friendly program instead of a template which needed to be edited each run.

https://gist.github.com/Hobadee/37f215dc0621b35830331c82fd0d4279

@eolix
Copy link

eolix commented Oct 25, 2019

one liner : mkdir group_vars host_vars plugins library roles/role{1..3}/{tasks,templates,handlers,files,vars,defaults,meta} -p

mkdir -p group_vars host_vars plugins library roles/role{1..3}/{tasks,templates,handlers,files,vars,defaults,meta}
Move the -p to the left ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment