Skip to content

ansible-examples/ansible-boilerplate

 
 

Repository files navigation

Ansible Boilerplate Code

What is boolerplate? In computer programming, boilerplate code or boilerplate refers to sections of code that have to be included in many places with little or no alteration. It is often used when referring to languages that are considered verbose, i.e. the programmer must write a lot of code to do minimal jobs Ref:

Read More

playground

Directory structure

├── _inventory
│   └── hosts.ini
│
├── _logs
│   └── facts
│   └── retry
│   └── ansible-log.json
│
├── _ssh
│   └── web.ssh.config
│
├── _ssl
│
├── group_vars
│   ├── all
│   └── dev-api-backend
│
├── notes
│   └── tags.txt
│
├── roles
│   └── common
│   └── hardening
│   └── docker
│   └── docker-compose    
│
├── ansible.cfg
│
└── dev-bastion.yml

ansible.cfg

This is a project specific configuration file to configure Ansible. View to see a more detailed explanation of the default settings provided by this project.

Read More


group_vars

This directory contains yaml files which correspond to a group name, and tells Ansible to load the variables for the hosts in that group.

Example structure:

└── group_vars
    ├── all
    │   └── global.yml
    └── dev-bastion
            └── config.yml
  • all - is a Ansible group, where it will be loaded for all hosts.
  • dev-api-backend- is a user defined group of hosts, we defined this in our dev-api-backend hosts file in the previous example.

Read More


inventories

This is where you should put the list of hosts for Ansible to connect to. It

Example:

├── hosts.ini

We have a file called hosts.ini, but if you have a lot of environments, instead of develop, you might call it dev-api-backend or dev-db-mongodb, etc.

In it you might define it like so:

[dev-api-backend]
10.250.0.0 = Env=dev EcType=dev_api_backend EcName=dev_api_backend-dev-0-a Az=a K=0 Nr=0 PublicIp=54.00.00.00 
IType=t2.medium Region=eu-west-1 PrivateIp=10.00.00.00 PrivateDns=ip-10-00-00-00.eu-west-1.compute.internal

[all:children]
dev-api-backend

Read More


notes

This is where you can add your notes for things like manual configuration.


roles

This is where you can add your custom Ansible roles for usage by your playbooks.

Read More

Roles - http://docs.ansible.com/ansible/playbooks_roles.html#roles


logs

By default this is just a symlink to ./_logs/ansible-log.json


playbooks

Read More


👬 Contribution

  • Open pull request with improvements
  • Discuss ideas in issues
  • Reach out with any feedback Twitter URL

About

Boilerplate code for Ansible

Resources

Stars

Watchers

Forks

Packages

No packages published