2014-08-26 15:23:48 +02:00
|
|
|
---
|
|
|
|
- name: Check if MySQL is already installed.
|
|
|
|
stat: path=/etc/init.d/mysql
|
|
|
|
register: mysql_installed
|
|
|
|
|
|
|
|
- name: Update apt cache if MySQL is not yet installed.
|
|
|
|
apt: update_cache=yes
|
|
|
|
when: mysql_installed.stat.exists == false
|
|
|
|
|
2015-08-31 17:22:54 +02:00
|
|
|
- name: Ensure MySQL Python libraries are installed.
|
|
|
|
apt: "name=python-mysqldb state=installed"
|
|
|
|
|
2014-08-26 15:23:48 +02:00
|
|
|
- name: Ensure MySQL packages are installed.
|
2014-11-08 22:10:49 +01:00
|
|
|
apt: "name={{ item }} state=installed"
|
2016-02-29 06:37:00 +01:00
|
|
|
with_items: "{{ mysql_packages }}"
|
2015-10-04 10:21:51 +02:00
|
|
|
register: deb_mysql_install_packages
|
2015-01-13 16:18:27 +01:00
|
|
|
|
|
|
|
# Because Ubuntu starts MySQL as part of the install process, we need to stop
|
|
|
|
# mysql and remove the logfiles in case the user set a custom log file size.
|
|
|
|
- name: Ensure MySQL is stopped after initial install.
|
2016-02-03 20:48:05 +01:00
|
|
|
service: "name={{ mysql_daemon }} state=stopped"
|
2015-01-13 16:18:27 +01:00
|
|
|
when: mysql_installed.stat.exists == false
|
|
|
|
|
|
|
|
- name: Delete innodb log files created by apt package after initial install.
|
|
|
|
shell: "rm -f {{ mysql_datadir }}/ib_logfile[01]"
|
|
|
|
when: mysql_installed.stat.exists == false
|