Permalink
Browse files

Merge "[dev_setup] move postgresql into blobstore"

  • Loading branch information...
2 parents 91116e9 + f0085b7 commit 18ddec3665ee793d79dbaaa12892b63e82109d6f Haipeng Wu committed with Gerrit Code Review Aug 19, 2012
@@ -8,13 +8,40 @@
%w{apt-utils build-essential libssl-dev
libxml2 libxml2-dev libxslt1.1 libxslt1-dev git-core sqlite3 libsqlite3-ruby
- libsqlite3-dev unzip zip ruby-dev libmysql-ruby libmysqlclient-dev libcurl4-openssl-dev libpq-dev
+ libsqlite3-dev unzip zip ruby-dev libmysql-ruby libmysqlclient-dev libcurl4-openssl-dev
xulrunner-1.9.2-dev libicu-dev libcurl4-gnutls-dev libtool erlang-dev erlang-eunit erlang-inets erlang-os-mon erlang-xmerl}.each do |p|
package p do
action [:install]
end
end
+machine = node[:kernel][:machine]
+libpq_deb_path = File.join(node[:deployment][:setup_cache], "libpq5_9.2.deb")
+cf_remote_file libpq_deb_path do
+ owner node[:deployment][:user]
+ id node[:postgresql][:id][:libpq]["#{machine}"]
+ checksum node[:postgresql][:checksum][:libpq]["#{machine}"]
+end
+
+libpq_dev_deb_path = File.join(node[:deployment][:setup_cache], "libpq-dev_9.2.deb")
+cf_remote_file libpq_dev_deb_path do
+ owner node[:deployment][:user]
+ id node[:postgresql][:id][:libpq_dev]["#{machine}"]
+ checksum node[:postgresql][:checksum][:libpq_dev]["#{machine}"]
+end
+
+bash "Install libpq" do
+ code <<-EOH
+ dpkg -i #{libpq_deb_path}
+ EOH
+end
+
+bash "Install libpq-dev" do
+ code <<-EOH
+ dpkg -i #{libpq_dev_deb_path}
+ EOH
+end
+
if node[:deployment][:profile]
file node[:deployment][:profile] do
owner node[:deployment][:user]
@@ -32,3 +32,73 @@
default[:postgresql_backup][:cron_file] = "postgresql_backup.cron"
default[:postgresql_worker][:config_file] = "postgresql_worker.yml"
+
+default[:postgresql][:id][:server] = {
+ "8.4" => {
+ "x86_64" => 'eyJzaWciOiIrRCtLdGV2dlBpc3A5ZmR1RlpEZ2R5dmQvWWs9Iiwib2lkIjoi%0ANGU0ZTc4YmNhNTFlMTIyMjA0ZTRlOTg2M2YyOGYzMDUwMmU4NjcyYTExN2Ei%0AfQ==%0A',
+ "i686" => 'eyJzaWciOiJBbEhQODh0aU1TMHYxUWlNcDVTTDdoSldpVlk9Iiwib2lkIjoi%0ANGU0ZTc4YmNhMjFlMTIyMjA0ZTRlOTg2MzkyNmIxMDUwMmU4NzMxN2E2OTAi%0AfQ==%0A'
+ },
+ "9.0" => {
+ "x86_64" => 'eyJzaWciOiI4R2xRVEQ3ZWNzY2VDK0FtS1NKYTN3RXR3aFk9Iiwib2lkIjoi%0ANGU0ZTc4YmNhMjFlMTIxMjA0ZTRlODZlZTE1MWJjMDUwMmU4NjhkNDYwMjUi%0AfQ==%0A',
+ "i686" => 'eyJzaWciOiJjRGl6SXhPMXpKNXUwb1Vva0NqYnV1ZTQvYzA9Iiwib2lkIjoi%0ANGU0ZTc4YmNhMTFlMTIxMjA0ZTRlODZlZTE1Mjk0MDUwMmU4NzNiZWZkZTYi%0AfQ==%0A'
+ }
+}
+
+default[:postgresql][:checksum][:server] = {
+ "8.4" => {
+ "x86_64" => '2fbcdb3e2916524edbf9d53709ecad757c99ab2a160d6a7f07faa897e834f3d9',
+ "i686" => '1fb349481d3995ad51290e7f8e2802253c08f0977258d8c67c7a2cc45ea5846f'
+ },
+ "9.0" => {
+ "x86_64" => '4898a37e2a5c6c4bc8c7f36b427dd027011e6d44f3539dfa1aca1f1601294349',
+ "i686" => 'd8b43aa2583b527a204224b6703b06fe9ba332d07272f54c2ccea1062b9c4617'
+ }
+}
+
+default[:postgresql][:id][:server_common] = 'eyJzaWciOiJGcEZic2RGakRSdW1CaXE4N1NmcDJtSmh5OTQ9Iiwib2lkIjoi%0ANGU0ZTc4YmNhMjFlMTIxMDA0ZTRlN2Q1MTFmNTUzMDUwMmU4NGZiZWNmNTki%0AfQ==%0A'
+default[:postgresql][:checksum][:server_common] = 'cf57380ccecb7bfcdbd1652094011370f6448935743ddf4027776801eefaeefb'
+
+default[:postgresql][:id][:client] = {
+ "8.4" => {
+ "x86_64" => 'eyJzaWciOiJlVXFGUytGZGZCdDJzWHBGWDJFL1oyOXdZSlE9Iiwib2lkIjoi%0ANGU0ZTc4YmNhNjFlMTIyMjA0ZTRlOTg2NDNkOWFlMDUwMmU4NWNkNzZhNGYi%0AfQ==%0A',
+ "i686" => 'eyJzaWciOiJzZmZDd3lwUEY5aDBhbC9UcVpYUVdjZys5bVk9Iiwib2lkIjoi%0ANGU0ZTc4YmNhNjFlMTIyMDA0ZTRlOGVjNmI0NGI2MDUwMmU4ODM5ODY4YmQi%0AfQ==%0A'
+ },
+ "9.0" => {
+ "x86_64" => 'eyJzaWciOiJGT2h4YW9wcE5YdmRNQjdTSlRlVzJWR0xmRUk9Iiwib2lkIjoi%0ANGU0ZTc4YmNhMTFlMTIxMjA0ZTRlODZlZTE1Mjk0MDUwMmU4NWQ3MjFiOGYi%0AfQ==%0A',
+ "i686" => 'eyJzaWciOiJnVEhuZFV1R0M3VERiTzJGcEE4MTgzckFPMEU9Iiwib2lkIjoi%0ANGU0ZTc4YmNhMTFlMTIxMDA0ZTRlN2Q1MTFmODIxMDUwMmU4ODQzMjQ1NTQi%0AfQ==%0A'
+ }
+}
+
+default[:postgresql][:checksum][:client] = {
+ "8.4" => {
+ "x86_64" => '4aef4c70aa9e429b5db517104fb79aa7098765af91847f22cbfd503bb8b96fa5',
+ "i686" => 'ab4825d4d21f6bd2b40376cd77f45b076202947d6e9646809b9495233b7363a0'
+ },
+ "9.0" => {
+ "x86_64" => 'a8e78d95b1cc7308153c95aaeff174d54bdce6f44ec98f5ddc92afbc1c919e31',
+ "i686" => '5d2275621e833f0290259aec1a032493640281db85978b181c08d85a0bf402e0'
+ }
+}
+
+default[:postgresql][:id][:client_common] = 'eyJzaWciOiJET0JEQmpUbUhmNWt2YU82ZlJMTWRFUElNSFE9Iiwib2lkIjoi%0ANGU0ZTc4YmNhMjFlMTIyMjA0ZTRlOTg2MzkyNmIxMDUwMmU4NTU0YzBmOWIi%0AfQ==%0A'
+default[:postgresql][:checksum][:client_common] = 'a2d7a96b8b42ea5d2e39c26a3d13c72f05d8036c96b18399a3dd023b6b99418b'
+
+default[:postgresql][:id][:libpq] = {
+ "x86_64" => 'eyJzaWciOiI2Q21GcmhocWpPaTFocEFhMlp2TFpZVlFOMGM9Iiwib2lkIjoi%0ANGU0ZTc4YmNhNTFlMTIyMDA0ZTRlOGVjNjg0MDc3MDUwMmU4NDc0MzFmMDIi%0AfQ==%0A',
+ "i686" => 'eyJzaWciOiJ0elRjblZhODlxaU9JYjFpNmo3eWpjY0RxNTQ9Iiwib2lkIjoi%0ANGU0ZTc4YmNhMTFlMTIyMDA0ZTRlOGVjNjQ4NDMxMDUwMmU4OTQyZjNiYjQi%0AfQ==%0A'
+}
+
+default[:postgresql][:checksum][:libpq] = {
+ "x86_64" => 'b6a7fe7634c41717757481713b24b0c0d9eeb5937875daea7aba17c7750e3f9e',
+ "i686" => '58943d9d8b657d974271a0022f44d57fb9e2a9863cbf5cd59d84e1f308eef33e'
+}
+
+default[:postgresql][:id][:libpq_dev] = {
+ "x86_64" => 'eyJzaWciOiJGRTVieFBiRFc0Z0hPSDBra2dMTTRpa1luWW89Iiwib2lkIjoi%0ANGU0ZTc4YmNhNTFlMTIyMjA0ZTRlOTg2M2YyOGYzMDUwMmVmZjVjZDdjNDMi%0AfQ==%0A',
+ "i686" => 'eyJzaWciOiIxV0UwMWx3N01BcWpTUW5CdEdBN0xDVW0yTEk9Iiwib2lkIjoi%0ANGU0ZTc4YmNhNDFlMTIxMjA0ZTRlODZlZTUzOTIxMDUwMmVmZjcyMTEwYWYi%0AfQ==%0A'
+}
+
+default[:postgresql][:checksum][:libpq_dev] = {
+ "x86_64" => 'f2153bb1dd36f61fbe0d207c3d62462f6880f802919a9699749719beb64412f4',
+ "i686" => 'a3d25b3a43d3454c07cd2fea026b33d8f64007b6902e5d814d315432d3bc0483'
+}
@@ -20,52 +20,66 @@ def cf_pg_install(pg_major_version, pg_port)
case node['platform']
when "ubuntu"
# install postgresql server & client
- `apt-get install -y python-software-properties`
- `add-apt-repository ppa:pitti/postgresql`
- `apt-get update`
+ machine = node[:kernel][:machine]
+ client_pkg_path = File.join(node[:deployment][:setup_cache], "postgresql-client-#{pg_major_version}.deb")
+ cf_remote_file client_pkg_path do
+ owner node[:deployment][:user]
+ id node[:postgresql][:id][:client]["#{pg_major_version}"]["#{machine}"]
+ checksum node[:postgresql][:checksum][:client]["#{pg_major_version}"]["#{machine}"]
+ end
- postgresql_client_pkg = "postgresql-client-#{pg_major_version}"
- postgresql_pkg = "postgresql-#{pg_major_version}"
+ server_pkg_path = File.join(node[:deployment][:setup_cache], "postgresql-#{pg_major_version}.deb")
+ cf_remote_file server_pkg_path do
+ owner node[:deployment][:user]
+ id node[:postgresql][:id][:server]["#{pg_major_version}"]["#{machine}"]
+ checksum node[:postgresql][:checksum][:server]["#{pg_major_version}"]["#{machine}"]
+ end
- `apt-get install -y #{postgresql_client_pkg}`
- if $?.exitstatus != 0
- Chef::Log.error("Installation of PostgreSQL client package #{postgresql_client_pkg} failed") && (exit 1)
+ bash "Install postgresql client #{pg_major_version}" do
+ code <<-EOH
+ dpkg -i #{client_pkg_path}
+ EOH
end
- `apt-get install -y #{postgresql_pkg}`
- if $?.exitstatus != 0
- Chef::Log.error("Installation of PostgreSQL server package #{postgresql_pkg} failed") && (exit 1)
+ bash "Install postgresql #{pg_major_version}" do
+ code <<-EOH
+ dpkg -i #{server_pkg_path}
+ EOH
end
- # update postgresql.conf
- postgresql_conf_file = File.join("", "etc", "postgresql", pg_major_version, "main", "postgresql.conf")
- Chef::Log.error("Installation of PostgreSQL #{postgresql_pkg} failed, could not find config file #{postgresql_conf_file}") && (exit 1) unless File.exist?(postgresql_conf_file)
+ ruby_block "Update PostgreSQL config" do
+ block do
+ # update postgresql.conf
+ postgresql_conf_file = File.join("", "etc", "postgresql", pg_major_version, "main", "postgresql.conf")
+ Chef::Log.error("Installation of PostgreSQL #{postgresql_pkg} failed, could not find config file #{postgresql_conf_file}") && (exit 1) unless File.exist?(postgresql_conf_file)
- `grep "^\s*listen_addresses" #{postgresql_conf_file}`
- if $?.exitstatus != 0
- `echo "listen_addresses='#{node[:postgresql][:host]},localhost'" >> #{postgresql_conf_file}`
- else
- `sed -i.bkup -e "s/^\s*listen_addresses.*$/listen_addresses='#{node[:postgresql][:host]},localhost'/" #{postgresql_conf_file}`
- end
+ `grep "^\s*listen_addresses" #{postgresql_conf_file}`
+ if $?.exitstatus != 0
+ `echo "listen_addresses='#{node[:postgresql][:host]},localhost'" >> #{postgresql_conf_file}`
+ else
+ `sed -i.bkup -e "s/^\s*listen_addresses.*$/listen_addresses='#{node[:postgresql][:host]},localhost'/" #{postgresql_conf_file}`
+ end
- `grep "^\s*port\s*=\s*\d*" #{postgresql_conf_file}`
- if $?.exitstatus != 0
- `echo "port = #{pg_port}" >> #{postgresql_conf_file}`
- else
- `sed -i.bkup -e "s/^\s*port\s*=\s*.*/port = #{pg_port}/" #{postgresql_conf_file}`
- end
+ `grep "^\s*port\s*=\s*\d*" #{postgresql_conf_file}`
+ if $?.exitstatus != 0
+ `echo "port = #{pg_port}" >> #{postgresql_conf_file}`
+ else
+ `sed -i.bkup -e "s/^\s*port\s*=\s*.*/port = #{pg_port}/" #{postgresql_conf_file}`
+ end
- # restart postgrsql
- init_file = File.join("", "etc", "init.d", "postgresql-#{pg_major_version}")
- backup_init_file = File.join("", "etc", "init.d", "postgresql")
+ # restart postgrsql
+ init_file = File.join("", "etc", "init.d", "postgresql-#{pg_major_version}")
+ backup_init_file = File.join("", "etc", "init.d", "postgresql")
- if File.exists?(init_file)
- Chef::Log.error("Fail to restart postgresql using #{init_file}") && (exit 1) unless system("#{init_file} restart")
- elsif File.exists?(backup_init_file)
- Chef::Log.error("Fail to restart postgresql using #{backup_init_file}") && (exit 1) unless system("#{backup_init_file} restart #{pg_major_version}")
- else
- Chef::Log.error("Installation of PostgreSQL maybe failed, could not find init script")
- exit 1
+ if File.exists?(init_file)
+ Chef::Log.error("Fail to restart postgresql using #{init_file}") && (exit 1) unless system("#{init_file} restart")
+ elsif File.exists?(backup_init_file)
+ Chef::Log.error("Fail to restart postgresql using #{backup_init_file}") && (exit 1) unless system("#{backup_init_file} restart #{pg_major_version}")
+ else
+ Chef::Log.error("Installation of PostgreSQL maybe failed, could not find init script")
+ exit 1
+ end
+ end
end
else
Chef::Log.error("PostgreSQL database setup is not supported on this platform.")
@@ -20,10 +20,36 @@
case node['platform']
when "ubuntu"
- %w[python-software-properties postgresql-common postgresql-client-common libpq-dev].each do |pkg|
+ %w[libc6 libcomerr2 libgssapi-krb5-2 libkrb5-3 libldap-2.4-2 libpam0g libssl0.9.8 libxml2 tzdata ssl-cert locales libedit2 zlib1g].each do |pkg|
package pkg
end
+ client_common_path = File.join(node[:deployment][:setup_cache], "postgresql-client-common_130.deb")
+ cf_remote_file client_common_path do
+ owner node[:deployment][:user]
+ id node[:postgresql][:id][:client_common]
+ checksum node[:postgresql][:checksum][:client_common]
+ end
+
+ server_common_path = File.join(node[:deployment][:setup_cache], "postgresql-common_130.deb")
+ cf_remote_file server_common_path do
+ owner node[:deployment][:user]
+ id node[:postgresql][:id][:server_common]
+ checksum node[:postgresql][:checksum][:server_common]
+ end
+
+ bash "Install postgresql client common" do
+ code <<-EOH
+ dpkg -i #{client_common_path}
+ EOH
+ end
+
+ bash "Install postgresql common" do
+ code <<-EOH
+ dpkg -i #{server_common_path}
+ EOH
+ end
+
else
Chef::Log.error("Installation of PostgreSQL is not supported on this platform.")
end
@@ -4,7 +4,7 @@ def cf_ruby_install(ruby_version, ruby_source_id, ruby_path, ruby_tarball_suffix
bundler_version = node[:rubygems][:bundler][:version]
rake_version = node[:rubygems][:rake][:version]
- %w[ build-essential libssl-dev zlib1g-dev libreadline6-dev libxml2-dev libpq-dev].each do |pkg|
+ %w[ build-essential libssl-dev zlib1g-dev libreadline6-dev libxml2-dev].each do |pkg|
package pkg
end

0 comments on commit 18ddec3

Please sign in to comment.