ansible-roles/mysql/tasks/logdir.yml
Jérémy Lecour ee21973371
All checks were successful
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2777|524|2253|2462|:+1: Reference build: <a href="https://jenkins.evolix.org/job/gitea/job/ansible-roles/job/unstable/223//ansiblelint">Evolix » ansible-roles » unstable #223</a>
gitea/ansible-roles/pipeline/head This commit looks good
Use FQCN
Fully Qualified Collection Name
2023-03-20 23:33:19 +01:00

48 lines
1.2 KiB
YAML

---
- block:
- name: "Is {{ mysql_custom_logdir }} present ?"
ansible.builtin.stat:
path: "{{ mysql_custom_logdir }}"
check_mode: no
register: mysql_custom_logdir_test
- name: "read the real logdir"
ansible.builtin.command:
cmd: 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
ansible.builtin.service:
name: mysql
state: stopped
- name: Move MySQL logdir to {{ mysql_custom_logdir }}
ansible.builtin.command:
cmd: mv {{ mysql_current_real_logdir_test.stdout }} {{ mysql_custom_logdir }}
args:
creates: "{{ mysql_custom_logdir }}"
- name: Symlink {{ mysql_custom_logdir }} to /var/log/mysql
ansible.builtin.file:
src: "{{ mysql_custom_logdir }}"
dest: '/var/log/mysql'
state: link
- name: MySQL is started
ansible.builtin.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