From a8bd71d2c94aa877dc2ae495f24c5988aa0b38a6 Mon Sep 17 00:00:00 2001 From: jaydee Date: Mon, 3 Jun 2024 01:14:36 +0200 Subject: [PATCH] bitwarden --- playbooks/switch_destination copy.yaml | 90 ++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 playbooks/switch_destination copy.yaml diff --git a/playbooks/switch_destination copy.yaml b/playbooks/switch_destination copy.yaml new file mode 100644 index 0000000..445ff03 --- /dev/null +++ b/playbooks/switch_destination copy.yaml @@ -0,0 +1,90 @@ +- hosts: containers + name: Switch mailu to second + + ignore_unreachable: false + vars: + arch_name: docker_mailu2_data + 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 + - mailu2-webdav-1 + - mailu2-webmail-1 + - HomeAssistant + - mosquitto-mosquitto-1 + - gitlab + - watchtower-watchtower-1 + - kestra-kestra-1 + - kestra-postgres-1 + - authentik-worker-1 + - authentik-server-1 + - authentik-redis-1 + - authentik-postgresql-1 + tasks: + - name: Start mailu containers + command: "docker start {{ containers | join(' ') }}" + become: true + ignore_errors: true + when: inventory_hostname in groups['raspberrypi5'] + + - name: Get ruleset + command: nvram get vts_rulelist + when: inventory_hostname in groups['router'] + register: ruleset + + - name: Print the gateway for each host when defined + ansible.builtin.debug: + 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 {{ destination }}" + when: inventory_hostname in groups['router'] + + - name: initialize variables + set_fact: + regexp: "\\g<1>{{ destination }}\\3" + when: inventory_hostname in groups['router'] + + - set_fact: + app_path: "{{ ruleset.stdout | regex_replace('(\\[0-9,]{1,}\\>)([0-9.]{1,})(\\>[0-9a-zA-Z\\s-]{0,}\\>TCP\\>)', regexp) | regex_replace('(\\[0-9,]{1,}\\>)([0-9.]{1,})(\\>[0-9a-zA-Z\\s-]{0,}\\>TCP\\>)', regexp) }}" + when: inventory_hostname in groups['router'] + + + - name: Print the gateway for each host when defined + ansible.builtin.debug: + msg: "var is {{ app_path }}" + when: inventory_hostname in groups['router'] + + + - name: Pause for 60 seconds + ansible.builtin.pause: + seconds: 60 + + - name: Set new ruleset + command: nvram set vts_rulelist="{{ app_path }}" + 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'] + + + + + \ No newline at end of file