--- - name: Install dependencies for mysql database apt: state: present name: - mariadb-server - mariadb-client notify: restart mysql - name: Install ansible dependencies for configuring pip: state: present name: - PyMySQL - meta: flush_handlers - name: Lock root user for localhost mysql_user: user: "root" password: "{{ mysql_root_password }}" host: "localhost" login_unix_socket: /var/run/mysqld/mysqld.sock - name: Remove test users mysql_user: user: "" host_all: yes state: absent login_unix_socket: /var/run/mysqld/mysqld.sock - name: Lock root user for ::1 mysql_user: user: "root" password: "{{ mysql_root_password }}" host: "::1" login_unix_socket: /var/run/mysqld/mysqld.sock - name: Lock root user for 127.0.0.1 mysql_user: user: "root" password: "{{ mysql_root_password }}" host: "127.0.0.1" login_unix_socket: /var/run/mysqld/mysqld.sock - name: Disable public root user access mysql_user: user: "root" host: "{{ inventory_hostname }}" state: absent login_unix_socket: /var/run/mysqld/mysqld.sock - name: Remove mysql test database mysql_db: db: "test" state: absent login_unix_socket: /var/run/mysqld/mysqld.sock - name: Configure innodb of mysql copy: dest: "/etc/mysql/conf.d/innodb.cnf" content: | [mysqld] innodb_large_prefix=ON innodb_file_format=barracuda innodb_file_per_table=ON notify: - restart mysql - name: Configure query cache of mysql template: src: query_cache.cnf dest: "/etc/mysql/mariadb.conf.d/query_cache.cnf" owner: root group: root mode: "u=rw,g=r,o=r" notify: - restart mysql