85 lines
1.8 KiB
YAML
Raw Permalink Normal View History

---
2023-09-14 21:57:26 +02:00
- name: Deploy terraform
hosts: localhost
gather_facts: false
tasks:
- name: Deploy terraform
community.general.terraform:
project_path: ../terraform/
state: present
complex_vars: true
2023-09-15 22:02:17 +02:00
variables: "{{ terraform_vars }}"
2023-09-14 21:57:26 +02:00
register: tf_out
- debug: var=tf_out
2023-09-14 21:57:26 +02:00
- 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
2023-09-15 22:01:42 +02:00
vars_files:
- vault.yaml
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
2023-09-15 22:01:42 +02:00
mysql:
hostrange: "10.0.0.0/255.255.255.0"
roles:
- caddy
2023-09-15 22:01:42 +02:00
- mysql
- name: Setup LEMP stack on application servers
2023-09-14 21:57:26 +02:00
hosts: web
vars_files:
- vault.yaml
vars:
server_name: wordpress-jr.senecops.com
wordpress:
dir: /var/www/html/wordpress
php:
version: 8.1
2023-09-05 23:05:22 +02:00
gluster:
brick_dir: /srv/data/wordpress
mount_dir: /var/www/html/wordpress
vol_name: wordpress_vol
dir_owner: wordpress
dir_group: www-data
cluster:
2023-09-14 21:57:26 +02:00
- 10.0.0.3
- 10.0.0.4
- 10.0.0.5
2023-09-05 23:05:22 +02:00
pre_tasks:
2023-09-15 22:01:42 +02:00
- debug: var=ansible_ens10.ipv4.address
roles:
- nginx
- php
2023-09-05 23:05:22 +02:00
- glusterfs
- wordpress
2023-09-15 22:02:17 +02:00
- name: Remove public IP
hosts: localhost
gather_facts: false
tasks:
- name: Remove public Ip
community.general.terraform:
project_path: ../terraform/
state: present
complex_vars: true
variables: "{{ terraform_vars | combine({'public_ipv4': False}) }}"
register: tf_out
- debug: var=tf_out