【问题标题】:Puppet PostgresQL management, Error: Puppet::Parser::AST::Puppet PostgresQL 管理,错误:Puppet::Parser::AST::
【发布时间】:2016-09-06 02:04:40
【问题描述】:

我正在使用 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 配置程序运行之前使用 vagrant shell 命令设置了模块的下载。通过这种方式,我从 puppet labs 下载了 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
}

在“vagrant up”命令之后出现错误:

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 类的正确方法是什么?

【问题讨论】:

  • 你能找到你的 /puppet/modules/database 目录吗?

标签: postgresql vagrant puppet provisioning


【解决方案1】:

阅读您的代码感觉很奇怪,尤其是类数据库部分。

你可以为puppet模块设置hieradata模板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 文件中的因子不是一个好习惯。

【讨论】:

  • 我不知道在哪里放置 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!'
猜你喜欢
  • 2016-04-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-29
相关资源
最近更新 更多