From 4cb6b933d590c47edec9c5c35e9a9d599eeee24e Mon Sep 17 00:00:00 2001 From: jaydee Date: Wed, 6 Dec 2023 15:19:27 +0100 Subject: [PATCH] 111 --- playbooks/reconfigure_heimdall.yaml | 12 ++++++++++++ playbooks/reconfigure_nginx.yaml | 6 ++++++ playbooks/sync_container_data.yaml | 8 ++++++++ playbooks/sync_part1-2.yaml | 29 +++++++++++++++++++++++++++++ playbooks/sync_part1.yaml | 29 +++++++++++++++++++++++++++++ 5 files changed, 84 insertions(+) create mode 100644 playbooks/reconfigure_heimdall.yaml create mode 100644 playbooks/reconfigure_nginx.yaml create mode 100644 playbooks/sync_container_data.yaml create mode 100644 playbooks/sync_part1-2.yaml create mode 100644 playbooks/sync_part1.yaml diff --git a/playbooks/reconfigure_heimdall.yaml b/playbooks/reconfigure_heimdall.yaml new file mode 100644 index 0000000..2cf9f2a --- /dev/null +++ b/playbooks/reconfigure_heimdall.yaml @@ -0,0 +1,12 @@ +- name: Getting entry + ansible.builtin.shell: sqlite3 /share/docker_data/heimdall/config/www/app.sqlite "SELECT url FROM items WHERE title = '{{ item }}'" + become: true + when: inventory_hostname in groups['raspberrypi5'] + register: url + +- debug: + msg: "{{ url.stdout |regex_replace('[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}','192.168.77.238')}}" +- name: Changing entry + ansible.builtin.shell: sqlite3 /share/docker_data/heimdall/config/www/app.sqlite "UPDATE items SET url = '{{ url.stdout |regex_replace('[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}','192.168.77.238') }}' WHERE title = '{{ item }}'" + become: true + when: inventory_hostname in groups['raspberrypi5'] \ No newline at end of file diff --git a/playbooks/reconfigure_nginx.yaml b/playbooks/reconfigure_nginx.yaml new file mode 100644 index 0000000..2180573 --- /dev/null +++ b/playbooks/reconfigure_nginx.yaml @@ -0,0 +1,6 @@ +- debug: + msg: "{{ item }}" +- name: Changing entry in nginx database + ansible.builtin.shell: sqlite3 /share/docker_data/nginx/data/database.sqlite "UPDATE proxy_host SET forward_host = '192.168.77.238' WHERE domain_names = '[\"{{ item }}\"]'" + become: true + when: inventory_hostname in groups['raspberrypi5'] \ No newline at end of file diff --git a/playbooks/sync_container_data.yaml b/playbooks/sync_container_data.yaml new file mode 100644 index 0000000..3a375af --- /dev/null +++ b/playbooks/sync_container_data.yaml @@ -0,0 +1,8 @@ +- name: Changing permission + ansible.builtin.shell: 'chown -R admin. /share/docker_data/' + become: true + when: inventory_hostname in groups['raspberry'] or inventory_hostname in groups['raspberrypi5'] +- name: Syncing all + ansible.builtin.shell: 'rsync -ra /share/docker_data/{mailu2,ha,gitlab,semaphore,webhub,nginx,heimdall} admin@192.168.77.238:/share/docker_data/ --exclude='home-assistant.log*' --exclude='gitlab/logs/*' + #ansible.builtin.shell: 'ls -la' + when: inventory_hostname in groups['nas'] \ No newline at end of file diff --git a/playbooks/sync_part1-2.yaml b/playbooks/sync_part1-2.yaml new file mode 100644 index 0000000..f707124 --- /dev/null +++ b/playbooks/sync_part1-2.yaml @@ -0,0 +1,29 @@ +- name: Changing permission + ansible.builtin.shell: 'chown -R admin. /share/docker_data/' + become: true + when: inventory_hostname in groups['raspberry'] or inventory_hostname in groups['raspberrypi5'] +- name: Syncing all + #ansible.builtin.shell: 'rsync -ra /share/docker_data/{mailu2,ha,gitlab,semaphore,webhub,nginx,heimdall} admin@192.168.77.238:/share/docker_data/' + ansible.builtin.shell: 'ls -la' + when: inventory_hostname in groups['nas'] + +- name: Get relevant configs + ansible.builtin.shell: 'egrep -l "# ha.sectorq.eu|# pw.sectorq.eu|# semaphore.sectorq.eu|# sectorq.eu|# gitlab.sectorq.eu|# ha.sectorq.eu" /share/docker_data/nginx/data/nginx/proxy_host/*' + ignore_errors: yes + become: yes + register: result + when: inventory_hostname in groups['raspberrypi5'] + +- debug: + msg: "{{ result.stdout_lines }}" + when: inventory_hostname in groups['raspberrypi5'] +- name: Replace ip + ansible.builtin.lineinfile: + path: "{{ item }}" + regexp: '^\s+set \$server\s+\"\w+.\w+.\w+.\w+\";' + line: " set $server \"192.168.77.238\";" + become: yes + with_items: + - "{{ result.stdout_lines }}" + when: inventory_hostname in groups['raspberrypi5'] + diff --git a/playbooks/sync_part1.yaml b/playbooks/sync_part1.yaml new file mode 100644 index 0000000..f707124 --- /dev/null +++ b/playbooks/sync_part1.yaml @@ -0,0 +1,29 @@ +- name: Changing permission + ansible.builtin.shell: 'chown -R admin. /share/docker_data/' + become: true + when: inventory_hostname in groups['raspberry'] or inventory_hostname in groups['raspberrypi5'] +- name: Syncing all + #ansible.builtin.shell: 'rsync -ra /share/docker_data/{mailu2,ha,gitlab,semaphore,webhub,nginx,heimdall} admin@192.168.77.238:/share/docker_data/' + ansible.builtin.shell: 'ls -la' + when: inventory_hostname in groups['nas'] + +- name: Get relevant configs + ansible.builtin.shell: 'egrep -l "# ha.sectorq.eu|# pw.sectorq.eu|# semaphore.sectorq.eu|# sectorq.eu|# gitlab.sectorq.eu|# ha.sectorq.eu" /share/docker_data/nginx/data/nginx/proxy_host/*' + ignore_errors: yes + become: yes + register: result + when: inventory_hostname in groups['raspberrypi5'] + +- debug: + msg: "{{ result.stdout_lines }}" + when: inventory_hostname in groups['raspberrypi5'] +- name: Replace ip + ansible.builtin.lineinfile: + path: "{{ item }}" + regexp: '^\s+set \$server\s+\"\w+.\w+.\w+.\w+\";' + line: " set $server \"192.168.77.238\";" + become: yes + with_items: + - "{{ result.stdout_lines }}" + when: inventory_hostname in groups['raspberrypi5'] +