我正在学习 Puppet,并且运行清单没有任何问题,但是当我向 Puppet 添加模块时,遇到了以下问题:
DEBUG ssh: Exit status: 0 INFO interface: info: Running Puppet with db.pp... INFO interface: info: ==> db: Running Puppet with db.pp... ==> db: Running Puppet with db.pp... DEBUG ssh: Re-using SSH connection. INFO ssh: Execute: puppet apply --verbose --debug --modulepath '/tmp/vagrant-puppet/modules-9f098f5eef3eb89ba69e9481e2fa4839:/etc/puppet/modules' --detailed-exitcodes --manifestdir /tmp/vagrant-puppet/manifests-a11d1078b1b1f2e3bdea27312f6ba513 /tmp/vagrant-puppet/manifests-a11d1078b1b1f2e3bdea27312f6ba513/db.pp (sudo=true) DEBUG ssh: stderr: stdin: is not a tty
INFO interface: info: stdin: is not a tty INFO interface: info: ==> db: stdin: is not a tty ==> db: stdin: is not a tty DEBUG ssh: stdout: warning: Could not retrieve fact fqdn INFO interface: info: warning: Could not retrieve fact fqdn INFO interface: info: ==> db: warning: Could not retrieve fact fqdn ==> db: warning: Could not retrieve fact fqdn DEBUG ssh: stdout:
DEBUG ssh: stderr: Could not find class msql-server for precise32 at /tmp/vagrant-puppet/manifests-a11d1078b1b1f2e3bdea27312f6ba513/db.pp:59 on node precise32 INFO interface: info: Could not find class msql-server for precise32 at /tmp/vagrant-puppet/manifests-a11d1078b1b1f2e3bdea27312f6ba513/db.pp:59 on node precise32 INFO interface: info: ==> db: Could not find class msql-server for precise32 at /tmp/vagrant-puppet/manifests-a11d1078b1b1f2e3bdea27312f6ba513/db.pp:59 on node precise32 ==> db: Could not find class msql-server for precise32 at /tmp/vagrant-puppet/manifests-a11d1078b1b1f2e3bdea27312f6ba513/db.pp:59 on node precise32
显然,Vagrant 没有使用此 vagrant 文件(在 db 机器部分)中描述的模块:
Vagrant.configure(2) do |config|
config.vm.box = "hashicorp/precise32"
config.vm.define :db do |db_config|
db_config.vm.network :private_network,
:ip => "192.168.33.10"
db_config.vm.provision "puppet" do |puppet|
puppet.module_path = "modules"
puppet.manifest_file = "db.pp"
puppet.options = "--verbose --debug"
end
end
config.vm.define :web do |web_config|
web_config.vm.network :private_network,
:ip => "192.168.33.12"
web_config.vm.provision "puppet" do |puppet|
puppet.module_path = "modules"
puppet.manifest_file = "web.pp"
end
end
config.vm.define :monitor do |monitor_config|
monitor_config.vm.network :private_network,
:ip => "192.168.33.14"
end
end
对发生什么事有任何线索吗?
已编辑
我能够弄清楚……这是 Puppet 中的语法问题。但现在我又遇到了另一个问题
::资源失败,错误为 ArgumentError:无效的资源类型 msql::db
资源类型在清单中使用:
include mysql::server
msql::db { "loja": schema => "loja_schema", password => "xxxx", }
定义如下:
define mysql::db($schema, $user = $title, $password) {
#Dependência
Class['mysql::server'] -> Mysql::db[$title]
exec { "$title-schema":
unless => "mysql -uroot $schema",
command => "mysqladmin -uroot create $schema",
path => "/usr/bin/",
}
exec {"$title-user":
unless => "mysql -u$user -p$password $schema",
command => "mysql -uroot -e \"GRANT ALL PRIVILEGES ON \
$schema.* TO '$user'@'%' \
IDENTIFIED BY '$password';\"",
path => "/usr/bin/",
require => Exec["$title-schema"],
}
}
答案1
通过将模块的类包含到 Vagrant 指向的清单文件中,解决了该问题。
例子:
在 manifests/db.pp 中添加:
include <module name>::<class name>