使用Chef在CentOS 6.5上安装Postgres 9.2

时间:2014-05-19 12:57:29

标签: postgresql centos chef

环境:CentOS 6.5,厨师,Vagrant,Berkshelf

  • 在我的cookbook "postgresql"
  • 中添加了Berksfile
  • 然后$ berks install跟随berks upload将我的食谱上传到托管的Enterprise Chef服务器。
  • 将我的postgresql属性添加到我的食谱my_cookbook/attributes/default.rb

    default['postgresql']['version'] = '9.2'
    
    default['postgresql']['client']['packages'] = ["postgresql#{node['postgresql']['version'].split('.').join}-devel"]
    
    default['postgresql']['server']['packages'] = ["postgresql#{node['postgresql']['version'].split('.').join}-server"]
    
    default['postgresql']['contrib']['packages'] = ["postgresql#{node['postgresql']['version'].split('.').join}-contrib"]
    
    default['postgresql']['dir'] = "/var/lib/pgsql/#{node['postgresql']['version']}/data"
    
    default['postgresql']['server']['service_name'] = "postgresql-#{node['postgresql']['version']}"
    

在我的default.rb食谱中:

include_recipe 'postgresql::yum_pgdg_postgresql'
include_recipe 'postgresql::server'

错误:

Recipe: postgresql::client
  * package[postgresql92-devel] action install
    * No version specified, and no candidate version available for postgresql92-devel
================================================================================
Error executing action `install` on resource 'package[postgresql92-devel]'
================================================================================

1 个答案:

答案 0 :(得分:1)

我通过在attributes/default.rb

中添加一行来解决此问题
default['postgresql']['enable_pgdg_yum'] = true      <==== ADDED THIS
default['postgresql']['version'] = '9.2'
default['postgresql']['client']['packages'] = ["postgresql#{node['postgresql']['version'].split('.').join}-devel"]
default['postgresql']['server']['packages'] = ["postgresql#{node['postgresql']['version'].split('.').join}-server"]
default['postgresql']['contrib']['packages'] = ["postgresql#{node['postgresql']['version'].split('.').join}-contrib"]
default['postgresql']['dir'] = "/var/lib/pgsql/#{node['postgresql']['version']}/data"
default['postgresql']['server']['service_name'] = "postgresql-#{node['postgresql']['version']}"