Commit ebdaf3c19820e7091a8d960a16169df488ce214d
1 parent
565064a9
Exists in
master
and in
17 other branches
More s/chef.server/gitlab/ for postgres
Showing
7 changed files
with
57 additions
and
57 deletions
Show diff stats
files/gitlab-cookbooks/gitlab/recipes/postgresql.rb
... | ... | @@ -15,30 +15,30 @@ |
15 | 15 | # limitations under the License. |
16 | 16 | # |
17 | 17 | |
18 | -postgresql_dir = node['chef_server']['postgresql']['dir'] | |
19 | -postgresql_data_dir = node['chef_server']['postgresql']['data_dir'] | |
18 | +postgresql_dir = node['gitlab']['postgresql']['dir'] | |
19 | +postgresql_data_dir = node['gitlab']['postgresql']['data_dir'] | |
20 | 20 | postgresql_data_dir_symlink = File.join(postgresql_dir, "data") |
21 | -postgresql_log_dir = node['chef_server']['postgresql']['log_directory'] | |
22 | -chef_db_dir = Dir.glob("/opt/chef-server/embedded/service/erchef/lib/chef_db-*").first | |
21 | +postgresql_log_dir = node['gitlab']['postgresql']['log_directory'] | |
22 | +chef_db_dir = Dir.glob("/opt/gitlab/embedded/service/erchef/lib/chef_db-*").first | |
23 | 23 | |
24 | -user node['chef_server']['postgresql']['username'] do | |
24 | +user node['gitlab']['postgresql']['username'] do | |
25 | 25 | system true |
26 | - shell node['chef_server']['postgresql']['shell'] | |
27 | - home node['chef_server']['postgresql']['home'] | |
26 | + shell node['gitlab']['postgresql']['shell'] | |
27 | + home node['gitlab']['postgresql']['home'] | |
28 | 28 | end |
29 | 29 | |
30 | 30 | directory postgresql_log_dir do |
31 | - owner node['chef_server']['postgresql']['username'] | |
31 | + owner node['gitlab']['postgresql']['username'] | |
32 | 32 | recursive true |
33 | 33 | end |
34 | 34 | |
35 | 35 | directory postgresql_dir do |
36 | - owner node['chef_server']['postgresql']['username'] | |
36 | + owner node['gitlab']['postgresql']['username'] | |
37 | 37 | mode "0700" |
38 | 38 | end |
39 | 39 | |
40 | 40 | directory postgresql_data_dir do |
41 | - owner node['chef_server']['postgresql']['username'] | |
41 | + owner node['gitlab']['postgresql']['username'] | |
42 | 42 | mode "0700" |
43 | 43 | recursive true |
44 | 44 | end |
... | ... | @@ -48,11 +48,11 @@ link postgresql_data_dir_symlink do |
48 | 48 | not_if { postgresql_data_dir == postgresql_data_dir_symlink } |
49 | 49 | end |
50 | 50 | |
51 | -file File.join(node['chef_server']['postgresql']['home'], ".profile") do | |
52 | - owner node['chef_server']['postgresql']['username'] | |
51 | +file File.join(node['gitlab']['postgresql']['home'], ".profile") do | |
52 | + owner node['gitlab']['postgresql']['username'] | |
53 | 53 | mode "0644" |
54 | 54 | content <<-EOH |
55 | -PATH=#{node['chef_server']['postgresql']['user_path']} | |
55 | +PATH=#{node['gitlab']['postgresql']['user_path']} | |
56 | 56 | EOH |
57 | 57 | end |
58 | 58 | |
... | ... | @@ -66,7 +66,7 @@ if File.directory?("/etc/sysctl.d") && File.exists?("/etc/init.d/procps") |
66 | 66 | source "90-postgresql.conf.sysctl.erb" |
67 | 67 | owner "root" |
68 | 68 | mode "0644" |
69 | - variables(node['chef_server']['postgresql'].to_hash) | |
69 | + variables(node['gitlab']['postgresql'].to_hash) | |
70 | 70 | notifies :start, 'service[procps]', :immediately |
71 | 71 | end |
72 | 72 | else |
... | ... | @@ -79,16 +79,16 @@ else |
79 | 79 | bash "add shm settings" do |
80 | 80 | user "root" |
81 | 81 | code <<-EOF |
82 | - echo 'kernel.shmmax = #{node['chef_server']['postgresql']['shmmax']}' >> /etc/sysctl.conf | |
83 | - echo 'kernel.shmall = #{node['chef_server']['postgresql']['shmall']}' >> /etc/sysctl.conf | |
82 | + echo 'kernel.shmmax = #{node['gitlab']['postgresql']['shmmax']}' >> /etc/sysctl.conf | |
83 | + echo 'kernel.shmall = #{node['gitlab']['postgresql']['shmall']}' >> /etc/sysctl.conf | |
84 | 84 | EOF |
85 | 85 | notifies :run, 'execute[sysctl]', :immediately |
86 | 86 | not_if "egrep '^kernel.shmmax = ' /etc/sysctl.conf" |
87 | 87 | end |
88 | 88 | end |
89 | 89 | |
90 | -execute "/opt/chef-server/embedded/bin/initdb -D #{postgresql_data_dir}" do | |
91 | - user node['chef_server']['postgresql']['username'] | |
90 | +execute "/opt/gitlab/embedded/bin/initdb -D #{postgresql_data_dir}" do | |
91 | + user node['gitlab']['postgresql']['username'] | |
92 | 92 | not_if { File.exists?(File.join(postgresql_data_dir, "PG_VERSION")) } |
93 | 93 | end |
94 | 94 | |
... | ... | @@ -96,9 +96,9 @@ postgresql_config = File.join(postgresql_data_dir, "postgresql.conf") |
96 | 96 | |
97 | 97 | template postgresql_config do |
98 | 98 | source "postgresql.conf.erb" |
99 | - owner node['chef_server']['postgresql']['username'] | |
99 | + owner node['gitlab']['postgresql']['username'] | |
100 | 100 | mode "0644" |
101 | - variables(node['chef_server']['postgresql'].to_hash) | |
101 | + variables(node['gitlab']['postgresql'].to_hash) | |
102 | 102 | notifies :restart, 'service[postgresql]' if OmnibusHelper.should_notify?("postgresql") |
103 | 103 | end |
104 | 104 | |
... | ... | @@ -106,26 +106,26 @@ pg_hba_config = File.join(postgresql_data_dir, "pg_hba.conf") |
106 | 106 | |
107 | 107 | template pg_hba_config do |
108 | 108 | source "pg_hba.conf.erb" |
109 | - owner node['chef_server']['postgresql']['username'] | |
109 | + owner node['gitlab']['postgresql']['username'] | |
110 | 110 | mode "0644" |
111 | - variables(node['chef_server']['postgresql'].to_hash) | |
111 | + variables(node['gitlab']['postgresql'].to_hash) | |
112 | 112 | notifies :restart, 'service[postgresql]' if OmnibusHelper.should_notify?("postgresql") |
113 | 113 | end |
114 | 114 | |
115 | 115 | should_notify = OmnibusHelper.should_notify?("postgresql") |
116 | 116 | |
117 | 117 | runit_service "postgresql" do |
118 | - down node['chef_server']['postgresql']['ha'] | |
118 | + down node['gitlab']['postgresql']['ha'] | |
119 | 119 | control(['t']) |
120 | 120 | options({ |
121 | 121 | :log_directory => postgresql_log_dir, |
122 | - :svlogd_size => node['chef_server']['postgresql']['svlogd_size'], | |
123 | - :svlogd_num => node['chef_server']['postgresql']['svlogd_num'] | |
122 | + :svlogd_size => node['gitlab']['postgresql']['svlogd_size'], | |
123 | + :svlogd_num => node['gitlab']['postgresql']['svlogd_num'] | |
124 | 124 | }.merge(params)) |
125 | 125 | end |
126 | 126 | |
127 | -if node['chef_server']['bootstrap']['enable'] | |
128 | - execute "/opt/chef-server/bin/chef-server-ctl start postgresql" do | |
127 | +if node['gitlab']['bootstrap']['enable'] | |
128 | + execute "/opt/gitlab/bin/gitlab-ctl start postgresql" do | |
129 | 129 | retries 20 |
130 | 130 | end |
131 | 131 | end |
... | ... | @@ -135,9 +135,9 @@ end |
135 | 135 | # privileges. |
136 | 136 | ### |
137 | 137 | pg_helper = PgHelper.new(node) |
138 | -pg_port = node['chef_server']['postgresql']['port'] | |
139 | -pg_user = node['chef_server']['postgresql']['username'] | |
140 | -bin_dir = "/opt/chef-server/embedded/bin" | |
138 | +pg_port = node['gitlab']['postgresql']['port'] | |
139 | +pg_user = node['gitlab']['postgresql']['username'] | |
140 | +bin_dir = "/opt/gitlab/embedded/bin" | |
141 | 141 | db_name = "opscode_chef" |
142 | 142 | |
143 | 143 | execute "create #{db_name} database" do |
... | ... | @@ -155,8 +155,8 @@ execute "migrate_database" do |
155 | 155 | action :nothing |
156 | 156 | end |
157 | 157 | |
158 | -sql_user = node['chef_server']['postgresql']['sql_user'] | |
159 | -sql_user_passwd = node['chef_server']['postgresql']['sql_password'] | |
158 | +sql_user = node['gitlab']['postgresql']['sql_user'] | |
159 | +sql_user_passwd = node['gitlab']['postgresql']['sql_password'] | |
160 | 160 | |
161 | 161 | execute "#{bin_dir}/psql --port #{pg_port} -d '#{db_name}' -c \"CREATE USER #{sql_user} WITH SUPERUSER ENCRYPTED PASSWORD '#{sql_user_passwd}'\"" do |
162 | 162 | cwd chef_db_dir |
... | ... | @@ -171,8 +171,8 @@ execute "grant #{db_name} privileges" do |
171 | 171 | action :nothing |
172 | 172 | end |
173 | 173 | |
174 | -sql_ro_user = node['chef_server']['postgresql']['sql_ro_user'] | |
175 | -sql_ro_user_passwd = node['chef_server']['postgresql']['sql_ro_password'] | |
174 | +sql_ro_user = node['gitlab']['postgresql']['sql_ro_user'] | |
175 | +sql_ro_user_passwd = node['gitlab']['postgresql']['sql_ro_password'] | |
176 | 176 | |
177 | 177 | execute "#{bin_dir}/psql --port #{pg_port} -d '#{db_name}' -c \"CREATE USER #{sql_ro_user} WITH SUPERUSER ENCRYPTED PASSWORD '#{sql_ro_user_passwd}'\"" do |
178 | 178 | cwd chef_db_dir | ... | ... |
files/gitlab-cookbooks/gitlab/templates/default/90-postgresql.conf.sysctl.erb
1 | 1 | # |
2 | -# chef server postgresql kernel shm tweaks | |
2 | +# gitlab postgresql kernel shm tweaks | |
3 | 3 | # |
4 | -kernel.shmmax = <%= node['chef_server']['postgresql']['shmmax'] %> | |
5 | -kernel.shmall = <%= node['chef_server']['postgresql']['shmall'] %> | |
4 | +kernel.shmmax = <%= node['gitlab']['postgresql']['shmmax'] %> | |
5 | +kernel.shmall = <%= node['gitlab']['postgresql']['shmall'] %> | ... | ... |
files/gitlab-cookbooks/gitlab/templates/default/pg_hba.conf.erb
... | ... | @@ -65,11 +65,11 @@ |
65 | 65 | # "local" is for Unix domain socket connections only |
66 | 66 | local all all trust |
67 | 67 | |
68 | -<% node['chef_server']['postgresql']['trust_auth_cidr_addresses'].each do |cidr| %> | |
68 | +<% node['gitlab']['postgresql']['trust_auth_cidr_addresses'].each do |cidr| %> | |
69 | 69 | host all all <%= cidr %> trust |
70 | 70 | <% end %> |
71 | 71 | |
72 | -<% node['chef_server']['postgresql']['md5_auth_cidr_addresses'].each do |cidr| %> | |
72 | +<% node['gitlab']['postgresql']['md5_auth_cidr_addresses'].each do |cidr| %> | |
73 | 73 | host all all <%= cidr %> md5 |
74 | 74 | <% end %> |
75 | 75 | ... | ... |
files/gitlab-cookbooks/gitlab/templates/default/postgresql-init.erb
... | ... | @@ -9,19 +9,19 @@ RETVAL=0 |
9 | 9 | |
10 | 10 | case "$1" in |
11 | 11 | stop|force-stop) |
12 | - /opt/chef-server/embedded/bin/sv once postgresql | |
13 | - /opt/chef-server/embedded/bin/sv interrupt postgresql | |
12 | + /opt/gitlab/embedded/bin/sv once postgresql | |
13 | + /opt/gitlab/embedded/bin/sv interrupt postgresql | |
14 | 14 | RETVAL=$? |
15 | 15 | ;; |
16 | 16 | restart) |
17 | - /opt/chef-server/embedded/bin/sv once postgresql | |
18 | - /opt/chef-server/embedded/bin/sv interrupt postgresql | |
17 | + /opt/gitlab/embedded/bin/sv once postgresql | |
18 | + /opt/gitlab/embedded/bin/sv interrupt postgresql | |
19 | 19 | sleep 5 |
20 | - /opt/chef-server/embedded/bin/sv start postgresql | |
20 | + /opt/gitlab/embedded/bin/sv start postgresql | |
21 | 21 | RETVAL=$? |
22 | 22 | ;; |
23 | 23 | *) |
24 | - /opt/chef-server/embedded/bin/sv $1 postgresql | |
24 | + /opt/gitlab/embedded/bin/sv $1 postgresql | |
25 | 25 | RETVAL=$? |
26 | 26 | esac |
27 | 27 | ... | ... |
files/gitlab-cookbooks/gitlab/templates/default/postgresql.conf.erb
... | ... | @@ -56,12 +56,12 @@ |
56 | 56 | |
57 | 57 | # - Connection Settings - |
58 | 58 | |
59 | -listen_addresses = '<%= node['chef_server']['postgresql']['listen_address'] %>' # what IP address(es) to listen on; | |
59 | +listen_addresses = '<%= node['gitlab']['postgresql']['listen_address'] %>' # what IP address(es) to listen on; | |
60 | 60 | # comma-separated list of addresses; |
61 | 61 | # defaults to 'localhost', '*' = all |
62 | 62 | # (change requires restart) |
63 | -port = <%= node['chef_server']['postgresql']['port'] %> # (change requires restart) | |
64 | -max_connections = <%= node['chef_server']['postgresql']['max_connections'] %> # (change requires restart) | |
63 | +port = <%= node['gitlab']['postgresql']['port'] %> # (change requires restart) | |
64 | +max_connections = <%= node['gitlab']['postgresql']['max_connections'] %> # (change requires restart) | |
65 | 65 | # Note: Increasing max_connections costs ~400 bytes of shared memory per |
66 | 66 | # connection slot, plus lock space (see max_locks_per_transaction). |
67 | 67 | #superuser_reserved_connections = 3 # (change requires restart) |
... | ... | @@ -106,7 +106,7 @@ max_connections = <%= node['chef_server']['postgresql']['max_connections'] %> |
106 | 106 | |
107 | 107 | # - Memory - |
108 | 108 | |
109 | -shared_buffers = <%= node['chef_server']['postgresql']['shared_buffers'] %> # min 128kB | |
109 | +shared_buffers = <%= node['gitlab']['postgresql']['shared_buffers'] %> # min 128kB | |
110 | 110 | # (change requires restart) |
111 | 111 | #temp_buffers = 8MB # min 800kB |
112 | 112 | #max_prepared_transactions = 0 # zero disables the feature |
... | ... | @@ -115,7 +115,7 @@ shared_buffers = <%= node['chef_server']['postgresql']['shared_buffers'] %> # mi |
115 | 115 | # per transaction slot, plus lock space (see max_locks_per_transaction). |
116 | 116 | # It is not advisable to set max_prepared_transactions nonzero unless you |
117 | 117 | # actively intend to use prepared transactions. |
118 | -work_mem = <%= node['chef_server']['postgresql']['work_mem'] %> # min 64kB | |
118 | +work_mem = <%= node['gitlab']['postgresql']['work_mem'] %> # min 64kB | |
119 | 119 | #maintenance_work_mem = 16MB # min 1MB |
120 | 120 | #max_stack_depth = 2MB # min 100kB |
121 | 121 | |
... | ... | @@ -171,10 +171,10 @@ work_mem = <%= node['chef_server']['postgresql']['work_mem'] %> # min 64kB |
171 | 171 | |
172 | 172 | # - Checkpoints - |
173 | 173 | |
174 | -checkpoint_segments = <%= node['chef_server']['postgresql']['checkpoint_segments'] %> # in logfile segments, min 1, 16MB each, default 3 | |
175 | -checkpoint_timeout = <%= node['chef_server']['postgresql']['checkpoint_timeout'] %> # range 30s-1h, default 5min | |
176 | -checkpoint_completion_target = <%= node['chef_server']['postgresql']['checkpoint_completion_target'] %> # checkpoint target duration, 0.0 - 1.0, default 0.5 | |
177 | -checkpoint_warning = <%= node['chef_server']['postgresql']['checkpoint_warning'] %> # 0 disables, default 30s | |
174 | +checkpoint_segments = <%= node['gitlab']['postgresql']['checkpoint_segments'] %> # in logfile segments, min 1, 16MB each, default 3 | |
175 | +checkpoint_timeout = <%= node['gitlab']['postgresql']['checkpoint_timeout'] %> # range 30s-1h, default 5min | |
176 | +checkpoint_completion_target = <%= node['gitlab']['postgresql']['checkpoint_completion_target'] %> # checkpoint target duration, 0.0 - 1.0, default 0.5 | |
177 | +checkpoint_warning = <%= node['gitlab']['postgresql']['checkpoint_warning'] %> # 0 disables, default 30s | |
178 | 178 | |
179 | 179 | # - Archiving - |
180 | 180 | |
... | ... | @@ -245,7 +245,7 @@ checkpoint_warning = <%= node['chef_server']['postgresql']['checkpoint_warning'] |
245 | 245 | #cpu_tuple_cost = 0.01 # same scale as above |
246 | 246 | #cpu_index_tuple_cost = 0.005 # same scale as above |
247 | 247 | #cpu_operator_cost = 0.0025 # same scale as above |
248 | -effective_cache_size = <%= node['chef_server']['postgresql']['effective_cache_size'] %> # Default 128MB | |
248 | +effective_cache_size = <%= node['gitlab']['postgresql']['effective_cache_size'] %> # Default 128MB | |
249 | 249 | |
250 | 250 | # - Genetic Query Optimizer - |
251 | 251 | ... | ... |
files/gitlab-cookbooks/gitlab/templates/default/sv-postgresql-control-t.erb
files/gitlab-cookbooks/gitlab/templates/default/sv-postgresql-run.erb
1 | 1 | #!/bin/sh |
2 | 2 | exec 2>&1 |
3 | -exec chpst -P -U <%= node['chef_server']['postgresql']['username'] %> -u <%= node['chef_server']['postgresql']['username'] %> /opt/chef-server/embedded/bin/postgres -D <%= File.join(node['chef_server']['postgresql']['dir'], "data") %> | |
3 | +exec chpst -P -U <%= node['gitlab']['postgresql']['username'] %> -u <%= node['gitlab']['postgresql']['username'] %> /opt/gitlab/embedded/bin/postgres -D <%= File.join(node['gitlab']['postgresql']['dir'], "data") %> | |
4 | 4 | ... | ... |