Update backup to nas and remove mattermost variables.
This commit is contained in:
106
nas.yaml
106
nas.yaml
@@ -1,91 +1,59 @@
|
|||||||
---
|
---
|
||||||
# This playbook creates a backup of odroid and writes it to the nas.
|
# This playbook creates a backup of minisforum and writes it to odroid.
|
||||||
- name: Backup odroid to nas.
|
- name: Backup minisforum to odroid
|
||||||
hosts: all
|
hosts: all
|
||||||
|
vars:
|
||||||
|
directories:
|
||||||
|
- docker
|
||||||
|
- media
|
||||||
|
- nextcloud
|
||||||
|
- sftp
|
||||||
|
- strato-production
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Backup odroid
|
- name: Wakeup odroid
|
||||||
block:
|
|
||||||
- include_vars: vars/mattermost.yaml
|
|
||||||
|
|
||||||
- name: Wakeup the nas
|
|
||||||
community.general.wakeonlan:
|
community.general.wakeonlan:
|
||||||
mac: '54:04:a6:f1:9b:80'
|
mac: '00:1E:06:45:4C:45'
|
||||||
|
broadcast: 192.168.178.255
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: Wait nas is responding
|
- name: Wait odroid is responding
|
||||||
wait_for_connection:
|
ansible.builtin.wait_for_connection:
|
||||||
timeout: 120
|
|
||||||
delay: 5
|
|
||||||
sleep: 5
|
|
||||||
|
|
||||||
- name: Gathering facts
|
- name: Gathering facts
|
||||||
setup:
|
ansible.builtin.setup:
|
||||||
|
|
||||||
- name: Check mount point exists
|
- name: Mount minisforum storage
|
||||||
file:
|
|
||||||
path: /media/nas
|
|
||||||
state: directory
|
|
||||||
|
|
||||||
- name: Mount nas volume
|
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
src: 192.168.178.55:/export/data
|
src: 192.168.178.46:/
|
||||||
path: /media/nas
|
path: /media/nas
|
||||||
state: mounted
|
state: mounted
|
||||||
fstype: nfs
|
fstype: nfs
|
||||||
become: yes
|
become: true
|
||||||
|
|
||||||
- name: Backup docker data to nas
|
- name: Check backup directory exists
|
||||||
shell: rsync -a --delete /media/backup/docker/ /media/nas/Odroid/docker
|
ansible.builtin.file:
|
||||||
become: yes
|
path: /media/backup/minisforum
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
- name: Backup hetzner data to nas
|
- name: Check file path for storage directories exists
|
||||||
shell: rsync -a --delete /media/backup/hetzner/ /media/nas/Odroid/hetzner
|
ansible.builtin.file:
|
||||||
become: yes
|
path: /media/backup/minisforum/{{ item }}
|
||||||
|
state: directory
|
||||||
|
mode: '0755'
|
||||||
|
loop: "{{ directories }}"
|
||||||
|
|
||||||
- name: Backup nextcloud data to nas
|
- name: Backup minisforum directories
|
||||||
shell: rsync -a --delete /media/backup/nextcloud/ /media/nas/Odroid/nextcloud
|
ansible.builtin.shell: rsync -a --delete /media/nas/{{ item }}/ /media/backup/minisforum/{{ item }}/
|
||||||
become: yes
|
loop: "{{ directories }}"
|
||||||
|
|
||||||
- name: Backup media to nas
|
- name: Unmount the volume
|
||||||
shell: rsync -a --delete /media/backup/media/ /media/nas/Odroid/media
|
|
||||||
become: yes
|
|
||||||
|
|
||||||
- name: Umount nas volume
|
|
||||||
ansible.posix.mount:
|
ansible.posix.mount:
|
||||||
path: /media/nas
|
path: /media/nas
|
||||||
state: unmounted
|
state: unmounted
|
||||||
become: yes
|
become: true
|
||||||
|
|
||||||
- name: Inform Mattermost about success
|
- name: Shutdown nas
|
||||||
uri:
|
ansible.builtin.shell: sudo shutdown -h 1
|
||||||
url: "{{ mattermost_url }}"
|
|
||||||
method: POST
|
|
||||||
body_format: json
|
|
||||||
body:
|
|
||||||
channel_id: "{{ channel_id }}"
|
|
||||||
message: "{{ ansible_date_time.date }} {{ ansible_date_time.time }}: Playbook ran successful ({{ ansible_play_name }})"
|
|
||||||
headers:
|
|
||||||
Content-Type: application/json
|
|
||||||
Authorization: "Bearer {{ semaphore_token }}"
|
|
||||||
status_code: [200, 201]
|
|
||||||
|
|
||||||
rescue:
|
|
||||||
- name: Umount nas volume
|
|
||||||
ansible.posix.mount:
|
|
||||||
path: /media/nas
|
|
||||||
state: unmounted
|
|
||||||
become: yes
|
|
||||||
|
|
||||||
- name: Inform Mattermost about error
|
|
||||||
uri:
|
|
||||||
url: "{{ mattermost_url }}"
|
|
||||||
method: POST
|
|
||||||
body_format: json
|
|
||||||
body:
|
|
||||||
channel_id: "{{ channel_id }}"
|
|
||||||
message: "{{ ansible_date_time.date }} {{ ansible_date_time.time }}: Playbook ran with error ({{ ansible_play_name }})"
|
|
||||||
headers:
|
|
||||||
Content-Type: application/json
|
|
||||||
Authorization: "Bearer {{ error_token }}"
|
|
||||||
status_code: [200, 201]
|
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
mattermost_url: https://cs-mm.ddnss.de/api/v4/posts
|
|
||||||
channel_id: !vault |
|
|
||||||
$ANSIBLE_VAULT;1.1;AES256
|
|
||||||
39653833613461333664643534613839663837373932333262346338653366363734643361383931
|
|
||||||
3632326236393064616566653336333830356135376530320a353135616533303632663432383663
|
|
||||||
62643264356135363064353666353736666330393035643139333833306463646365356563313862
|
|
||||||
3662363932666164650a393834376463366537323066393262663730383337636636633439653437
|
|
||||||
32313635326439373234313565633035306166323935363336326231316533386538
|
|
||||||
semaphore_token: !vault |
|
|
||||||
$ANSIBLE_VAULT;1.1;AES256
|
|
||||||
63313433633333393362306534636131666536313365353439343764623132616537663838353238
|
|
||||||
3536376438343865376539336235366138303762663732370a303532306533613838383037633138
|
|
||||||
39383139656231373237333434653932663361393063313962383831356134653866313539373235
|
|
||||||
3564373132346262640a316463333735393534346436313838336439373839643535646262366339
|
|
||||||
34663863383264393638316434333764643263623536386262643431613630333539
|
|
||||||
error_token: !vault |
|
|
||||||
$ANSIBLE_VAULT;1.1;AES256
|
|
||||||
37376437373233373664323163346661663336656636316365343732383130626339363032393035
|
|
||||||
3831633664373835663933333533303031626135303139380a396439393762316430333035373233
|
|
||||||
64623137643433353537306436333665313864373634353032346366613037336437343239643661
|
|
||||||
3665646265326435650a373561663637366266613933376636313830313937306362653864376439
|
|
||||||
66313761646362323634343139316235353639643830366130653238306232353631
|
|
||||||
Reference in New Issue
Block a user