Last Updated: February 25, 2016
·
858
· catdev

MySQL server installation with custom password in Ansible

When using Ansible for your provisioning your Vagrant, it can error due to MySQL prompting you for a password. The following Ansible code will allow you to automatically set the MySQL password during provisioning.

- name: Mysql | Set root password
  shell: mysql-server-5.5 mysql-server/root_password password password | debconf-set-selections
  tags: needed

- name: Mysql | Set root repassword again
  shell: mysql-server-5.5 mysql-server/root_password_again password password | debconf-set-selections
  tags: needed

- name: Installing MySQL
  action: apt pkg=mysql-server state=latest
  tags: needed

Did this help? Follow me on twitter @ ItsCatDev