我正在使用Vagrant,而我正尝试使用puppet配置VM。在Vagrant文件中,我按如下方式配置了VM db:
config.vm.define "db" do |db|
db.vm.hostname = "db"
db.vm.network "private_network", ip: "10.11.1.201", virtualbox__intnet: true
db.vm.provider "virtualbox" do |v|
v.memory = 1024
end
db.vm.network "forwarded_port", guest: 22, host: 2221, id: 'ssh', auto_correct: true
db.vm.network "forwarded_port", guest: 5432, host: 2222
db.ssh.forward_agent = true
config.vm.provision :shell do |shell|
shell.inline = "mkdir -p /etc/puppet/modules;
puppet module install puppetlabs-postgresql"
end
config.vm.provision :puppet do |puppet|
puppet.manifests_path = "puppet/manifests"
puppet.manifest_file = "site.pp"
puppet.module_path = "puppet/modules"
end
end
end
正如您所看到的,我在puppet provisioner运行之前使用vagrant shell命令设置了模块的下载。通过这种方式,我从puppet实验室下载了 puppetlabs-postgresql模块。我不想通过在/puppet/manifests/site.pp中的site.pp文件中创建类来管理我的数据库。我想在/ puppet / modules / database中有一个模块调用数据库。到目前为止我所做的是在/ puppet / modules / database中创建一个init.pp文件。以下是我的init.pp文件的内容:
class database {
class { 'postgresql::server':
ip_mask_allow_all_users => '0.0.0.0/0',
listen_addresses => '*',
ipv4acls => ['hostssl all johndoe 192.168.0.0/24 cert'],
postgres_password => 'TPSrep0rt!',
}
}
然后在我的/puppet/manifests/site.pp文件中,我已经包含了数据库类,如下所示:
node 'db' {
include database
}
"流浪汉"命令我收到错误:
Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class postgresql::server at /tmp/vagrant-puppet/modules-d1208595f982e4ac16b287f9bd398c89/database/manifests/init.pp:8 on node db.lan
==> db: Wrapped exception:
==> db: Could not find declared class postgresql::server
==> db: Error: Puppet::Parser::AST::Resource failed with error ArgumentError: Could not find declared class postgresql::server at /tmp/vagrant-puppet/modules-d1208595f982e4ac16b287f9bd398c89/database/manifests/init.pp:8 on node db.lan
使用postgresql类的正确方法是什么?
答案 0 :(得分:0)
阅读代码是一种奇怪的感觉,尤其是类数据库部分。
可以为puppet模块postgresql
postgresql::server:
ip_mask_allow_all_users: '0.0.0.0/0'
listen_addresses: '*'
ipv4acls:
- 'hostssl all johndoe 192.168.0.0/24 cert'
postgres_password: 'TPSrep0rt!'
节点定义中的,
node 'db' {
include postgresql::server
}
直接管理pp
文件中的要素并不是一种好习惯。