This is a practical Ansible template that can be used immediately to support different stages and multiple cloud
- Segregate different ENV
- Flexiability to support multiple applications
- Multi-cloud supports (GCP, AWS)
- Python 2.7+
- Ansible 2.7
Make sure the inventory/hosts are config with valid IPs first
git clone git@github.com:CyanZero/ansible_template.git
ansible -i local/ tag_web-server -m ping
ansible-playbook -i local/ playbooks/server_conf.yml --diff --check
ansible-playbook -i local/ playbooks/server_conf.yml --diff
- ansible
- local
- group_vars
all
- inventory
hosts
- group_vars
- dev_gcp
- group_vars
all
- inventory
hosts
gce.py
dev_gce.ini
- group_vars
- staging
- prod
- playbooks
*
site.yml
*server_conf.yml
- roles
- tasks
main.yml
- templates
syslog.conf.tpl
- handlers
handlers.yml
- tasks
- common
- java
- nginx
- shared
- roles
- local
- A GCP service account with miminum Compute Engine Editor role
- gce_service_account_email_address = ${email_address}
- gce_service_account_pem_file_path = ${path to gserviceaccount.json}
- gce_project_id = PROJECT NAME
export GCE_INI_PATH=${path to gce.ini}
Get the inventory list
./dev_gcp/inventory/gce.py
- Use differnt folder for different ENV, e.g. local, dev and prod
- Roles are shared common tasks
- Assign multiple roles to a host
- Host is a set of instance group
- Use site.yml to run multple playbooks
- Load tasks dynamically by passing in variablies