mysql.yml 1.0 KB

12345678910111213141516171819202122232425
  1. - name: Install MySQL server related packages
  2. apt: pkg={{ item }} state=installed update_cache=yes
  3. with_items:
  4. - mysql-server
  5. - mysql-client
  6. when: with_mysql
  7. - name: Install MySQL backup related packages (automysqlbackup)
  8. apt: pkg=automysqlbackup state=installed update_cache=yes
  9. when: with_mysql and with_mysql_backup
  10. - name: Fix automysqlbackup to handle events properly
  11. lineinfile:
  12. dest: /usr/sbin/automysqlbackup
  13. regexp: "^OPT="
  14. line: 'OPT="--quote-names --events" # OPT string for use with mysqldump ( see man mysqldump )'
  15. when: with_mysql and with_mysql_backup
  16. - name: Change MySQL root default password
  17. 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
  18. when: with_mysql and mysql_root_password
  19. - name: Ensure MySQL is running
  20. service: name=mysql state=started
  21. when: with_mysql