Skip to content

Commit

Permalink
chef#1949: Wordmark replacements: chef-server-ctl
Browse files Browse the repository at this point in the history
  • Loading branch information
jgitlin-p21 committed Aug 25, 2021
1 parent e7e50c4 commit a9c308d
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/chef-server-ctl/bin/chef-server-ctl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ require 'veil'
require 'chef_server_ctl/log'
require 'chef_server_ctl/config'
require "license_acceptance/acceptor"
#require "chef-config/dist"
#require "chef"

module Omnibus
# This implements callbacks for handling commands related to the
Expand All @@ -28,13 +30,13 @@ module Omnibus
d
end

CREDENTIAL_ENV = 'CHEF_SECRETS_DATA'.freeze
CREDENTIAL_ENV = "#{ChefUtils::Dist::Infra::SHORT.upcase}_SECRETS_DATA".freeze

def credentials
if ENV.has_key?(CREDENTIAL_ENV)
@credentials = Veil::CredentialCollection::ChefSecretsEnv.new(var_name: CREDENTIAL_ENV)
else
secrets_file = ENV['SECRETS_FILE'] || "/etc/opscode/private-chef-secrets.json"
secrets_file = ENV['SECRETS_FILE'] || "/etc/opscode/private-#{ChefUtils::Dist::Infra::SHORT}-secrets.json"
@credentials ||= Veil::CredentialCollection::ChefSecretsFile.from_file(secrets_file)
end
end
Expand Down Expand Up @@ -75,13 +77,13 @@ module Omnibus
last = exec_list.shift
connection.exec(last)
end
puts "Chef Server databases and roles have been successsfully deleted from #{postgres['vip']}"
puts "#{ChefUtils::Dist::Server::PRODUCT} databases and roles have been successfully deleted from #{postgres['vip']}"
rescue StandardError => e
exec_list.insert(0, last) unless last.nil?
if exec_list.empty?
path = nil
else
path = Time.now.strftime('/root/%FT%R-chef-server-manual-postgresql-cleanup.sql')
path = Time.now.strftime("/root/%FT%R-#{ChefConfig::Dist::SHORT}-server-manual-postgresql-cleanup.sql")
dump_exec_list_to_file(path, exec_list)
end
# Note - we're just showing the error and not exiting, so that
Expand Down Expand Up @@ -157,15 +159,15 @@ STAT001: An error occurred while attempting to get status from PostgreSQL
#{format_multiline_message(12, message)}
See https://docs.chef.io/error_messages.html#stat001-postgres-failed
See #{ChefUtils::Dist::Server::DOCS}/error_messages.html#stat001-postgres-failed
for more information.
EOM
end

def err_CLEANSE001_postgres_failed(postgres, path, last, message)
msg = <<EOM
CLEANSE001: While local cleanse of Chef Server succeeded, an error
occurred while deleting Chef Server data from the external
CLEANSE001: While local cleanse of #{ChefUtils::Dist::Server::PRODUCT} succeeded, an error
occurred while deleting #{ChefUtils::Dist::Server::PRODUCT} data from the external
PostgreSQL server at #{postgres['vip']}.
The error reported was:
Expand All @@ -188,18 +190,18 @@ EOM

msg << <<EOM
See https://docs.chef.io/error_messages.html#cleanse001-postgres-failed
See #{ChefUtils::Dist::Server::DOCS}/error_messages.html#cleanse001-postgres-failed
for more information.
EOM
msg
end
def warn_CLEANSE002_no_postgres_delete(sql_path, postgres)
<<EOM
CLEANSE002: Note that Chef Server data was not removed from your
CLEANSE002: Note that #{ChefUtils::Dist::Server::PRODUCT} data was not removed from your
remote PostgreSQL server because you did not specify
the '--with-external' option.
If you do wish to purge Chef Server data from PostgreSQL,
If you do wish to purge #{ChefUtils::Dist::Server::PRODUCT} data from PostgreSQL,
you can do by logging into PostgreSQL on
#{postgres['vip']}:#{postgres['port']}
and executing the appropriate SQL staements manually.
Expand All @@ -209,7 +211,7 @@ CLEANSE002: Note that Chef Server data was not removed from your
#{sql_path}
See https://docs.chef.io/error_messages.html#cleanse002-postgres-not-purged
See #{ChefUtils::Dist::Server::DOCS}/error_messages.html#cleanse002-postgres-not-purged
for more information.
EOM
end
Expand Down Expand Up @@ -288,7 +290,7 @@ log_level = if ENV['CSC_LOG_LEVEL']

ChefServerCtl::Log.level = log_level

ctl = Omnibus::ChefServerCtl.new(cmd_name, true, "Chef Server")
ctl = Omnibus::ChefServerCtl.new(cmd_name, true, "#{ChefUtils::Dist::Server::PRODUCT}")

#Initialize global configuration
ChefServerCtl::Config.init(ctl)
Expand Down

0 comments on commit a9c308d

Please sign in to comment.