# Ansible needs python-mysqldb - name: Install MySQL apt: pkg={{item}} state=latest update_cache=false register: ispconfig_install_step1 with_items: - pwgen - mysql-client - mysql-server - python-mysqldb # Requires a system with pwgen, included in our base system - name: Generate MySQL Random Password command: /usr/bin/pwgen -s 16 register: mysql_root_password - name: update mysql root password for all root accounts mysql_user: name=root host={{ item }} password={{mysql_root_password.stdout}} update_password=always state=present with_items: - "{{ inventory_hostname }}" - 127.0.0.1 - ::1 - localhost notify: - Restart MySQL - name: copy my.cnf file with root password credentials to /root/.my.cnf template: src=my.cnf dest=/root/.my.cnf owner=root mode=0600 - name: Configure MySQL to listen on *:3306 replace: dest=/etc/mysql/my.cnf regexp='bind-address' replace='#bind-address'