ansible-roles/mysql/tasks/logdir.yml
Jérémy Lecour 1728eaee68
All checks were successful
gitea/ansible-roles/pipeline/head This commit looks good
Revert "Add “when: not ansible_check_mode” to allow more --check"
This reverts commit fafff25c20.
This reverts commit e64471c5a8084f95a8e6f955d3fa918c55b8e846.
2022-12-14 07:41:18 +01:00

46 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