Commit 565064a97e5ba315020c4a6763e3a327a9c35dce
1 parent
0a14a69e
Exists in
master
and in
17 other branches
Rename chef.server to gitlab in cookbook helpers
Showing
2 changed files
with
20 additions
and
21 deletions
Show diff stats
files/gitlab-cookbooks/gitlab/libraries/chef_server.rb
| ... | ... | @@ -21,7 +21,7 @@ require 'chef/json_compat' |
| 21 | 21 | require 'chef/mixin/deep_merge' |
| 22 | 22 | require 'securerandom' |
| 23 | 23 | |
| 24 | -module ChefServer | |
| 24 | +module GitLab | |
| 25 | 25 | extend(Mixlib::Config) |
| 26 | 26 | |
| 27 | 27 | postgresql Mash.new |
| ... | ... | @@ -36,41 +36,40 @@ module ChefServer |
| 36 | 36 | |
| 37 | 37 | def generate_secrets(node_name) |
| 38 | 38 | existing_secrets ||= Hash.new |
| 39 | - if File.exists?("/etc/chef-server/chef-server-secrets.json") | |
| 40 | - existing_secrets = Chef::JSONCompat.from_json(File.read("/etc/chef-server/chef-server-secrets.json")) | |
| 39 | + if File.exists?("/etc/gitlab/gitlab-secrets.json") | |
| 40 | + existing_secrets = Chef::JSONCompat.from_json(File.read("/etc/gitlab/gitlab-secrets.json")) | |
| 41 | 41 | end |
| 42 | 42 | existing_secrets.each do |k, v| |
| 43 | 43 | v.each do |pk, p| |
| 44 | - ChefServer[k][pk] = p | |
| 44 | + GitLab[k][pk] = p | |
| 45 | 45 | end |
| 46 | 46 | end |
| 47 | 47 | |
| 48 | - ChefServer['chef_server_webui']['cookie_secret'] ||= generate_hex(50) | |
| 49 | - ChefServer['postgresql']['sql_password'] ||= generate_hex(50) | |
| 50 | - ChefServer['postgresql']['sql_ro_password'] ||= generate_hex(50) | |
| 48 | + GitLab['postgresql']['sql_password'] ||= generate_hex(50) | |
| 49 | + GitLab['postgresql']['sql_ro_password'] ||= generate_hex(50) | |
| 51 | 50 | |
| 52 | - if File.directory?("/etc/chef-server") | |
| 53 | - File.open("/etc/chef-server/chef-server-secrets.json", "w") do |f| | |
| 51 | + if File.directory?("/etc/gitlab") | |
| 52 | + File.open("/etc/gitlab/gitlab-secrets.json", "w") do |f| | |
| 54 | 53 | f.puts( |
| 55 | 54 | Chef::JSONCompat.to_json_pretty({ |
| 56 | 55 | 'postgresql' => { |
| 57 | - 'sql_password' => ChefServer['postgresql']['sql_password'], | |
| 58 | - 'sql_ro_password' => ChefServer['postgresql']['sql_ro_password'] | |
| 56 | + 'sql_password' => GitLab['postgresql']['sql_password'], | |
| 57 | + 'sql_ro_password' => GitLab['postgresql']['sql_ro_password'] | |
| 59 | 58 | }, |
| 60 | 59 | }) |
| 61 | 60 | ) |
| 62 | - system("chmod 0600 /etc/chef-server/chef-server-secrets.json") | |
| 61 | + system("chmod 0600 /etc/gitlab/gitlab-secrets.json") | |
| 63 | 62 | end |
| 64 | 63 | end |
| 65 | 64 | end |
| 66 | 65 | |
| 67 | 66 | def generate_hash |
| 68 | - results = { "chef_server" => {} } | |
| 67 | + results = { "gitlab" => {} } | |
| 69 | 68 | [ |
| 70 | 69 | "postgresql" |
| 71 | 70 | ].each do |key| |
| 72 | 71 | rkey = key.gsub('_', '-') |
| 73 | - results['chef_server'][rkey] = ChefServer[key] | |
| 72 | + results['gitlab'][rkey] = GitLab[key] | |
| 74 | 73 | end |
| 75 | 74 | |
| 76 | 75 | results | ... | ... |
files/gitlab-cookbooks/gitlab/libraries/helper.rb
| ... | ... | @@ -35,13 +35,13 @@ class PgHelper |
| 35 | 35 | end |
| 36 | 36 | |
| 37 | 37 | def sql_user_exists? |
| 38 | - user_exists?(node['chef_server']['postgresql']['sql_user']) | |
| 38 | + user_exists?(node['gitlab']['postgresql']['sql_user']) | |
| 39 | 39 | end |
| 40 | 40 | |
| 41 | 41 | def sql_ro_user_exists? |
| 42 | - user_exists?(node['chef_server']['postgresql']['sql_ro_user']) | |
| 42 | + user_exists?(node['gitlab']['postgresql']['sql_ro_user']) | |
| 43 | 43 | end |
| 44 | - | |
| 44 | + | |
| 45 | 45 | def user_exists?(db_user) |
| 46 | 46 | psql_cmd(["-d 'template1'", |
| 47 | 47 | "-c 'select usename from pg_user' -x", |
| ... | ... | @@ -49,20 +49,20 @@ class PgHelper |
| 49 | 49 | end |
| 50 | 50 | |
| 51 | 51 | def psql_cmd(cmd_list) |
| 52 | - cmd = ["/opt/chef-server/embedded/bin/chpst", | |
| 52 | + cmd = ["/opt/gitlab/embedded/bin/chpst", | |
| 53 | 53 | "-u #{pg_user}", |
| 54 | - "/opt/chef-server/embedded/bin/psql", | |
| 54 | + "/opt/gitlab/embedded/bin/psql", | |
| 55 | 55 | "--port #{pg_port}", |
| 56 | 56 | cmd_list.join(" ")].join(" ") |
| 57 | 57 | do_shell_out(cmd, 0) |
| 58 | 58 | end |
| 59 | 59 | |
| 60 | 60 | def pg_user |
| 61 | - node['chef_server']['postgresql']['username'] | |
| 61 | + node['gitlab']['postgresql']['username'] | |
| 62 | 62 | end |
| 63 | 63 | |
| 64 | 64 | def pg_port |
| 65 | - node['chef_server']['postgresql']['port'] | |
| 65 | + node['gitlab']['postgresql']['port'] | |
| 66 | 66 | end |
| 67 | 67 | |
| 68 | 68 | def do_shell_out(cmd, expect_status) | ... | ... |