mirror of
https://github.com/dredx/prole.git
synced 2026-09-23 10:13:58 +00:00
80 lines
2.2 KiB
YAML
80 lines
2.2 KiB
YAML
---
|
|
- name: Migrate /prole/logs to iSCSI
|
|
hosts: myrddin.prole.org
|
|
become: true
|
|
vars:
|
|
prole_logs_iscsi_target:
|
|
iqn: "iqn.2000-01.com.synology:synology.Target-1.292d45194a1"
|
|
chap_user: "prole"
|
|
chap_password: "{{ vault_iscsi_prole_password }}"
|
|
mounts:
|
|
- path: /prole/logs/synology
|
|
fstype: ext4
|
|
opts: "_netdev,noatime"
|
|
src: "UUID=5335affd-b1ab-4134-a1c0-be88ab965309"
|
|
tasks:
|
|
- name: Ensure rsync installed
|
|
ansible.builtin.package:
|
|
name: rsync
|
|
state: present
|
|
|
|
- name: Ensure staging mountpoint exists
|
|
ansible.builtin.file:
|
|
path: /prole/logs/synology
|
|
state: directory
|
|
mode: "0755"
|
|
|
|
- name: Login and mount logs volume at staging path
|
|
ansible.builtin.include_role:
|
|
name: iscsi
|
|
vars:
|
|
iscsi_targets: "{{ [prole_logs_iscsi_target] }}"
|
|
iscsi_absent_mounts: []
|
|
|
|
- name: Initial rsync from /prole/logs to staging
|
|
ansible.builtin.command: >
|
|
rsync -aHAX --info=stats2 /prole/logs/ /prole/logs/synology/
|
|
register: rsync_initial
|
|
failed_when: rsync_initial.rc not in [0, 24]
|
|
|
|
- name: Stop rsyslog
|
|
ansible.builtin.service:
|
|
name: rsyslog
|
|
state: stopped
|
|
|
|
- name: Final rsync after rsyslog stop
|
|
ansible.builtin.command: >
|
|
rsync -aHAX --delete --info=stats2 /prole/logs/ /prole/logs/synology/
|
|
register: rsync_final
|
|
failed_when: rsync_final.rc not in [0, 24]
|
|
|
|
- name: Unmount staging logs volume
|
|
ansible.builtin.mount:
|
|
path: /prole/logs/synology
|
|
state: unmounted
|
|
|
|
- name: Remove staging fstab entry
|
|
ansible.builtin.lineinfile:
|
|
path: /etc/fstab
|
|
state: absent
|
|
regexp: '^\\S+\\s+/prole/logs/synology\\s+'
|
|
|
|
- name: Ensure /prole/logs exists
|
|
ansible.builtin.file:
|
|
path: /prole/logs
|
|
state: directory
|
|
mode: "0755"
|
|
|
|
- name: Mount logs volume at /prole/logs
|
|
ansible.builtin.mount:
|
|
path: /prole/logs
|
|
src: "UUID=5335affd-b1ab-4134-a1c0-be88ab965309"
|
|
fstype: ext4
|
|
opts: "_netdev,noatime"
|
|
state: mounted
|
|
|
|
- name: Start rsyslog
|
|
ansible.builtin.service:
|
|
name: rsyslog
|
|
state: started
|