Ansible - create playbooks and role file and folder structure

08-09-2016 | Remy van Elst

Table of Contents

Because I always forget which folders and files go into a playbook folder. Based on the best practices page


If you like this article, consider sponsoring me by trying out a Digital Ocean VPS. With this link you'll get a $5 VPS for 2 months free (as in, you get $10 credit). (referral link)

To create a new Ansile project:

mkdir -p new_project
cd new_project
# inventory and master playbook
touch production staging site.yml 
# folders
mkdir -p group_vars host_vars library filter_plugins

To create a role with all the folders (role is named common):

mkdir -p roles/common/{tasks,handlers,templates,files,vars,defaults,meta}
touch roles/common/{tasks,handlers,templates,files,vars,defaults,meta}/main.yml

Tags: ansible, python,