Преглед изворни кода

Improve MySQL config, make automysqlbackup optional

Emmanuel Bouthenot пре 10 година
родитељ
комит
810b52e2aa

+ 2 - 1
roles/dbserver/defaults/main.yml

@@ -3,6 +3,7 @@
 #
 
 with_mysql: False
-mysql_root_password: ro1234ot
+with_mysql_backup: True
+mysql_root_password: Null
 
 # vim: ft=yaml

+ 0 - 1
roles/dbserver/handlers/main.yml

@@ -1 +0,0 @@
-- include: mysql.yml

+ 0 - 5
roles/dbserver/handlers/mysql.yml

@@ -1,5 +0,0 @@
-- name: Reload mysql
-  service: name=mysql state=reloaded
-
-- name: Restart nginx
-  service: name=mysql state=restarted

+ 10 - 6
roles/dbserver/tasks/mysql.yml

@@ -1,21 +1,25 @@
-- name: Install mysql-server related packages
+- name: Install MySQL server related packages
   apt: pkg={{ item }} state=installed update_cache=yes
   with_items:
     - mysql-server
-    - automysqlbackup
+    - mysql-client
   when: with_mysql
 
+- name: Install MySQL backup related packages (automysqlbackup)
+  apt: pkg=automysqlbackup state=installed update_cache=yes
+  when: with_mysql and with_mysql_backup
+
 - name: Fix automysqlbackup to handle events properly
   lineinfile:
     dest: /usr/sbin/automysqlbackup
     regexp: "^OPT="
     line: 'OPT="--quote-names --events" # OPT string for use with mysqldump ( see man mysqldump )'
-  when: with_mysql
+  when: with_mysql and with_mysql_backup
 
-- name: Change mysql root default password
+- name: Change MySQL root default password
   raw: if ! echo "SELECT VERSION();" | mysql -u root --password='{{ mysql_root_password }}' >/dev/null 2>&1 ; then echo "UPDATE mysql.user SET Password=PASSWORD('{{ mysql_root_password }}') WHERE User IN ('', 'root'); FLUSH PRIVILEGES;" | mysql --defaults-file=/etc/mysql/debian.cnf ; fi
-  when: with_mysql
+  when: with_mysql and mysql_root_password
 
-- name: Ensure mysql-server is running
+- name: Ensure MySQL is running
   service: name=mysql state=started
   when: with_mysql