from-scratch 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Berksfile.lock +11 -0
  4. data/chefignore +1 -0
  5. data/cookbooks/apt/CHANGELOG.md +248 -0
  6. data/cookbooks/apt/README.md +294 -0
  7. data/cookbooks/apt/attributes/default.rb +51 -0
  8. data/cookbooks/apt/files/default/15update-stamp +1 -0
  9. data/cookbooks/apt/files/default/apt-proxy-v2.conf +50 -0
  10. data/cookbooks/apt/libraries/helpers.rb +61 -0
  11. data/cookbooks/apt/libraries/matchers.rb +17 -0
  12. data/cookbooks/apt/libraries/network.rb +31 -0
  13. data/cookbooks/apt/metadata.json +1 -0
  14. data/cookbooks/apt/providers/preference.rb +84 -0
  15. data/cookbooks/apt/providers/repository.rb +246 -0
  16. data/cookbooks/apt/recipes/cacher-client.rb +83 -0
  17. data/cookbooks/apt/recipes/cacher-ng.rb +43 -0
  18. data/cookbooks/apt/recipes/default.rb +112 -0
  19. data/cookbooks/apt/recipes/unattended-upgrades.rb +47 -0
  20. data/cookbooks/apt/resources/preference.rb +37 -0
  21. data/cookbooks/apt/resources/repository.rb +60 -0
  22. data/cookbooks/apt/templates/debian-6.0/acng.conf.erb +173 -0
  23. data/cookbooks/apt/templates/default/01proxy.erb +9 -0
  24. data/cookbooks/apt/templates/default/10recommends.erb +3 -0
  25. data/cookbooks/apt/templates/default/20auto-upgrades.erb +2 -0
  26. data/cookbooks/apt/templates/default/50unattended-upgrades.erb +68 -0
  27. data/cookbooks/apt/templates/default/acng.conf.erb +275 -0
  28. data/cookbooks/apt/templates/default/unattended-upgrades.seed.erb +1 -0
  29. data/cookbooks/apt/templates/ubuntu-10.04/acng.conf.erb +269 -0
  30. data/cookbooks/build-essential/CHANGELOG.md +136 -0
  31. data/cookbooks/build-essential/README.md +108 -0
  32. data/cookbooks/build-essential/attributes/default.rb +20 -0
  33. data/cookbooks/build-essential/libraries/matchers.rb +5 -0
  34. data/cookbooks/build-essential/libraries/timing.rb +124 -0
  35. data/cookbooks/build-essential/libraries/xcode_command_line_tools.rb +210 -0
  36. data/cookbooks/build-essential/metadata.json +1 -0
  37. data/cookbooks/build-essential/recipes/_debian.rb +28 -0
  38. data/cookbooks/build-essential/recipes/_fedora.rb +32 -0
  39. data/cookbooks/build-essential/recipes/_freebsd.rb +24 -0
  40. data/cookbooks/build-essential/recipes/_mac_os_x.rb +22 -0
  41. data/cookbooks/build-essential/recipes/_omnios.rb +33 -0
  42. data/cookbooks/build-essential/recipes/_rhel.rb +36 -0
  43. data/cookbooks/build-essential/recipes/_smartos.rb +27 -0
  44. data/cookbooks/build-essential/recipes/_solaris2.rb +48 -0
  45. data/cookbooks/build-essential/recipes/_suse.rb +29 -0
  46. data/cookbooks/build-essential/recipes/default.rb +29 -0
  47. data/cookbooks/chef-sugar/CHANGELOG.md +159 -0
  48. data/cookbooks/chef-sugar/README.md +464 -0
  49. data/cookbooks/chef-sugar/metadata.json +1 -0
  50. data/cookbooks/chef-sugar/recipes/default.rb +34 -0
  51. data/cookbooks/openssl/CHANGELOG.md +30 -0
  52. data/cookbooks/openssl/README.md +115 -0
  53. data/cookbooks/openssl/attributes/default.rb +21 -0
  54. data/cookbooks/openssl/libraries/secure_password.rb +37 -0
  55. data/cookbooks/openssl/metadata.json +31 -0
  56. data/cookbooks/openssl/providers/x509.rb +94 -0
  57. data/cookbooks/openssl/recipes/default.rb +18 -0
  58. data/cookbooks/openssl/recipes/upgrade.rb +39 -0
  59. data/cookbooks/openssl/resources/x509.rb +16 -0
  60. data/cookbooks/postgresql/CHANGELOG.md +220 -0
  61. data/cookbooks/postgresql/README.md +464 -0
  62. data/cookbooks/postgresql/attributes/default.rb +549 -0
  63. data/cookbooks/postgresql/files/default/tests/minitest/apt_pgdg_postgresql_test.rb +39 -0
  64. data/cookbooks/postgresql/files/default/tests/minitest/default_test.rb +27 -0
  65. data/cookbooks/postgresql/files/default/tests/minitest/ruby_test.rb +28 -0
  66. data/cookbooks/postgresql/files/default/tests/minitest/server_test.rb +43 -0
  67. data/cookbooks/postgresql/files/default/tests/minitest/support/helpers.rb +29 -0
  68. data/cookbooks/postgresql/libraries/default.rb +377 -0
  69. data/cookbooks/postgresql/metadata.json +56 -0
  70. data/cookbooks/postgresql/recipes/apt_pgdg_postgresql.rb +18 -0
  71. data/cookbooks/postgresql/recipes/client.rb +32 -0
  72. data/cookbooks/postgresql/recipes/config_initdb.rb +148 -0
  73. data/cookbooks/postgresql/recipes/config_pgtune.rb +284 -0
  74. data/cookbooks/postgresql/recipes/contrib.rb +44 -0
  75. data/cookbooks/postgresql/recipes/default.rb +18 -0
  76. data/cookbooks/postgresql/recipes/ruby.rb +117 -0
  77. data/cookbooks/postgresql/recipes/server.rb +89 -0
  78. data/cookbooks/postgresql/recipes/server_conf.rb +34 -0
  79. data/cookbooks/postgresql/recipes/server_debian.rb +38 -0
  80. data/cookbooks/postgresql/recipes/server_redhat.rb +100 -0
  81. data/cookbooks/postgresql/recipes/yum_pgdg_postgresql.rb +45 -0
  82. data/cookbooks/postgresql/templates/default/pg_hba.conf.erb +35 -0
  83. data/cookbooks/postgresql/templates/default/pgsql.sysconfig.erb +4 -0
  84. data/cookbooks/postgresql/templates/default/postgresql.conf.erb +21 -0
  85. data/cookbooks/scratchify/.chef/knife.rb +2 -5
  86. data/cookbooks/scratchify/Berksfile +2 -1
  87. data/cookbooks/scratchify/Berksfile.lock +11 -0
  88. data/cookbooks/scratchify/README.md +34 -17
  89. data/cookbooks/scratchify/bin/scratchify +1 -1
  90. data/cookbooks/scratchify/chefignore +1 -0
  91. data/cookbooks/scratchify/from-scratch.gemspec +2 -5
  92. data/cookbooks/scratchify/lib/from-scratch.rb +25 -0
  93. data/cookbooks/scratchify/lib/{from/scratch → from-scratch}/version.rb +1 -1
  94. data/cookbooks/scratchify/metadata.json +2 -1
  95. data/cookbooks/scratchify/templates/node.json.erb +34 -0
  96. data/cookbooks/scratchify/templates/user.json.erb +6 -0
  97. data/lib/from-scratch.rb +2 -2
  98. data/lib/from-scratch/version.rb +1 -1
  99. data/templates/node.json.erb +6 -3
  100. metadata +85 -10
  101. data/cookbooks/scratchify/bin/console +0 -14
  102. data/cookbooks/scratchify/bin/setup +0 -7
  103. data/cookbooks/scratchify/data_bags/users/deploy.json +0 -6
  104. data/cookbooks/scratchify/environments/.gitkeep +0 -0
  105. data/cookbooks/scratchify/lib/from/scratch.rb +0 -31
  106. data/cookbooks/scratchify/lib/from/scratch/interviewer.rb +0 -35
  107. data/cookbooks/scratchify/nodes/normfood.ru.json +0 -75
  108. data/cookbooks/scratchify/roles/.gitkeep +0 -0
@@ -0,0 +1,44 @@
1
+ #
2
+ # Cookbook Name:: postgresql
3
+ # Recipe:: contrib
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ db_name = node['postgresql']['database_name']
19
+
20
+ # Install the PostgreSQL contrib package(s) from the distribution,
21
+ # as specified by the node attributes.
22
+ node['postgresql']['contrib']['packages'].each do |pg_pack|
23
+
24
+ package pg_pack
25
+
26
+ end
27
+
28
+ include_recipe "postgresql::server"
29
+
30
+ # Install PostgreSQL contrib extentions into the database, as specified by the
31
+ # node attribute node['postgresql']['database_name'].
32
+ if (node['postgresql']['contrib'].attribute?('extensions'))
33
+ node['postgresql']['contrib']['extensions'].each do |pg_ext|
34
+ bash "install-#{pg_ext}-extension" do
35
+ user 'postgres'
36
+ code <<-EOH
37
+ echo 'CREATE EXTENSION IF NOT EXISTS "#{pg_ext}";' | psql -d "#{db_name}"
38
+ EOH
39
+ action :run
40
+ ::Chef::Resource.send(:include, Opscode::PostgresqlHelpers)
41
+ not_if {extension_installed?(pg_ext)}
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,18 @@
1
+ #
2
+ # Cookbook Name:: postgresql
3
+ # Recipe:: default
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ include_recipe "postgresql::client"
@@ -0,0 +1,117 @@
1
+ #
2
+ # Cookbook Name:: postgresql
3
+ # Recipe:: ruby
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ # Load the pgdgrepo_rpm_info method from libraries/default.rb
19
+ ::Chef::Recipe.send(:include, Opscode::PostgresqlHelpers)
20
+
21
+ begin
22
+ require 'pg'
23
+ rescue LoadError
24
+
25
+ if platform_family?('ubuntu', 'debian')
26
+ e = execute 'apt-get update' do
27
+ action :nothing
28
+ end
29
+ e.run_action(:run) unless ::File.exists?('/var/lib/apt/periodic/update-success-stamp')
30
+ end
31
+
32
+ node.set['build-essential']['compile_time'] = true
33
+ include_recipe "build-essential"
34
+ include_recipe "postgresql::client"
35
+
36
+ if node['postgresql']['enable_pgdg_yum']
37
+ repo_rpm_url, repo_rpm_filename, repo_rpm_package = pgdgrepo_rpm_info
38
+ include_recipe "postgresql::yum_pgdg_postgresql"
39
+ resources("remote_file[#{Chef::Config[:file_cache_path]}/#{repo_rpm_filename}]").run_action(:create)
40
+ resources("package[#{repo_rpm_package}]").run_action(:install)
41
+ ENV['PATH'] = "/usr/pgsql-#{node['postgresql']['version']}/bin:#{ENV['PATH']}"
42
+ end
43
+
44
+ if node['postgresql']['enable_pgdg_apt']
45
+ include_recipe "postgresql::apt_pgdg_postgresql"
46
+ resources("file[remove deprecated Pitti PPA apt repository]").run_action(:delete)
47
+ resources("apt_repository[apt.postgresql.org]").run_action(:add)
48
+ end
49
+
50
+ node['postgresql']['client']['packages'].each do |pg_pack|
51
+ resources("package[#{pg_pack}]").run_action(:install)
52
+ end
53
+
54
+ begin
55
+ chef_gem "pg"
56
+ rescue Gem::Installer::ExtensionBuildError, Mixlib::ShellOut::ShellCommandFailed => e
57
+ # Are we an omnibus install?
58
+ raise if RbConfig.ruby.scan(%r{(chef|opscode)}).empty?
59
+ # Still here, must be omnibus. Lets make this thing install!
60
+ Chef::Log.warn 'Failed to properly build pg gem. Forcing properly linking and retrying (omnibus fix)'
61
+ gem_dir = e.message.scan(%r{will remain installed in ([^ ]+)}).flatten.first
62
+ raise unless gem_dir
63
+ gem_name = File.basename(gem_dir)
64
+ ext_dir = File.join(gem_dir, 'ext')
65
+ gem_exec = File.join(File.dirname(RbConfig.ruby), 'gem')
66
+ new_content = <<-EOS
67
+ require 'rbconfig'
68
+ %w(
69
+ configure_args
70
+ LIBRUBYARG_SHARED
71
+ LIBRUBYARG_STATIC
72
+ LIBRUBYARG
73
+ LDFLAGS
74
+ ).each do |key|
75
+ RbConfig::CONFIG[key].gsub!(/-Wl[^ ]+( ?\\/[^ ]+)?/, '')
76
+ RbConfig::MAKEFILE_CONFIG[key].gsub!(/-Wl[^ ]+( ?\\/[^ ]+)?/, '')
77
+ end
78
+ RbConfig::CONFIG['RPATHFLAG'] = ''
79
+ RbConfig::MAKEFILE_CONFIG['RPATHFLAG'] = ''
80
+ EOS
81
+ new_content << File.read(extconf_path = File.join(ext_dir, 'extconf.rb'))
82
+ File.open(extconf_path, 'w') do |file|
83
+ file.write(new_content)
84
+ end
85
+
86
+ lib_builder = execute 'generate pg gem Makefile' do
87
+ # [COOK-3490] pg gem install requires full path on RHEL
88
+ command "PATH=$PATH:/usr/pgsql-#{node['postgresql']['version']}/bin #{RbConfig.ruby} extconf.rb"
89
+ cwd ext_dir
90
+ action :nothing
91
+ end
92
+ lib_builder.run_action(:run)
93
+
94
+ lib_maker = execute 'make pg gem lib' do
95
+ command 'make'
96
+ cwd ext_dir
97
+ action :nothing
98
+ end
99
+ lib_maker.run_action(:run)
100
+
101
+ lib_installer = execute 'install pg gem lib' do
102
+ command 'make install'
103
+ cwd ext_dir
104
+ action :nothing
105
+ end
106
+ lib_installer.run_action(:run)
107
+
108
+ spec_installer = execute 'install pg spec' do
109
+ command "#{gem_exec} spec ./cache/#{gem_name}.gem --ruby > ./specifications/#{gem_name}.gemspec"
110
+ cwd File.join(gem_dir, '..', '..')
111
+ action :nothing
112
+ end
113
+ spec_installer.run_action(:run)
114
+
115
+ Chef::Log.warn 'Installation of pg gem successful!'
116
+ end
117
+ end
@@ -0,0 +1,89 @@
1
+ #
2
+ # Cookbook Name:: postgresql
3
+ # Recipe:: server
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ ::Chef::Recipe.send(:include, Opscode::OpenSSL::Password)
19
+
20
+ include_recipe "postgresql::client"
21
+
22
+ # randomly generate postgres password, unless using solo - see README
23
+ if Chef::Config[:solo]
24
+ missing_attrs = %w{
25
+ postgres
26
+ }.select do |attr|
27
+ node['postgresql']['password'][attr].nil?
28
+ end.map { |attr| "node['postgresql']['password']['#{attr}']" }
29
+
30
+ if !missing_attrs.empty?
31
+ Chef::Log.fatal([
32
+ "You must set #{missing_attrs.join(', ')} in chef-solo mode.",
33
+ "For more information, see https://github.com/opscode-cookbooks/postgresql#chef-solo-note"
34
+ ].join(' '))
35
+ raise
36
+ end
37
+ else
38
+ # TODO: The "secure_password" is randomly generated plain text, so it
39
+ # should be converted to a PostgreSQL specific "encrypted password" if
40
+ # it should actually install a password (as opposed to disable password
41
+ # login for user 'postgres'). However, a random password wouldn't be
42
+ # useful if it weren't saved as clear text in Chef Server for later
43
+ # retrieval.
44
+ unless node.key?('postgresql') && node['postgresql'].key?('password') && node['postgresql']['password'].key?('postgres')
45
+ node.set_unless['postgresql']['password']['postgres'] = secure_password
46
+ node.save
47
+ end
48
+ end
49
+
50
+ # Include the right "family" recipe for installing the server
51
+ # since they do things slightly differently.
52
+ case node['platform_family']
53
+ when "rhel", "fedora", "suse"
54
+ include_recipe "postgresql::server_redhat"
55
+ when "debian"
56
+ include_recipe "postgresql::server_debian"
57
+ end
58
+
59
+ # Versions prior to 9.2 do not have a config file option to set the SSL
60
+ # key and cert path, and instead expect them to be in a specific location.
61
+ if node['postgresql']['version'].to_f < 9.2 && node['postgresql']['config'].attribute?('ssl_cert_file')
62
+ link ::File.join(node['postgresql']['config']['data_directory'], 'server.crt') do
63
+ to node['postgresql']['config']['ssl_cert_file']
64
+ end
65
+ end
66
+
67
+ if node['postgresql']['version'].to_f < 9.2 && node['postgresql']['config'].attribute?('ssl_key_file')
68
+ link ::File.join(node['postgresql']['config']['data_directory'], 'server.key') do
69
+ to node['postgresql']['config']['ssl_key_file']
70
+ end
71
+ end
72
+
73
+ # NOTE: Consider two facts before modifying "assign-postgres-password":
74
+ # (1) Passing the "ALTER ROLE ..." through the psql command only works
75
+ # if passwordless authorization was configured for local connections.
76
+ # For example, if pg_hba.conf has a "local all postgres ident" rule.
77
+ # (2) It is probably fruitless to optimize this with a not_if to avoid
78
+ # setting the same password. This chef recipe doesn't have access to
79
+ # the plain text password, and testing the encrypted (md5 digest)
80
+ # version is not straight-forward.
81
+ bash "assign-postgres-password" do
82
+ user 'postgres'
83
+ code <<-EOH
84
+ echo "ALTER ROLE postgres ENCRYPTED PASSWORD '#{node['postgresql']['password']['postgres']}';" | psql -p #{node['postgresql']['config']['port']}
85
+ EOH
86
+ action :run
87
+ not_if "ls #{node['postgresql']['config']['data_directory']}/recovery.conf"
88
+ only_if { node['postgresql']['assign_postgres_password'] }
89
+ end
@@ -0,0 +1,34 @@
1
+ #
2
+ # Cookbook Name:: postgresql
3
+ # Recipe:: server
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ change_notify = node['postgresql']['server']['config_change_notify']
19
+
20
+ template "#{node['postgresql']['dir']}/postgresql.conf" do
21
+ source "postgresql.conf.erb"
22
+ owner "postgres"
23
+ group "postgres"
24
+ mode 0600
25
+ notifies change_notify, 'service[postgresql]', :immediately
26
+ end
27
+
28
+ template "#{node['postgresql']['dir']}/pg_hba.conf" do
29
+ source "pg_hba.conf.erb"
30
+ owner "postgres"
31
+ group "postgres"
32
+ mode 00600
33
+ notifies change_notify, 'service[postgresql]', :immediately
34
+ end
@@ -0,0 +1,38 @@
1
+ #
2
+ # Cookbook Name:: postgresql
3
+ # Recipe:: server
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ include_recipe "postgresql::client"
19
+
20
+ node['postgresql']['server']['packages'].each do |pg_pack|
21
+
22
+ package pg_pack
23
+
24
+ end
25
+
26
+ include_recipe "postgresql::server_conf"
27
+
28
+ service "postgresql" do
29
+ service_name node['postgresql']['server']['service_name']
30
+ supports :restart => true, :status => true, :reload => true
31
+ action [:enable, :start]
32
+ end
33
+
34
+ execute 'Set locale and Create cluster' do
35
+ command 'export LC_ALL=C; /usr/bin/pg_createcluster --start ' + node['postgresql']['version'] + ' main'
36
+ action :run
37
+ not_if { ::File.directory?('/etc/postgresql/' + node['postgresql']['version'] + '/main') }
38
+ end
@@ -0,0 +1,100 @@
1
+ #
2
+ # Cookbook Name:: postgresql
3
+ # Recipe:: server
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+ include_recipe "postgresql::client"
19
+
20
+ svc_name = node['postgresql']['server']['service_name']
21
+ dir = node['postgresql']['dir']
22
+ initdb_locale = node['postgresql']['initdb_locale']
23
+
24
+ # Create a group and user like the package will.
25
+ # Otherwise the templates fail.
26
+
27
+ group "postgres" do
28
+ gid 26
29
+ end
30
+
31
+ user "postgres" do
32
+ shell "/bin/bash"
33
+ comment "PostgreSQL Server"
34
+ home "/var/lib/pgsql"
35
+ gid "postgres"
36
+ system true
37
+ uid 26
38
+ supports :manage_home => false
39
+ end
40
+
41
+ directory dir do
42
+ owner "postgres"
43
+ group "postgres"
44
+ recursive true
45
+ action :create
46
+ end
47
+
48
+ node['postgresql']['server']['packages'].each do |pg_pack|
49
+
50
+ package pg_pack
51
+
52
+ end
53
+
54
+ # Starting with Fedora 16, the pgsql sysconfig files are no longer used.
55
+ # The systemd unit file does not support 'initdb' or 'upgrade' actions.
56
+ # Use the postgresql-setup script instead.
57
+
58
+ unless platform_family?("fedora") and node['platform_version'].to_i >= 16
59
+
60
+ directory "/etc/sysconfig/pgsql" do
61
+ mode "0644"
62
+ recursive true
63
+ action :create
64
+ end
65
+
66
+ template "/etc/sysconfig/pgsql/#{svc_name}" do
67
+ source "pgsql.sysconfig.erb"
68
+ mode "0644"
69
+ notifies :restart, "service[postgresql]", :delayed
70
+ end
71
+
72
+ end
73
+
74
+ if platform_family?("fedora") and node['platform_version'].to_i >= 16
75
+
76
+ execute "postgresql-setup initdb #{svc_name}" do
77
+ not_if { ::FileTest.exist?(File.join(dir, "PG_VERSION")) }
78
+ end
79
+
80
+ elsif platform?("redhat") and node['platform_version'].to_i >= 7
81
+
82
+ execute "postgresql#{node['postgresql']['version'].split('.').join}-setup initdb #{svc_name}" do
83
+ not_if { ::FileTest.exist?(File.join(dir, "PG_VERSION")) }
84
+ end
85
+
86
+ else !platform_family?("suse")
87
+
88
+ execute "/sbin/service #{svc_name} initdb #{initdb_locale}" do
89
+ not_if { ::FileTest.exist?(File.join(dir, "PG_VERSION")) }
90
+ end
91
+
92
+ end
93
+
94
+ include_recipe "postgresql::server_conf"
95
+
96
+ service "postgresql" do
97
+ service_name svc_name
98
+ supports :restart => true, :status => true, :reload => true
99
+ action [:enable, :start]
100
+ end