I’ve been doing quite a lot of development lately, on various projects, and have been making great use of Vagrant for isolated development. As such, I need to write provisioning scripts so that each machine can be built exactly as the production machine will be. I’ve tried Puppet once but it was far more than what I needed, so I just settled with using a shell script provisioner. Just a basic bash file with a bunch of apt-gets, pips and what not. Most of my projects require a database so MySQL it is. The issue I had was automatically installing MySQL without being asked for a password (as the provisioner is non-interactive). One amazing way I’ve found is issuing these commands before the apt-get (or tasksel) commands to install MySQL

echo "mysql-server mysql-server/root_password select (YOUR PASSWORD)" | sudo debconf-set-selections
echo "mysql-server mysql-server/root_password_again select (YOUR PASSWORD)" | sudo debconf-set-selections