在 vagrant 虚拟机上安装 mysql with puppet

Install mysql with puppet on vagrant vm

我正在尝试在带有 puppet 的 vagrant 虚拟机上安装 mysql 服务器,我在 Vagrant 文件中添加了这一行

config.vm.provision "puppet"

在同一个 Vagrantfile 文件夹中,我创建了 manifests 文件夹,并在其中 default.pp 文件夹中包含此内容

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'],
}

但是我在执行 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.

puppetlabs-mysql 是一个 puppet 模块,这意味着它不包含在基本 puppet 可执行文件中。要使用它,您需要做一些事情:

  1. 在您的项目中创建一个 modules 目录来存放人偶模块
  2. 使用puppet module install --modulepath modules puppetlabs-mysql将MySQL模块安装到模块目录
  3. Configure module_path for the puppet provisioner 在你的 Vagrantfile