mysql.yml 818 B

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