forked from evolix/ansible-roles
2036db938b
Remove the useless call for `cat` as `grep` take a file as it's second argument that tell it to search for the pattern in a specific file instead of whatever is passed to it through stdin. Name both task defining the position of the config directory for self-documentation purposes (and please ansible-lint defaults). Change role description to it's description in the readme instead of the default description asking for the role to be described. Don't compare to empty string, an empty string is already false while a non-empty string is true.
46 lines
1.1 KiB
YAML
46 lines
1.1 KiB
YAML
---
|
|
|
|
- block:
|
|
- name: "Is {{ mysql_custom_datadir }} present ?"
|
|
stat:
|
|
path: "{{ mysql_custom_datadir }}"
|
|
check_mode: no
|
|
register: mysql_custom_datadir_test
|
|
|
|
- name: "read the real datadir"
|
|
command: readlink -f /var/lib/mysql
|
|
changed_when: False
|
|
check_mode: no
|
|
register: mysql_current_real_datadir_test
|
|
tags:
|
|
- mysql
|
|
when: mysql_custom_datadir
|
|
|
|
- block:
|
|
- name: MySQL is stopped
|
|
service:
|
|
name: mysql
|
|
state: stopped
|
|
|
|
- name: Move MySQL datadir to {{ mysql_custom_datadir }}
|
|
command: mv {{ mysql_current_real_datadir_test.stdout }} {{ mysql_custom_datadir }}
|
|
args:
|
|
creates: "{{ mysql_custom_datadir }}"
|
|
|
|
- name: Symlink {{ mysql_custom_datadir }} to /var/lib/mysql
|
|
file:
|
|
src: "{{ mysql_custom_datadir }}"
|
|
dest: '/var/lib/mysql'
|
|
state: link
|
|
|
|
- name: MySQL is started
|
|
service:
|
|
name: mysql
|
|
state: started
|
|
tags:
|
|
- mysql
|
|
when:
|
|
- mysql_custom_datadir
|
|
- mysql_custom_datadir != mysql_current_real_datadir_test.stdout
|
|
- not mysql_custom_datadir_test.stat.exists
|