88 lines
2.0 KiB
YAML

---
- name: Deploy terraform
hosts: localhost
gather_facts: false
tasks:
- name: Deploy terraform
community.general.terraform:
project_path: ../terraform/
state: present
complex_vars: true
variables:
location: "nbg1"
network_zone: "eu-central"
server_count: 3
subnetwork_ip_range: "10.0.0.0/24"
lb_internal_ip: "10.0.0.100"
lb_external_ip: "167.235.105.161"
lb_service_id: 1399502
ssh_keys:
- "rothe.pub"
- "alt.pub"
register: tf_out
- debug: var=tf_out
- add_host:
name: "{{ item.key }}"
ansible_host: "{{ item.value }}"
group: web
loop: "{{ tf_out.outputs.server_ips.value | dict2items }}"
- add_host:
name: "lb"
ansible_host: "{{ tf_out.outputs.lb_public_ip.value }}"
group: lb
- name: Setup loadbalancer
hosts: lb
vars:
caddy:
server_name: wordpress-jr.senecops.com
lb_targets:
- 10.0.0.3:80
- 10.0.0.4:80
- 10.0.0.5:80
roles:
- caddy
- name: Setup LEMP stack on application servers
hosts: web
vars_files:
- vault.yaml
vars:
server_name: wordpress-jr.senecops.com
wordpress:
dir: /var/www/html/wordpress
db_name: wordpress
db_user: wp
php:
version: 8.1
gluster:
brick_dir: /srv/data/wordpress
mount_dir: /var/www/html/wordpress
vol_name: wordpress_vol
dir_owner: wordpress
dir_group: www-data
cluster:
- 10.0.0.3
- 10.0.0.4
- 10.0.0.5
mysql:
replication_user: replica_user
replication_master_hostname: web1
replication_master_ip: 10.0.0.3
replication_slaves:
- web2
- web3
pre_tasks:
- debug: var=ansible_all_ipv4_addresses
# we need gluster on all servers to configure peering
roles:
- nginx
- mysql
- mysql-replication
- php
- glusterfs
- wordpress