From 6361d8528a5f70bb6aa392a4740c0e586553d5cd Mon Sep 17 00:00:00 2001 From: "ladislav.dusa" Date: Fri, 15 Sep 2023 14:04:30 +0200 Subject: [PATCH 1/3] lala --- playbooks/mailu_switch_to_primary.yaml | 50 ++++++++++++++++++++++++++ playbooks/mailu_switch_to_second.yaml | 50 ++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 playbooks/mailu_switch_to_primary.yaml create mode 100644 playbooks/mailu_switch_to_second.yaml diff --git a/playbooks/mailu_switch_to_primary.yaml b/playbooks/mailu_switch_to_primary.yaml new file mode 100644 index 0000000..5e97770 --- /dev/null +++ b/playbooks/mailu_switch_to_primary.yaml @@ -0,0 +1,50 @@ +- hosts: containers + name: Stop mailu + ignore_unreachable: false + vars: + arch_name: docker_mailu2_data + tasks: + - name: Start mailu rasp + uri: + url: "http://192.168.77.106:9000/api/stacks/{{ item }}/start?endpointId=13" + method: POST + body_format: form-urlencoded + return_content: yes + headers: + Content-Type: "application/json" + X-API-Key: "ptr_DfS2M6Fj2P3fVvYpkhE0KJh2UGCzY47ePaFaLqadsjg=" + timeout: 60 + ignore_errors: yes + when: inventory_hostname in groups['nas'] + loop: + - 130 + - 149 + #- 140 + - 180 + + - name: Get ruleset + command: nvram get vts_rulelist + when: inventory_hostname in groups['router'] + register: ruleset + + - name: Pause for 60 seconds + ansible.builtin.pause: + seconds: 60 + + - name: Set new ruleset + command: nvram set vts_rulelist="{{ ruleset.stdout | replace('192.168.77.106', '192.168.77.246') }}" + when: inventory_hostname in groups['router'] + + - name: Nvram commit + command: nvram commit + when: inventory_hostname in groups['router'] + + - name: Restart firewall + command: service restart_firewall + when: inventory_hostname in groups['router'] + args: + warn: false + + + + \ No newline at end of file diff --git a/playbooks/mailu_switch_to_second.yaml b/playbooks/mailu_switch_to_second.yaml new file mode 100644 index 0000000..5e97770 --- /dev/null +++ b/playbooks/mailu_switch_to_second.yaml @@ -0,0 +1,50 @@ +- hosts: containers + name: Stop mailu + ignore_unreachable: false + vars: + arch_name: docker_mailu2_data + tasks: + - name: Start mailu rasp + uri: + url: "http://192.168.77.106:9000/api/stacks/{{ item }}/start?endpointId=13" + method: POST + body_format: form-urlencoded + return_content: yes + headers: + Content-Type: "application/json" + X-API-Key: "ptr_DfS2M6Fj2P3fVvYpkhE0KJh2UGCzY47ePaFaLqadsjg=" + timeout: 60 + ignore_errors: yes + when: inventory_hostname in groups['nas'] + loop: + - 130 + - 149 + #- 140 + - 180 + + - name: Get ruleset + command: nvram get vts_rulelist + when: inventory_hostname in groups['router'] + register: ruleset + + - name: Pause for 60 seconds + ansible.builtin.pause: + seconds: 60 + + - name: Set new ruleset + command: nvram set vts_rulelist="{{ ruleset.stdout | replace('192.168.77.106', '192.168.77.246') }}" + when: inventory_hostname in groups['router'] + + - name: Nvram commit + command: nvram commit + when: inventory_hostname in groups['router'] + + - name: Restart firewall + command: service restart_firewall + when: inventory_hostname in groups['router'] + args: + warn: false + + + + \ No newline at end of file From 93459ee448fadd3c33ca20109b62f4c698ad57bd Mon Sep 17 00:00:00 2001 From: "ladislav.dusa" Date: Fri, 15 Sep 2023 14:11:49 +0200 Subject: [PATCH 2/3] lala --- playbooks/mailu_switch_to_primary.yaml | 54 +++++++++++++------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/playbooks/mailu_switch_to_primary.yaml b/playbooks/mailu_switch_to_primary.yaml index 5e97770..7fdddd1 100644 --- a/playbooks/mailu_switch_to_primary.yaml +++ b/playbooks/mailu_switch_to_primary.yaml @@ -4,9 +4,34 @@ vars: arch_name: docker_mailu2_data tasks: - - name: Start mailu rasp + + - name: Get ruleset + command: nvram get vts_rulelist + when: inventory_hostname in groups['router'] + register: ruleset + + - name: Pause for 60 seconds + ansible.builtin.pause: + seconds: 60 + + - name: Set new ruleset + command: nvram set vts_rulelist="{{ ruleset.stdout | replace('192.168.77.246', '192.168.77.106') }}" + when: inventory_hostname in groups['router'] + + - name: Nvram commit + command: nvram commit + when: inventory_hostname in groups['router'] + + - name: Restart firewall + command: service restart_firewall + when: inventory_hostname in groups['router'] + args: + warn: false + + + - name: Stop mailu rasp uri: - url: "http://192.168.77.106:9000/api/stacks/{{ item }}/start?endpointId=13" + url: "http://192.168.77.106:9000/api/stacks/{{ item }}/stop?endpointId=2" method: POST body_format: form-urlencoded return_content: yes @@ -22,29 +47,4 @@ #- 140 - 180 - - name: Get ruleset - command: nvram get vts_rulelist - when: inventory_hostname in groups['router'] - register: ruleset - - - name: Pause for 60 seconds - ansible.builtin.pause: - seconds: 60 - - - name: Set new ruleset - command: nvram set vts_rulelist="{{ ruleset.stdout | replace('192.168.77.106', '192.168.77.246') }}" - when: inventory_hostname in groups['router'] - - - name: Nvram commit - command: nvram commit - when: inventory_hostname in groups['router'] - - - name: Restart firewall - command: service restart_firewall - when: inventory_hostname in groups['router'] - args: - warn: false - - - \ No newline at end of file From 57f02bd83cebbce4e1f416c037499851054f08b3 Mon Sep 17 00:00:00 2001 From: "ladislav.dusa" Date: Fri, 15 Sep 2023 14:14:20 +0200 Subject: [PATCH 3/3] lala --- playbooks/mailu_switch_to_primary.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/playbooks/mailu_switch_to_primary.yaml b/playbooks/mailu_switch_to_primary.yaml index 7fdddd1..51595e2 100644 --- a/playbooks/mailu_switch_to_primary.yaml +++ b/playbooks/mailu_switch_to_primary.yaml @@ -10,10 +10,6 @@ when: inventory_hostname in groups['router'] register: ruleset - - name: Pause for 60 seconds - ansible.builtin.pause: - seconds: 60 - - name: Set new ruleset command: nvram set vts_rulelist="{{ ruleset.stdout | replace('192.168.77.246', '192.168.77.106') }}" when: inventory_hostname in groups['router']