infra-template/ansible
Jakub Sokołowski 92c6c74bcf
ansible/roles.py: fix pull call to handle up-to-date repo
Signed-off-by: Jakub Sokołowski <jakub@status.im>
2024-06-24 08:47:40 +02:00
..
files add ansibe/files/README.md to keep the dir 2023-01-29 14:21:31 +01:00
group_vars minor updates after infra-shards 2023-10-05 14:02:30 +02:00
inventory add Ansible boilerplate 2022-05-11 14:46:01 +02:00
lookup_plugins lookup_plugins/bitwarden: ignore stderr 2024-05-07 14:36:33 +02:00
README.md add Ansible boilerplate 2022-05-11 14:46:01 +02:00
bootstrap.yml ansible/bootstrap: fix use of versioncheck.py 2024-06-20 11:59:02 +02:00
requirements.yml roles.py: script to replace Ansible Galaxy 2024-06-13 14:07:14 +02:00
roles.py ansible/roles.py: fix pull call to handle up-to-date repo 2024-06-24 08:47:40 +02:00
terraform.py add Ansible boilerplate 2022-05-11 14:46:01 +02:00
upgrade.yml ansible/upgrade.yml: remove packages after reboot 2022-05-17 19:04:15 +02:00

README.md

Description

Herein lie all ansible related files except for ansible.cfg at the root of the repo for easier usage without having to cd here.

Usage

Simply run the play related to the specific type of configuration you want to deploy:

 > ls -1 ansible/*.yml 
ansible/bootstrap.yml
ansible/upgrade.yml
ansible/main.yml
ansible-playbook ansible/main.yml

Bootstrap

All hosts are bootstraped right after provisioning using these roles:

If you want to re-run any bootstrap step you can do it like so:

ansible-playbook ansible/bootstrap.yml -t role::bootstrap:hostname

In this case only the hostname set of tasks will be executed due to the role::bootstrap:hostname tag.

Inventory

The inventory we use is crated by Terraform via the terraform-provider-ansible which generates the necessary data structures in the Consul Key/Value store that is later used by the terraform.py script to provide hosts and their variables to Ansible.

Some ways to view existing hosts:

ansible localhost -m debug -a 'var=groups'
ansible all -o -m debug -a 'var=ansible_host' | columns -t

Variables

Ansible variables can be provided to Ansible using the --extra-vars/-e flag. An example of such a flag is

compose_state: 'present'
compose_recreate: 'smart'
compose_restart: false

These are used in every role that starts docker containers. You can use them to change the behaviour of roles. For example to re-create all metric related containers use:

ansible-playbook ansible/main.yml -e compose_recreate=always

Secrets

Secrets are stored and provided in two ways: