Skip to content

Instantly share code, notes, and snippets.

@shiumachi
Created September 4, 2015 02:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shiumachi/6a9bba5aec6afea1b631 to your computer and use it in GitHub Desktop.
Save shiumachi/6a9bba5aec6afea1b631 to your computer and use it in GitHub Desktop.
Create Ansible Directory Layout Based on Ansible Document
#!/bin/bash
# Create Ansible directory layaout based on Ansible Documentation http://docs.ansible.com/ansible/playbooks_best_practices.html
#
# inventory file for production servers
touch production
# inventory file for staging environment
touch staging
# here we assign variables to particular groups
mkdir group_vars
touch group_vars/group1
# if systems need specific variables, put them here
mkdir host_vars
touch host_vars/hostname1
# if any custom modules, put them here (optional)
mkdir library
# if any custom filter plugins, put them here (optional)
mkdir filter_plugins
# master playbook
touch site.yml
# playbook for webserver tier
touch webservers.yml
# playbook for dbserver tier
touch dbservers.yml
# role directories
mkdir roles
cd roles
## this hierarchy represents a "role"
mkdir common
cd common
# tasks file can include smaller files if warranted
mkdir tasks
touch tasks/main.yml
# handlers file
mkdir handlers
touch handlers/main.yml
# files for use with the template resource
# templates end in .j2
mkdir templates
touch templates/dummy.j2
# files for use with the copy resource
# script files for use with the script resource
mkdir files
touch files/dummy.txt
# variables associated with this role
mkdir vars
touch vars/main.yml
# default lower priority variables for this role
mkdir defaults
touch defaults/main.yml
# role dependencies
mkdir meta
touch meta/main.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment