browbeat/ansible/logs/roles/mysql/tasks/main.yml

31 lines
809 B
YAML

---
- name: Check that mysql is installed
stat:
path: /etc/my.cnf.d/galera.cnf
register: mysql_config
- name: Check if mysql is containerized
shell:
cmd: docker ps | grep mariadb
register: mysql_container
when: mysql_config.stat.exists
ignore_errors: true
- name: Set mysql log location (containerized)
set_fact:
mysql_logs: /var/log/containers/mysql
when: mysql_container.rc == 0 and mysql_config.stat.exists
- name: Check if log folder exists
stat:
path: "{{mysql_logs}}"
register: logs_path
- name: Copy logs to directory on host
synchronize:
src: "{{mysql_logs}}"
dest: /home/{{host_remote_user}}/{{ansible_hostname}}
delegate_to: "{{ inventory_hostname }}"
when: mysql_config.stat.exists and logs_path.stat.isdir is defined and logs_path.stat.isdir