From 62a62567526a70be6e6676c0a6e73cde2575ce85 Mon Sep 17 00:00:00 2001 From: jaydee Date: Tue, 22 Aug 2023 10:03:54 +0200 Subject: [PATCH] upt playbook --- playbooks/sync_mailu.yaml | 103 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 playbooks/sync_mailu.yaml diff --git a/playbooks/sync_mailu.yaml b/playbooks/sync_mailu.yaml new file mode 100644 index 0000000..41e02bd --- /dev/null +++ b/playbooks/sync_mailu.yaml @@ -0,0 +1,103 @@ +- hosts: datacenter + name: Stop mailu + tasks: + - name: Start mailu rasp + uri: + url: "http://192.168.77.106:9000/api/stacks/130/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'] + + - name: Get ruleset + command: nvram get vts_rulelist + when: inventory_hostname in groups['router'] + register: ruleset + + - name: Pause for 30 seconds + ansible.builtin.pause: + seconds: 30 + + - 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: Test + command: nvram commit + when: inventory_hostname in groups['router'] + + - name: Restart firewall + command: service restart_firewall + when: inventory_hostname in groups['router'] + + - name: Stop mailu main + uri: + url: "http://192.168.77.106:9000/api/stacks/108/stop?endpointId=2" + method: POST + body_format: form-urlencoded + return_content: yes + headers: + Content-Type: "application/json" + X-API-Key: "ptr_DfS2M6Fj2P3fVvYpkhE0KJh2UGCzY47ePaFaLqadsjg=" + timeout: 60 + register: result + ignore_errors: yes + when: inventory_hostname in groups['nas'] + + - name: Create archive + #ansible.builtin.shell: 'tar -czf /share/Data/dockers.tar.gz /share/docker_data/{mailu2,webhub,ha} --exclude="/ha/backups/*" --exclude="home-assistant.log*"' + ansible.builtin.shell: 'tar -czf /share/Data/dockers.tar.gz /share/docker_data/mailu2 --exclude="/ha/backups/*" --exclude="home-assistant.log*"' + ignore_errors: yes + when: inventory_hostname in groups['nas'] + + - name: Start mailu main + uri: + url: "http://192.168.77.106:9000/api/stacks/108/start?endpointId=2" + 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'] + + - name: Pause for 30 seconds + ansible.builtin.pause: + seconds: 30 + #- debug: + # msg: "{{ ruleset.stdout }}" + + - 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: Test + command: nvram commit + when: inventory_hostname in groups['router'] + + - name: Restart firewall + command: service restart_firewall + when: inventory_hostname in groups['router'] + + - name: Stop mailu rhasp + uri: + url: "http://192.168.77.106:9000/api/stacks/130/stop?endpointId=13" + method: POST + body_format: form-urlencoded + return_content: yes + headers: + Content-Type: "application/json" + X-API-Key: "ptr_DfS2M6Fj2P3fVvYpkhE0KJh2UGCzY47ePaFaLqadsjg=" + timeout: 60 + register: result + ignore_errors: yes + when: inventory_hostname in groups['nas'] + + \ No newline at end of file