ansible/playbooks/mailu_switch_to_second.yaml

77 lines
2.5 KiB
YAML
Raw Normal View History

2023-09-15 14:04:30 +02:00
- hosts: containers
2023-11-01 01:51:24 +01:00
name: Switch mailu to second
2023-11-01 01:30:32 +01:00
2023-09-15 14:04:30 +02:00
ignore_unreachable: false
vars:
2024-05-28 01:20:19 +02:00
#app_path: "<MAIL_SERVER>25,143,465,993,995,587>192.168.77.106>dsadsad dsad dasdas-ddasd>TCP><WEB_SERVER>443,80>192.168.77.106>>TCP>"
2024-05-28 00:41:00 +02:00
NEW_IP: 192.168.77.238
2023-09-15 14:04:30 +02:00
arch_name: docker_mailu2_data
2023-11-01 01:59:49 +01:00
containers:
- nginx-app-1
- heimdall
- mailu2-admin-1
- mailu2-antispam-1
- mailu2-antivirus-1
- mailu2-fetchmail-1
- mailu2-front-1
- mailu2-imap-1
- mailu2-oletools-1
- mailu2-redis-1
- mailu2-resolver-1
- mailu2-smtp-1
2023-11-01 02:02:07 +01:00
- mailu2-webdav-1
- mailu2-webmail-1
- HomeAssistant
- mosquitto-mosquitto-1
2023-09-15 14:04:30 +02:00
tasks:
2023-11-01 01:04:47 +01:00
- name: Start mailu containers
2024-05-28 01:09:07 +02:00
command: "docker start {{ containers | join(' ') }}"
2023-11-01 01:46:26 +01:00
become: true
2023-11-01 01:56:50 +01:00
ignore_errors: true
2024-05-28 00:43:07 +02:00
when: inventory_hostname in groups['raspberrypi5']
2023-11-01 01:30:32 +01:00
2023-09-15 14:04:30 +02:00
- name: Get ruleset
command: nvram get vts_rulelist
when: inventory_hostname in groups['router']
register: ruleset
2024-05-28 00:41:00 +02:00
- name: Print the gateway for each host when defined
ansible.builtin.debug:
2024-05-28 01:09:07 +02:00
msg: "var is {{ ruleset.stdout }}"
when: inventory_hostname in groups['router']
- name: Print the gateway for each host when defined
ansible.builtin.debug:
msg: "var is {{ NEW_IP }}"
2024-05-28 01:04:09 +02:00
when: inventory_hostname in groups['router']
2024-05-28 00:41:00 +02:00
- set_fact:
2024-05-28 01:23:42 +02:00
app_path2: "{{ ruleset.stdout|string }}"
2024-05-28 01:12:42 +02:00
when: inventory_hostname in groups['router']
- set_fact:
2024-05-28 01:20:19 +02:00
app_path: "{{ app_path2 | regex_replace('(\\<MAIL_SERVER\\>[0-9,]{1,}\\>)([0-9.]{1,})(\\>[0-9a-zA-Z\\s-]{0,}\\>TCP\\>)', '\\1{{ NEW_IP }}\\3') | regex_replace('(\\<WEB_SERVER\\>[0-9,]{1,}\\>)([0-9.]{1,})(\\>[0-9a-zA-Z\\s-]{0,}\\>TCP\\>)', '\\1{{ NEW_IP }}\\3') }}"
2024-05-28 01:04:09 +02:00
when: inventory_hostname in groups['router']
2024-05-28 00:41:00 +02:00
- name: Print the gateway for each host when defined
ansible.builtin.debug:
msg: "var is {{ app_path }}"
2024-05-28 01:04:09 +02:00
when: inventory_hostname in groups['router']
2024-05-28 00:41:00 +02:00
2024-05-28 01:04:09 +02:00
# - name: Pause for 60 seconds
# ansible.builtin.pause:
# seconds: 60
2023-09-15 14:04:30 +02:00
2024-05-28 01:04:09 +02:00
# - name: Set new ruleset
# command: nvram set vts_rulelist="{{ app_path }}"
# when: inventory_hostname in groups['router']
2023-09-15 14:04:30 +02:00
2024-05-28 01:04:09 +02:00
# - name: Nvram commit
# command: nvram commit
# when: inventory_hostname in groups['router']
2023-09-15 14:04:30 +02:00
2024-05-28 01:04:09 +02:00
# - name: Restart firewall
# command: service restart_firewall
# when: inventory_hostname in groups['router']
2023-11-01 00:55:11 +01:00
2023-09-15 14:04:30 +02:00