我通过学习使用木偶和流浪汉让我的生活变得更轻松(我希望)。 我已经知道如何使用Vagrant但是想要进行一个开箱即用的配置。所以我想用Puppet。 我在http://jamesmcfadden.co.uk/using-vagrant-and-puppet-to-build-a-php-nginx-and-mysql-environment/使用了教程,但似乎无法弄清楚如何启动MySQL。
运行Ubuntu 14.04LTS我的init.pp for MySQL是
class mysql {
# Install mysql
package { ['mysql-server']:
ensure => present,
require => Exec['apt-get update'],
}
# Run mysql
service { 'mysql':
ensure => running,
require => Package['mysql-server'],
}
# Use a custom mysql configuration file
file { '/etc/mysql/my.cnf':
source => 'puppet:///modules/mysql/my.cnf',
require => Package['mysql-server'],
notify => Service['mysql'],
}
# We set the root password here
exec { 'set-mysql-password':
unless => 'mysqladmin -uroot -proot status',
command => "mysqladmin -uroot password a9120ed2b58af37862a83f5b9f850819ed08b2a9",
path => ['/bin', '/usr/bin'],
require => Service['mysql'];
}
}
但这给了我一个错误,找不到mysql。
err: /Stage[main]/Mysql/Service[mysql]/ensure: change from stopped to running fa
iled: Could not start Service[mysql]: Execution of '/sbin/start mysql' returned
1: at /tmp/vagrant-puppet-2/modules-0/mysql/manifests/init.pp:13
并将其更改为mysqld(注意'd')此消息已消失,但是有些问题无法找到,无法检查mysql是否正在运行(在将它们更改为'Service ['mysqld之后) ']':
err: /Stage[main]/Mysql/Service[mysqld]: Could not evaluate: Could not find init
script or upstart conf file for 'mysqld'
我做错了吗?
答案 0 :(得分:0)
您的脚本包含以下几行:
require => Exec ['apt-get update'],
,但不要定义“ Exec”。添加以下行:
exec { 'apt-get update':
command => 'sudo apt-get update',
path => ['/bin', '/usr/bin'],
}
以后应该可以正常工作。
答案 1 :(得分:-2)
不要尝试编写自己的MySQL模块。请使用官方支持的puppet MySQ L模块。要安装它,请致电:
puppet module install puppetlabs-mysql
通常,如果您想通过puppet安装/管理某些应用程序,请首先检查puppet forge是否存在专用模块。