This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

COOK-286, platform specific version as set_unless for postgresql

  • Loading branch information...
1 parent a459aa1 commit 66b035d9f628371562551a4161f4117ad06993aa @jtimberman jtimberman committed Jun 3, 2010
Showing with 42 additions and 38 deletions.
  1. +23 −2 postgresql/attributes/default.rb
  2. +16 −27 postgresql/metadata.json
  3. +2 −8 postgresql/metadata.rb
  4. +1 −1 postgresql/recipes/server.rb
@@ -17,11 +17,32 @@
# limitations under the License.
#
+set_unless[:postgresql][:version] = value_for_platform(
+ "ubuntu" => {
+ "8.04" => "8.3",
+ "8.10" => "8.3",
+ "9.10" => "8.3",
+ "10.04" => "8.4",
+ "default" => "8.4"
+ },
+ "fedora" => {
+ "10" => "8.3",
+ "11" => "8.3",
+ "12" => "8.3",
+ "13" => "8.4",
+ "14" => "8.4",
+ "default" => "8.4"
+ },
+ ["redhat", "centos"] => {
+ "default" => "8.3"
+ }
+)
+
case platform
when "redhat","centos","fedora","suse"
set[:postgresql][:dir] = "/var/lib/pgsql/data"
when "debian","ubuntu"
- set[:postgresql][:dir] = "/etc/postgresql/8.3/main"
+ set[:postgresql][:dir] = "/etc/postgresql/#{node.postgresql.version}/main"
else
- set[:postgresql][:dir] = "/etc/postgresql/8.3/main"
+ set[:postgresql][:dir] = "/etc/postgresql/#{node.postgresql.version}/main"
end
View
@@ -1,29 +1,17 @@
{
- "maintainer": "Opscode, Inc.",
- "attributes": {
- "postgresql/dir": {
- "default": "/etc/postgresql/8.3/main",
- "calculated": false,
- "type": "string",
- "choice": [
-
- ],
- "description": "Location of the PostgreSQL databases",
- "display_name": "PostgreSQL Directory",
- "required": "optional",
- "recipes": [
-
- ]
- }
+ "replacing": {
},
- "suggestions": {
+ "attributes": {
},
"platforms": {
"ubuntu": [
],
"rhel": [
+ ],
+ "fedora": [
+
],
"centos": [
@@ -32,26 +20,27 @@
]
},
+ "groupings": {
+ },
"dependencies": {
},
- "maintainer_email": "cookbooks@opscode.com",
- "conflicting": {
+ "long_description": "= DESCRIPTION:\n\nInstalls and configures postgresql client or server.\n\n= REQUIREMENTS:\n\n== Platform:\n\nTested on Ubuntu 8.10, but adapted from Red Hat Enterprise 5.0 based recipes.\n\n== Cookbooks:\n\n= ATTRIBUTES: \n\n* postgresql[:dir] - configuration file location.\n\n= USAGE:\n\nFor clients:\n\n include_recipe \"postgresql::client\"\n \nFor server: \n\n include_recipe \"postgresql::server\"\n \n(client is already included by server)\n\n= LICENSE and AUTHOR:\n \nAuthor:: Joshua Timberman (<joshua@opscode.com>)\n\nCopyright:: 2009, Opscode, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n",
+ "recommendations": {
},
- "version": "0.8.0",
+ "version": "0.9.0",
+ "maintainer": "Opscode, Inc.",
"name": "postgresql",
+ "suggestions": {
+ },
"recipes": {
"postgresql::server": "Installs postgresql server packages, templates",
"postgresql::client": "Installs postgresql client package(s)"
},
- "providing": {
- },
"license": "Apache 2.0",
- "replacing": {
- },
- "groupings": {
+ "maintainer_email": "cookbooks@opscode.com",
+ "conflicting": {
},
- "long_description": "= DESCRIPTION:\n\nInstalls and configures postgresql client or server.\n\n= REQUIREMENTS:\n\n== Platform:\n\nTested on Ubuntu 8.10, but adapted from Red Hat Enterprise 5.0 based recipes.\n\n== Cookbooks:\n\n= ATTRIBUTES: \n\n* postgresql[:dir] - configuration file location.\n\n= USAGE:\n\nFor clients:\n\n include_recipe \"postgresql::client\"\n \nFor server: \n\n include_recipe \"postgresql::server\"\n \n(client is already included by server)\n\n= LICENSE and AUTHOR:\n \nAuthor:: Joshua Timberman (<joshua@opscode.com>)\n\nCopyright:: 2009, Opscode, Inc\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n",
- "recommendations": {
+ "providing": {
},
"description": "Installs and configures postgresql for clients or servers"
}
View
@@ -3,16 +3,10 @@
license "Apache 2.0"
description "Installs and configures postgresql for clients or servers"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
-version "0.8"
+version "0.9"
recipe "postgresql::client", "Installs postgresql client package(s)"
recipe "postgresql::server", "Installs postgresql server packages, templates"
-%w{rhel centos ubuntu debian}.each do |os|
+%w{rhel centos fedora ubuntu debian}.each do |os|
supports os
end
-
-attribute "postgresql/dir",
- :display_name => "PostgreSQL Directory",
- :description => "Location of the PostgreSQL databases",
- :default => "/etc/postgresql/8.3/main"
-
@@ -24,7 +24,7 @@
service "postgresql" do
case node[:platform]
when "debian","ubuntu"
- service_name "postgresql-8.3"
+ service_name "postgresql-#{node.postgresql.version}"
@thewoolleyman

thewoolleyman Jun 23, 2010

Contributor

What is this syntax of 'node.postgresql.version'? It is causing a syntax error under chef-solo 0.9.0.rc02. Why isn't it node[:postgresql][:version]?

DEBUG: Executing /etc/init.d/postgresql-#Chef::Node::Attribute:0x7f7d86bfbcf0 status
DEBUG: ---- Begin output of /etc/init.d/postgresql-#Chef::Node::Attribute:0x7f7d86bfbcf0 status ----
DEBUG: STDOUT:
DEBUG: STDERR: sh: cannot open Chef::Node::Attribute:0x7f7d86bfbcf0: No such file
DEBUG: ---- End output of /etc/init.d/postgresql-#Chef::Node::Attribute:0x7f7d86bfbcf0 status ----
DEBUG: Ran /etc/init.d/postgresql-#Chef::Node::Attribute:0x7f7d86bfbcf0 status returned 2
ERROR: service[postgresql](/home/ubuntu/chef/railsci_chef_repo/cookbooks/opscode/postgresql/recipes/server.rb line 24) had an error:
/usr/sbin/update-rc.d -n -f postgresql-#Chef::Node::Attribute:0x7f7d86bfbcf0 failed - #<Process::Status: pid=12280,exited(2)>
/home/ubuntu/.rvm/gems/ruby-1.8.7-p174/gems/chef-0.9.0.rc02/bin/../lib/chef/provider/service/debian.rb:60:in service_currently_enabled?' /home/ubuntu/.rvm/gems/ruby-1.8.7-p174/gems/chef-0.9.0.rc02/bin/../lib/chef/provider/service/debian.rb:32:inload_current_resource'

@thewoolleyman

thewoolleyman Jun 23, 2010

Contributor

looks like the root cause is the use of value_for_platform in the attributes default file...

@jtimberman

jtimberman Jun 23, 2010

Contributor

Ah, indeed. This is open ticket:

http://tickets.opscode.com/browse/CHEF-520

If you would, please open a ticket in the JIRA COOK project.

end
supports :restart => true, :status => true, :reload => true
action :nothing

0 comments on commit 66b035d

Please sign in to comment.