Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace trademarks hardcodes with constants #42

Merged
merged 1 commit into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions chef_backup.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ Gem::Specification.new do |spec|
spec.add_dependency "mixlib-shellout", ">= 2.0", "< 4.0"
spec.add_dependency "pastel"
spec.add_dependency "tty-prompt", "~> 0.21"
spec.add_dependency "chef-utils", ">= 16.5.54" # for ChefUtils::Dist constants
end
9 changes: 5 additions & 4 deletions lib/chef_backup/config.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require "fileutils" unless defined?(FileUtils)
require "json" unless defined?(JSON)
require "forwardable" unless defined?(Forwardable)
require "chef-utils/dist" unless defined?(ChefUtils::Dist)

module ChefBackup
# ChefBackup Global Config
Expand All @@ -12,10 +13,10 @@ class Config
"backup" => {
"always_dump_db" => true,
"strategy" => "none",
"export_dir" => "/var/opt/chef-backup",
"project_name" => "opscode",
"ctl-command" => "chef-server-ctl",
"running_filepath" => "/etc/opscode/chef-server-running.json",
"export_dir" => "/var/opt/#{ChefUtils::Dist::Infra::SHORT}-backup",
"project_name" => ChefUtils::Dist::Org::LEGACY_CONF_DIR,
"ctl-command" => ChefUtils::Dist::Server::SERVER_CTL,
"running_filepath" => "/etc/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/#{ChefUtils::Dist::Server::SERVER}-running.json",
"database_name" => "opscode_chef",
},
}.freeze
Expand Down
3 changes: 2 additions & 1 deletion lib/chef_backup/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'mixlib/shellout'
require 'chef_backup/config'
require 'chef_backup/logger'
require 'chef-utils/dist'

# rubocop:disable ModuleLength
# rubocop:disable IndentationWidth
Expand All @@ -29,7 +30,7 @@ module Helpers
'ctl_command' => 'opscode-analytics-ctl'
},
'chef-ha' => {
'config_file' => '/etc/opscode/chef-server.rb'
'config_file' => "/etc/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/#{ChefUtils::Dist::Server::SERVER}.rb"
},
'chef-sync' => {
'config_file' => '/etc/chef-sync/chef-sync.rb',
Expand Down
11 changes: 6 additions & 5 deletions lib/chef_backup/strategy/restore/tar.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require "fileutils" unless defined?(FileUtils)
require "pathname" unless defined?(Pathname)
require "forwardable" unless defined?(Forwardable)
require "chef-utils/dist" unless defined?(ChefUtils::Dist)
require "chef_backup/deep_merge"

# rubocop:disable IndentationWidth
Expand Down Expand Up @@ -93,7 +94,7 @@ def restore_configs
end

def touch_sentinel
dir = "/var/opt/opscode"
dir = "/var/opt/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}"
sentinel = File.join(dir, "bootstrapped")
FileUtils.mkdir_p(dir) unless File.directory?(dir)
File.open(sentinel, "w") { |file| file.write "bootstrapped!" }
Expand Down Expand Up @@ -135,11 +136,11 @@ def check_manifest_version

def fix_ha_plugins
log "Fixing HA plugins directory (https://github.com/chef/chef-server/issues/115)"
plugins_dir = "/var/opt/opscode/plugins"
plugins_dir = "/var/opt/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/plugins"
drbd_plugin = File.join(plugins_dir, "chef-ha-drbd.rb")

FileUtils.mkdir_p(plugins_dir) unless Dir.exist?(plugins_dir)
FileUtils.ln_sf("/opt/opscode/chef-server-plugin.rb", drbd_plugin) unless
FileUtils.ln_sf("/opt/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/chef-server-plugin.rb", drbd_plugin) unless
File.exist?(drbd_plugin)
end

Expand All @@ -158,8 +159,8 @@ def ha_data_dir_mounted?(ha_data_dir)

def touch_drbd_ready
log "Touching drbd_ready file"
FileUtils.touch("/var/opt/opscode/drbd/drbd_ready") unless
File.exist?("/var/opt/opscode/drbd/drbd_ready")
FileUtils.touch("/var/opt/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/drbd/drbd_ready") unless
File.exist?("/var/opt/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/drbd/drbd_ready")
end

def reconfigure_server
Expand Down