Skip to content

Latest commit

 

History

History
54 lines (42 loc) · 2.15 KB

README.md

File metadata and controls

54 lines (42 loc) · 2.15 KB

About This Repo

This is a skeleton of an Ansible home directory. You can control all of your application environments from this directory. If you work with multiple customers, you probably want to create a separate copy of this repo for each customer.

This repo was designed to help new Ansible users to get up and running quickly. Feel free to add to it and add additional tips and tricks. Pull requests welcome.

Ansible Tips

In your roles directory, type ansible-galaxy init role_name in order to generate an empty skeleton for a new role you are working on.

Example:

ansible-galaxy init nginx

Check out Ansible Examples for example playbooks.

Best Practices Directory Layout

production                # inventory file for production servers
stage                     # inventory file for stage environment

group_vars/
   group1                 # here we assign variables to particular groups
   group2                 # ""
host_vars/
   hostname1              # if systems need specific variables, put them here
   hostname2              # ""

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
        meta/             #
            main.yml      #  -- role dependencies

    webtier/              # same kind of structure as "common" was above, done for the webtier role
    monitoring/           # ""
    fooapp/               # ""