Search code examples
mysqlvagrantpuppet

Install mysql with puppet on vagrant vm


I'm trying to install mysql server on a vagrant vm with puppet ,I've added this line on the Vagrant file

config.vm.provision "puppet"

in the same Vagrantfile folder I've created the manifests folder and inside it folder it's default.pp with this content

class { '::mysql::server':
  root_password           => 'root',
  remove_default_accounts => false,
  override_options        => $override_options
}
mysql::db { 'wordpress':
  user     => 'wordpress',
  password => '12345',
  host     => 'localhost',
  grant    => ['ALL'],
}

But I get this error message when I execute vagrant provision

==> default: Running provisioner: puppet...
==> default: Running Puppet with default.pp...
==> default: stdin: is not a tty
==> default: Warning: Setting templatedir is deprecated. See http://links.puppetlabs.com/env-settings-deprecations
==> default:    (at /usr/lib/ruby/vendor_ruby/puppet/settings.rb:1139:in `issue_deprecation_warning')
==> default: Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class ::mysql::server at /tmp/vagrant-puppet/manifests-a11d1078b1b1f2e3bdea27312f6ba513/default.pp:5 on node vagrant-ubuntu-trusty-64.hitronhub.home
==> default: Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class ::mysql::server at /tmp/vagrant-puppet/manifests-a11d1078b1b1f2e3bdea27312f6ba513/default.pp:5 on node vagrant-ubuntu-trusty-64.hitronhub.home
The SSH command responded with a non-zero exit status. Vagrant
assumes that this means the command failed. The output for this command
should be in the log above. Please read the output to determine what
went wrong.

Solution

  • puppetlabs-mysql is a puppet module, which means it is not included with the base puppet executable. To use it, you'll need to do a few things:

    1. Create a modules directory in your project for holding puppet modules
    2. Use puppet module install --modulepath modules puppetlabs-mysql to install the MySQL module into the modules directory
    3. Configure module_path for the puppet provisioner in your Vagrantfile