ansible/playbooks/sync.yaml

127 lines
4.0 KiB
YAML
Raw Normal View History

2023-08-21 09:25:58 +02:00
- hosts: datacenter
2023-08-14 14:47:44 +02:00
name: Stop mailu
tasks:
2023-08-20 14:15:32 +02:00
- name: Stop HA
uri:
url: "http://192.168.77.106:9000/api/stacks/2/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
2023-08-21 09:38:29 +02:00
when: inventory_hostname in groups['nas']
2023-08-21 10:12:49 +02:00
2023-08-21 09:46:04 +02:00
- name: Start mailu rasp
2023-08-14 14:47:44 +02:00
uri:
2023-08-20 09:21:38 +02:00
url: "http://192.168.77.106:9000/api/stacks/130/start?endpointId=13"
2023-08-14 14:47:44 +02:00
method: POST
body_format: form-urlencoded
return_content: yes
headers:
Content-Type: "application/json"
X-API-Key: "ptr_DfS2M6Fj2P3fVvYpkhE0KJh2UGCzY47ePaFaLqadsjg="
2023-08-20 14:08:51 +02:00
timeout: 60
2023-08-14 14:47:44 +02:00
register: result
2023-08-19 20:52:00 +02:00
ignore_errors: yes
2023-08-21 09:38:29 +02:00
when: inventory_hostname in groups['nas']
2023-08-21 10:03:57 +02:00
2023-08-21 10:16:44 +02:00
- name: Get ruleset
2023-08-21 10:03:57 +02:00
command: nvram get vts_rulelist
when: inventory_hostname in groups['router']
2023-08-21 10:16:44 +02:00
register: ruleset
2023-08-21 10:03:57 +02:00
2023-08-21 10:16:44 +02:00
- name: Set new ruleset
command: nvram set vts_rulelist="{{ ruleset.stdout | replace('192.168.77.106', '192.168.77.246') }}"
2023-08-21 10:03:57 +02:00
when: inventory_hostname in groups['router']
- name: Test
command: nvram commit
when: inventory_hostname in groups['router']
2023-08-21 10:12:49 +02:00
- name: Restart firewall
command: service restart_firewall
when: inventory_hostname in groups['router']
2023-08-21 10:03:57 +02:00
2023-08-20 09:21:38 +02:00
- name: Stop mailu main
2023-08-19 20:52:00 +02:00
uri:
2023-08-20 09:21:38 +02:00
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="
2023-08-20 14:08:51 +02:00
timeout: 60
2023-08-20 09:21:38 +02:00
register: result
ignore_errors: yes
2023-08-21 09:38:29 +02:00
when: inventory_hostname in groups['nas']
2023-08-21 09:46:04 +02:00
- name: Create archive
2023-08-21 10:27:06 +02:00
#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*"'
2023-08-21 09:46:04 +02:00
ignore_errors: yes
when: inventory_hostname in groups['nas']
2023-08-21 10:12:49 +02:00
2023-08-20 14:15:32 +02:00
- name: Start HA
uri:
url: "http://192.168.77.106:9000/api/stacks/2/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
2023-08-21 09:38:29 +02:00
when: inventory_hostname in groups['nas']
2023-08-21 10:12:49 +02:00
2023-08-20 09:21:38 +02:00
- 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="
2023-08-21 09:49:57 +02:00
timeout: 60
2023-08-21 10:16:44 +02:00
2023-08-20 09:21:38 +02:00
ignore_errors: yes
2023-08-21 09:38:29 +02:00
when: inventory_hostname in groups['nas']
2023-08-21 10:03:57 +02:00
2023-08-21 10:16:44 +02:00
- debug:
msg: "{{ ruleset.stdout }}"
- name: Set new ruleset
2023-08-21 10:26:38 +02:00
command: nvram set vts_rulelist="{{ ruleset.stdout | replace('192.168.77.246', '192.168.77.106') }}"
2023-08-21 10:03:57 +02:00
when: inventory_hostname in groups['router']
- name: Test
command: nvram commit
when: inventory_hostname in groups['router']
2023-08-21 10:12:49 +02:00
- name: Restart firewall
command: service restart_firewall
when: inventory_hostname in groups['router']
2023-08-21 10:03:57 +02:00
2023-08-20 13:56:03 +02:00
- name: Stop mailu rhasp
2023-08-20 09:21:38 +02:00
uri:
url: "http://192.168.77.106:9000/api/stacks/130/stop?endpointId=13"
2023-08-19 20:52:00 +02:00
method: POST
body_format: form-urlencoded
return_content: yes
headers:
Content-Type: "application/json"
X-API-Key: "ptr_DfS2M6Fj2P3fVvYpkhE0KJh2UGCzY47ePaFaLqadsjg="
2023-08-21 09:49:57 +02:00
timeout: 60
2023-08-19 20:52:00 +02:00
register: result
ignore_errors: yes
2023-08-21 09:38:29 +02:00
when: inventory_hostname in groups['nas']
2023-08-19 20:52:00 +02:00