ansible-roles/mysql/tasks/logdir.yml
David Prevot fc692cf65b
All checks were successful
gitea/ansible-roles/pipeline/head This commit looks good
Allow more --check runs
Use “when: not ansible_check_mode” or “when <file>.stat.exists or not
ansible_check_mode” in order to provide a meaningful diff if possible.

This is an improvement from the previously reverted commit
1728eaee68.
2022-12-21 18:05:41 +01:00

47 lines
1.1 KiB
YAML

---
- block:
- name: "Is {{ mysql_custom_logdir }} present ?"
stat:
path: "{{ mysql_custom_logdir }}"
check_mode: no
register: mysql_custom_logdir_test
- name: "read the real logdir"
command: readlink -f /var/log/mysql
changed_when: False
check_mode: no
register: mysql_current_real_logdir_test
tags:
- mysql
when: mysql_custom_logdir | length > 0
- block:
- name: MySQL is stopped
service:
name: mysql
state: stopped
- name: Move MySQL logdir to {{ mysql_custom_logdir }}
command: mv {{ mysql_current_real_logdir_test.stdout }} {{ mysql_custom_logdir }}
args:
creates: "{{ mysql_custom_logdir }}"
- name: Symlink {{ mysql_custom_logdir }} to /var/log/mysql
file:
src: "{{ mysql_custom_logdir }}"
dest: '/var/log/mysql'
state: link
- name: MySQL is started
service:
name: mysql
state: started
tags:
- mysql
when:
- mysql_custom_logdir | length > 0
- mysql_custom_logdir != mysql_current_real_logdir_test.stdout
- not mysql_custom_logdir_test.stat.exists
- not ansible_check_mode