Skip to content

Instantly share code, notes, and snippets.

@javiergarciad
Created November 8, 2018 19:06
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 javiergarciad/2478c0966ce98fb91273378d03644ced to your computer and use it in GitHub Desktop.
Save javiergarciad/2478c0966ce98fb91273378d03644ced to your computer and use it in GitHub Desktop.
Script to create ansible basic project directory structure
#!/bin/bash
# Script to create ansible basic project directory structure
# https://docs.ansible.com/ansible/latest/user_guide/playbooks_best_practices.html
#production # inventory file for production servers
#staging # inventory file for staging environment
#
#group_vars/
# group1.yml # here we assign variables to particular groups
# group2.yml
#host_vars/
# hostname1.yml # here we assign variables to particular systems
# hostname2.yml
#
#library/ # if any custom modules, put them here (optional)
#module_utils/ # if any custom module_utils to support modules, put them here (optional)
#filter_plugins/ # if any custom filter plugins, put them here (optional)
#
#site.yml # master playbook
#webservers.yml # playbook for webserver tier
#dbservers.yml # playbook for dbserver tier
#
#roles/
# common/ # this hierarchy represents a "role"
# tasks/ #
# main.yml # <-- tasks file can include smaller files if warranted
# handlers/ #
# main.yml # <-- handlers file
# templates/ # <-- files for use with the template resource
# ntp.conf.j2 # <------- templates end in .j2
# files/ #
# bar.txt # <-- files for use with the copy resource
# foo.sh # <-- script files for use with the script resource
# vars/ #
# main.yml # <-- variables associated with this role
# defaults/ #
# main.yml # <-- default lower priority variables for this role
# meta/ #
# main.yml # <-- role dependencies
# library/ # roles can also include custom modules
# module_utils/ # roles can also include custom module_utils
# lookup_plugins/ # or other types of plugins, like lookup in this case
#
# webtier/ # same kind of structure as "common" was above, done for the webtier role
# monitoring/ # ""
# fooapp/ # ""
read project_name
mkdir -p $project_name
cd $project_name
# inventory and master playbook
touch production staging site.yml
# folders
mkdir -p group_vars host_vars library filter_plugins roles
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment