Update cookbooks and add wordpress cookbook
This commit is contained in:
6
cookbooks/postgresql/recipes/ca_certificates.rb
Normal file
6
cookbooks/postgresql/recipes/ca_certificates.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
# some older linux distributions have expired certificate bundles
|
||||
# for pgdg repositories. Upgrading this package before trying to
|
||||
# install postgresql is necessary.
|
||||
package "ca-certificates" do
|
||||
action :upgrade
|
||||
end
|
||||
@@ -15,18 +15,23 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
if platform_family?('debian') && node['postgresql']['version'].to_f > 9.3
|
||||
node.default['postgresql']['enable_pgdg_apt'] = true
|
||||
include_recipe "postgresql::ca_certificates"
|
||||
|
||||
case node['platform_family']
|
||||
when 'debian'
|
||||
if node['postgresql']['version'].to_f > 9.3
|
||||
node.set['postgresql']['enable_pgdg_apt'] = true
|
||||
end
|
||||
|
||||
if node['postgresql']['enable_pgdg_apt']
|
||||
include_recipe 'postgresql::apt_pgdg_postgresql'
|
||||
end
|
||||
when 'rhel'
|
||||
if node['postgresql']['enable_pgdg_yum']
|
||||
include_recipe 'postgresql::yum_pgdg_postgresql'
|
||||
end
|
||||
end
|
||||
|
||||
if(node['postgresql']['enable_pgdg_apt']) and platform_family?('debian')
|
||||
include_recipe 'postgresql::apt_pgdg_postgresql'
|
||||
end
|
||||
|
||||
if(node['postgresql']['enable_pgdg_yum']) and platform_family?('rhel')
|
||||
include_recipe 'postgresql::yum_pgdg_postgresql'
|
||||
end
|
||||
|
||||
node['postgresql']['client']['packages'].each do |pg_pack|
|
||||
package pg_pack
|
||||
node['postgresql']['client']['packages'].each do |pkg|
|
||||
package pkg
|
||||
end
|
||||
|
||||
@@ -31,24 +31,50 @@ rescue LoadError
|
||||
|
||||
node.set['build-essential']['compile_time'] = true
|
||||
include_recipe "build-essential"
|
||||
include_recipe "postgresql::client"
|
||||
|
||||
if node['postgresql']['enable_pgdg_yum']
|
||||
repo_rpm_url, repo_rpm_filename, repo_rpm_package = pgdgrepo_rpm_info
|
||||
package "ca-certificates" do
|
||||
action :nothing
|
||||
end.run_action(:upgrade)
|
||||
|
||||
include_recipe "postgresql::yum_pgdg_postgresql"
|
||||
resources("remote_file[#{Chef::Config[:file_cache_path]}/#{repo_rpm_filename}]").run_action(:create)
|
||||
resources("package[#{repo_rpm_package}]").run_action(:install)
|
||||
|
||||
rpm_platform = node['platform']
|
||||
rpm_platform_version = node['platform_version'].to_f.to_i.to_s
|
||||
arch = node['kernel']['machine']
|
||||
|
||||
resources("remote_file[#{Chef::Config[:file_cache_path]}/#{node[:postgresql][:pgdg][:repo_rpm_url][node[:postgresql][:version]][rpm_platform][rpm_platform_version][arch][:package]}]").run_action(:create)
|
||||
resources("package[#{node[:postgresql][:pgdg][:repo_rpm_url][node[:postgresql][:version]][rpm_platform][rpm_platform_version][arch][:package]}]").run_action(:install)
|
||||
|
||||
ENV['PATH'] = "/usr/pgsql-#{node['postgresql']['version']}/bin:#{ENV['PATH']}"
|
||||
|
||||
node['postgresql']['client']['packages'].each do |pkg|
|
||||
package pkg do
|
||||
action :nothing
|
||||
end.run_action(:install)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if node['postgresql']['enable_pgdg_apt']
|
||||
include_recipe "postgresql::apt_pgdg_postgresql"
|
||||
resources("file[remove deprecated Pitti PPA apt repository]").run_action(:delete)
|
||||
resources("apt_repository[apt.postgresql.org]").run_action(:add)
|
||||
|
||||
node['postgresql']['client']['packages'].each do |pkg|
|
||||
package pkg do
|
||||
action :nothing
|
||||
end.run_action(:install)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
node['postgresql']['client']['packages'].each do |pg_pack|
|
||||
resources("package[#{pg_pack}]").run_action(:install)
|
||||
include_recipe "postgresql::client"
|
||||
|
||||
node['postgresql']['client']['packages'].each do |pkg|
|
||||
package pkg do
|
||||
action :nothing
|
||||
end.run_action(:install)
|
||||
end
|
||||
|
||||
begin
|
||||
|
||||
@@ -15,7 +15,9 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
::Chef::Recipe.send(:include, Opscode::OpenSSL::Password)
|
||||
include_recipe "postgresql::ca_certificates"
|
||||
|
||||
::Chef::Recipe.send(:include, OpenSSLCookbook::RandomPassword)
|
||||
|
||||
include_recipe "postgresql::client"
|
||||
|
||||
@@ -42,7 +44,7 @@ else
|
||||
# useful if it weren't saved as clear text in Chef Server for later
|
||||
# retrieval.
|
||||
unless node.key?('postgresql') && node['postgresql'].key?('password') && node['postgresql']['password'].key?('postgres')
|
||||
node.set_unless['postgresql']['password']['postgres'] = secure_password
|
||||
node.set_unless['postgresql']['password']['postgres'] = random_password(length: 20, mode: :base64)
|
||||
node.save
|
||||
end
|
||||
end
|
||||
@@ -50,10 +52,16 @@ end
|
||||
# Include the right "family" recipe for installing the server
|
||||
# since they do things slightly differently.
|
||||
case node['platform_family']
|
||||
when "rhel", "fedora", "suse"
|
||||
when "rhel", "fedora"
|
||||
node.set['postgresql']['dir'] = "/var/lib/pgsql/#{node['postgresql']['version']}/data"
|
||||
node.set['postgresql']['config']['data_directory'] = "/var/lib/pgsql/#{node['postgresql']['version']}/data"
|
||||
include_recipe "postgresql::server_redhat"
|
||||
when "debian"
|
||||
node.set['postgresql']['config']['data_directory'] = "/var/lib/postgresql/#{node['postgresql']['version']}/main"
|
||||
include_recipe "postgresql::server_debian"
|
||||
when 'suse'
|
||||
node.set['postgresql']['config']['data_directory'] = node['postgresql']['dir']
|
||||
include_recipe "postgresql::server_redhat"
|
||||
end
|
||||
|
||||
# Versions prior to 9.2 do not have a config file option to set the SSL
|
||||
@@ -81,7 +89,7 @@ end
|
||||
bash "assign-postgres-password" do
|
||||
user 'postgres'
|
||||
code <<-EOH
|
||||
echo "ALTER ROLE postgres ENCRYPTED PASSWORD '#{node['postgresql']['password']['postgres']}';" | psql -p #{node['postgresql']['config']['port']}
|
||||
echo "ALTER ROLE postgres ENCRYPTED PASSWORD \'#{node['postgresql']['password']['postgres']}\';" | psql -p #{node['postgresql']['config']['port']}
|
||||
EOH
|
||||
action :run
|
||||
not_if "ls #{node['postgresql']['config']['data_directory']}/recovery.conf"
|
||||
|
||||
@@ -17,6 +17,28 @@
|
||||
|
||||
change_notify = node['postgresql']['server']['config_change_notify']
|
||||
|
||||
# There are some configuration items which depend on correctly evaluating the intended version being installed
|
||||
if node['platform_family'] == 'debian'
|
||||
|
||||
node.set['postgresql']['config']['hba_file'] = "/etc/postgresql/#{node['postgresql']['version']}/main/pg_hba.conf"
|
||||
node.set['postgresql']['config']['ident_file'] = "/etc/postgresql/#{node['postgresql']['version']}/main/pg_ident.conf"
|
||||
node.set['postgresql']['config']['external_pid_file'] = "/var/run/postgresql/#{node['postgresql']['version']}-main.pid"
|
||||
|
||||
if node['postgresql']['version'].to_f < 9.3
|
||||
node.set['postgresql']['config']['unix_socket_directory'] = '/var/run/postgresql'
|
||||
else
|
||||
node.set['postgresql']['config']['unix_socket_directories'] = '/var/run/postgresql'
|
||||
end
|
||||
|
||||
node.set['postgresql']['config']['max_fsm_pages'] = 153600 if node['postgresql']['version'].to_f < 8.4
|
||||
|
||||
if node['postgresql']['config']['ssl']
|
||||
node.set['postgresql']['config']['ssl_cert_file'] = '/etc/ssl/certs/ssl-cert-snakeoil.pem' if node['postgresql']['version'].to_f >= 9.2
|
||||
node.set['postgresql']['config']['ssl_key_file'] = '/etc/ssl/private/ssl-cert-snakeoil.key'if node['postgresql']['version'].to_f >= 9.2
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
template "#{node['postgresql']['dir']}/postgresql.conf" do
|
||||
source "postgresql.conf.erb"
|
||||
owner "postgres"
|
||||
|
||||
@@ -18,9 +18,10 @@
|
||||
include_recipe "postgresql::client"
|
||||
|
||||
svc_name = node['postgresql']['server']['service_name']
|
||||
dir = node['postgresql']['dir']
|
||||
initdb_locale = node['postgresql']['initdb_locale']
|
||||
|
||||
shortver = node['postgresql']['version'].split('.').join
|
||||
|
||||
# Create a group and user like the package will.
|
||||
# Otherwise the templates fail.
|
||||
|
||||
@@ -38,7 +39,7 @@ user "postgres" do
|
||||
supports :manage_home => false
|
||||
end
|
||||
|
||||
directory dir do
|
||||
directory node['postgresql']['config']['data_directory'] do
|
||||
owner "postgres"
|
||||
group "postgres"
|
||||
recursive true
|
||||
@@ -51,11 +52,24 @@ node['postgresql']['server']['packages'].each do |pg_pack|
|
||||
|
||||
end
|
||||
|
||||
# Starting with Fedora 16, the pgsql sysconfig files are no longer used.
|
||||
# If using PGDG, add symlinks so that downstream commands all work
|
||||
if node['postgresql']['enable_pgdg_yum'] == true
|
||||
[
|
||||
"postgresql#{shortver}-setup",
|
||||
"postgresql#{shortver}-check-db-dir"
|
||||
].each do |cmd|
|
||||
|
||||
link "/usr/bin/#{cmd}" do
|
||||
to "/usr/pgsql-#{node['postgresql']['version']}/bin/#{cmd}"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
# The systemd unit file does not support 'initdb' or 'upgrade' actions.
|
||||
# Use the postgresql-setup script instead.
|
||||
|
||||
unless platform_family?("fedora") and node['platform_version'].to_i >= 16
|
||||
unless node['postgresql']['server']['init_package'] == 'systemd'
|
||||
|
||||
directory "/etc/sysconfig/pgsql" do
|
||||
mode "0644"
|
||||
@@ -71,30 +85,38 @@ unless platform_family?("fedora") and node['platform_version'].to_i >= 16
|
||||
|
||||
end
|
||||
|
||||
if platform_family?("fedora") and node['platform_version'].to_i >= 16
|
||||
if node['postgresql']['server']['init_package'] == 'systemd'
|
||||
|
||||
execute "postgresql-setup initdb #{svc_name}" do
|
||||
not_if { ::FileTest.exist?(File.join(dir, "PG_VERSION")) }
|
||||
case node['platform_family']
|
||||
when 'suse'
|
||||
execute "initdb -d #{node['postgresql']['dir']}" do
|
||||
user 'postgres'
|
||||
not_if { ::File.exist?("#{node['postgresql']['config']['data_directory']}/PG_VERSION") }
|
||||
end
|
||||
else
|
||||
execute "#{node['postgresql']['setup_script']} initdb #{svc_name}" do
|
||||
not_if { ::File.exist?("#{node['postgresql']['config']['data_directory']}/PG_VERSION") }
|
||||
end
|
||||
end
|
||||
|
||||
elsif platform?("redhat") and node['platform_version'].to_i >= 7
|
||||
|
||||
execute "postgresql#{node['postgresql']['version'].split('.').join}-setup initdb #{svc_name}" do
|
||||
not_if { ::FileTest.exist?(File.join(dir, "PG_VERSION")) }
|
||||
end
|
||||
|
||||
else !platform_family?("suse")
|
||||
elsif (!platform_family?("suse") && node['postgresql']['version'].to_f <= 9.3)
|
||||
|
||||
execute "/sbin/service #{svc_name} initdb #{initdb_locale}" do
|
||||
not_if { ::FileTest.exist?(File.join(dir, "PG_VERSION")) }
|
||||
not_if { ::File.exist?("#{node['postgresql']['config']['data_directory']}/PG_VERSION") }
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
execute "/sbin/service #{svc_name} initdb" do
|
||||
not_if { ::File.exist?("#{node['postgresql']['config']['data_directory']}/PG_VERSION") }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
include_recipe "postgresql::server_conf"
|
||||
|
||||
service "postgresql" do
|
||||
service_name svc_name
|
||||
supports :restart => true, :status => true, :reload => true
|
||||
action [:enable, :start]
|
||||
end
|
||||
|
||||
include_recipe "postgresql::server_conf"
|
||||
|
||||
@@ -15,31 +15,22 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
#######
|
||||
# Load the pgdgrepo_rpm_info method from libraries/default.rb
|
||||
::Chef::Recipe.send(:include, Opscode::PostgresqlHelpers)
|
||||
|
||||
######################################
|
||||
# Install the "PostgreSQL RPM Building Project - Yum Repository" through
|
||||
# the repo_rpm_url determined with pgdgrepo_rpm_info method from
|
||||
# libraries/default.rb. The /etc/yum.repos.d/pgdg-*.repo
|
||||
# will provide postgresql9X packages, but you may need to exclude
|
||||
# postgresql packages from the repository of the distro in order to use
|
||||
# PGDG repository properly. Conflicts will arise if postgresql9X does
|
||||
# appear in your distro's repo and you want a more recent patch level.
|
||||
# Install the "PostgreSQL RPM Building Project - Yum Repository"
|
||||
|
||||
repo_rpm_url, repo_rpm_filename, repo_rpm_package = pgdgrepo_rpm_info
|
||||
rpm_platform = node['platform']
|
||||
rpm_platform_version = node['platform_version'].to_f.to_i.to_s
|
||||
arch = node['kernel']['machine']
|
||||
|
||||
# Download the PGDG repository RPM as a local file
|
||||
remote_file "#{Chef::Config[:file_cache_path]}/#{repo_rpm_filename}" do
|
||||
source repo_rpm_url
|
||||
remote_file "#{Chef::Config[:file_cache_path]}/#{node[:postgresql][:pgdg][:repo_rpm_url][node[:postgresql][:version]][rpm_platform][rpm_platform_version][arch][:package]}" do
|
||||
source "#{node[:postgresql][:pgdg][:repo_rpm_url][node[:postgresql][:version]][rpm_platform][rpm_platform_version][arch][:url]}#{node[:postgresql][:pgdg][:repo_rpm_url][node[:postgresql][:version]][rpm_platform][rpm_platform_version][arch][:package]}"
|
||||
mode "0644"
|
||||
end
|
||||
|
||||
# Install the PGDG repository RPM from the local file
|
||||
# E.g., /etc/yum.repos.d/pgdg-91-centos.repo
|
||||
package repo_rpm_package do
|
||||
package "#{node[:postgresql][:pgdg][:repo_rpm_url][node[:postgresql][:version]][rpm_platform][rpm_platform_version][arch][:package]}" do
|
||||
provider Chef::Provider::Package::Rpm
|
||||
source "#{Chef::Config[:file_cache_path]}/#{repo_rpm_filename}"
|
||||
source "#{Chef::Config[:file_cache_path]}/#{node[:postgresql][:pgdg][:repo_rpm_url][node[:postgresql][:version]][rpm_platform][rpm_platform_version][arch][:package]}"
|
||||
action :install
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user