I am trying to provision a Vagrant
con machine Puppet
using this mysql module .
It Hola mundo
's simple, it's something like this:
class { '::mysql::server':
root_password => 'strongpassword',
remove_default_accounts => true
}
However, my goal is that after doing Vagrant up
the first time, a machine is built vagrant
with a server mysql
ready to be accessed from the machine host
and accept connections from a defined user.
My attempt is the following:
class { '::mysql::server':
root_password => 'strongpass',
remove_default_accounts => false,
override_options => {
mysqld => { bind-address => '0.0.0.0'} //permitir conexiones entrantes desde cualquier ip
}
}
//crear una base de datos llamada `mydb`, un usuario y asignarle una contraseña
mysql::db { 'mydb':
user => 'admin',
password => 'secret',
host => '192.168.33.1',
}
//asignarle todos los permisos al usuario que acabamos de crear
mysql_grant { '[email protected]/*.*':
ensure => 'present',
options => ['GRANT'],
privileges => ['ALL'],
table => '*.*',
user => '[email protected]',
}
To test that everything works as expected I do my tests like this:
- Destroy the vagrant machine if it already exists:
vagrant destroy
- Create the vagrant machine:
vagrant up
- Try to connect from MySQLWorkbench .
The strange thing is that, when I try to connect, the machine vagrant
does not allow me but if I do a re-provision vagrant reload --provision
then I can already connect and do anything consulta
from MySQLWorkbech
. What am I doing wrong?
I was trying to replicate your problem and ran into a couple of issues apart from the plugin installation which is not as easy (at least on mac) as the documentation says.
The first thing was this ( taken from the module link ):
So in your
class
demysql::server
pon:That should be enough but if you want to be more sure of the order in which the blocks are executed add this in the part
mysql_grant
:That will ensure that this part runs until the previous one has run.
Luck!