chef_backup 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b4e824870ac3e10eb6ffaa5bedd55483721a1af6b15cb61c7cb58cc2ccbcf7d9
4
- data.tar.gz: 73be0c4d4911cd7f2f238aa0c9bd93b67a5fe7fdbfeb90294a8bfbffdcc42d7d
3
+ metadata.gz: abf3acd4e6bd56e159617ce5fc550b0eca43520bb9a804cac9795ffb86b05c07
4
+ data.tar.gz: 997e7b9b797959b88b5cff52de0d8f5b10ece2fd23098d89e69a7ac67efba21d
5
5
  SHA512:
6
- metadata.gz: 718ef11067a9e995f10bef3ccee17ac176b42a9a08fd9c3eebad64856dd5fda41f63c3e75e82d5e22fbb37dff521c0dd8e231436a580ace946366fb7dc9f1bc3
7
- data.tar.gz: 03d05f2b1fd933cbd1842fc3563392b63f91127697ab17ae066eaf7c19f094c9c14aaeb083b9bbcbd580db0eb6ed0a71a67b20371821466308a2e1103a8fcbfb
6
+ metadata.gz: 476e6227c7b64a8fe35467802aca311f5c6c8b80241bb54b21f0ef5d08c40041c218760e965f54798a2806521397c6b272507a7a8f4503c00aafbe3280c7a2e3
7
+ data.tar.gz: b0d905d8893045fe1c3c3b0ee2c43b785d26d122825abf98185e1e492d6e03f479d228895be01b8d74728fdfd14090c29bcb1eafea56e3246f550e163bcbf52e
@@ -1,6 +1,7 @@
1
- require "fileutils"
2
- require "json"
3
- require "forwardable"
1
+ require "fileutils" unless defined?(FileUtils)
2
+ require "json" unless defined?(JSON)
3
+ require "forwardable" unless defined?(Forwardable)
4
+ require "chef-utils/dist" unless defined?(ChefUtils::Dist)
4
5
 
5
6
  module ChefBackup
6
7
  # ChefBackup Global Config
@@ -12,10 +13,10 @@ module ChefBackup
12
13
  "backup" => {
13
14
  "always_dump_db" => true,
14
15
  "strategy" => "none",
15
- "export_dir" => "/var/opt/chef-backup",
16
- "project_name" => "opscode",
17
- "ctl-command" => "chef-server-ctl",
18
- "running_filepath" => "/etc/opscode/chef-server-running.json",
16
+ "export_dir" => "/var/opt/#{ChefUtils::Dist::Infra::SHORT}-backup",
17
+ "project_name" => ChefUtils::Dist::Org::LEGACY_CONF_DIR,
18
+ "ctl-command" => ChefUtils::Dist::Server::SERVER_CTL,
19
+ "running_filepath" => "/etc/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/#{ChefUtils::Dist::Server::SERVER}-running.json",
19
20
  "database_name" => "opscode_chef",
20
21
  },
21
22
  }.freeze
@@ -1,4 +1,4 @@
1
- require "time"
1
+ require "time" unless defined?(Time.zone_offset)
2
2
 
3
3
  module ChefBackup
4
4
  # DataMap class to store data about the data we're backing up
@@ -3,6 +3,7 @@ require 'json'
3
3
  require 'mixlib/shellout'
4
4
  require 'chef_backup/config'
5
5
  require 'chef_backup/logger'
6
+ require 'chef-utils/dist'
6
7
 
7
8
  # rubocop:disable ModuleLength
8
9
  # rubocop:disable IndentationWidth
@@ -29,7 +30,7 @@ module Helpers
29
30
  'ctl_command' => 'opscode-analytics-ctl'
30
31
  },
31
32
  'chef-ha' => {
32
- 'config_file' => '/etc/opscode/chef-server.rb'
33
+ 'config_file' => "/etc/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/#{ChefUtils::Dist::Server::SERVER}.rb"
33
34
  },
34
35
  'chef-sync' => {
35
36
  'config_file' => '/etc/chef-sync/chef-sync.rb',
@@ -1,5 +1,3 @@
1
- require "highline"
2
-
3
1
  module ChefBackup
4
2
  # Basic Logging Class
5
3
  class Logger
@@ -16,17 +14,24 @@ module ChefBackup
16
14
 
17
15
  def initialize(logfile = nil)
18
16
  $stdout = logfile ? File.open(logfile, "ab") : $stdout
19
- @highline = HighLine.new($stdin, $stdout)
17
+ end
18
+
19
+ # pastel.decorate is a lightweight replacement for highline.color
20
+ def pastel
21
+ @pastel ||= begin
22
+ require "pastel" unless defined?(Pastel)
23
+ Pastel.new
24
+ end
20
25
  end
21
26
 
22
27
  def log(msg, level = :info)
23
28
  case level
24
29
  when :warn
25
30
  msg = "WARNING: #{msg}"
26
- $stdout.puts(color? ? @highline.color(msg, :yellow) : msg)
31
+ $stdout.puts(color? ? pastel.decorate(msg, :yellow) : msg)
27
32
  when :error
28
33
  msg = "ERROR: #{msg}"
29
- $stdout.puts(color? ? @highline.color(msg, :red) : msg)
34
+ $stdout.puts(color? ? pastel.decorate(msg, :red) : msg)
30
35
  else
31
36
  $stdout.puts(msg)
32
37
  end
@@ -1,5 +1,5 @@
1
- require "fileutils"
2
- require "pathname"
1
+ require "fileutils" unless defined?(FileUtils)
2
+ require "pathname" unless defined?(Pathname)
3
3
 
4
4
  module ChefBackup
5
5
  # ChefBackup::Runner class initializes the strategy and runs the action
@@ -60,16 +60,14 @@ module ChefBackup
60
60
  # @return [String] A path to backup tarball or EBS snapshot ID
61
61
  #
62
62
  def restore_strategy
63
- @restore_strategy ||= begin
64
- if tarball?
65
- unpack_tarball
66
- manifest["strategy"]
67
- elsif ebs_snapshot?
68
- "ebs"
69
- else
70
- raise InvalidStrategy, "#{restore_param} is not a valid backup"
71
- end
72
- end
63
+ @restore_strategy ||= if tarball?
64
+ unpack_tarball
65
+ manifest["strategy"]
66
+ elsif ebs_snapshot?
67
+ "ebs"
68
+ else
69
+ raise InvalidStrategy, "#{restore_param} is not a valid backup"
70
+ end
73
71
  end
74
72
 
75
73
  #
@@ -1,7 +1,6 @@
1
1
  require 'fileutils'
2
2
  require 'json'
3
3
  require 'time'
4
- require 'highline/import'
5
4
 
6
5
  # rubocop:disable IndentationWidth
7
6
  module ChefBackup
@@ -181,7 +180,7 @@ class TarBackup
181
180
  cleanup
182
181
  log 'Backup Complete!'
183
182
  rescue => e
184
- log "Something wen't terribly wrong, aborting backup", :error
183
+ log "Something went terribly wrong, aborting backup", :error
185
184
  log e.message, :error
186
185
  cleanup
187
186
  start_chef_server
@@ -244,7 +243,8 @@ class TarBackup
244
243
  msg << 'continuing. You can skip this message by passing a "--yes" '
245
244
  msg << 'argument. Do you wish to proceed? (y/N):'
246
245
 
247
- exit(1) unless ask(msg) =~ /^y/i
246
+ require "tty-prompt" unless defined?(TTY::Prompt)
247
+ exit(1) unless TTY::Prompt.new(interrupt: :exit).ask(msg) =~ /^y/i
248
248
  end
249
249
  end
250
250
  end
@@ -1,6 +1,7 @@
1
- require "fileutils"
2
- require "pathname"
3
- require "forwardable"
1
+ require "fileutils" unless defined?(FileUtils)
2
+ require "pathname" unless defined?(Pathname)
3
+ require "forwardable" unless defined?(Forwardable)
4
+ require "chef-utils/dist" unless defined?(ChefUtils::Dist)
4
5
  require "chef_backup/deep_merge"
5
6
 
6
7
  # rubocop:disable IndentationWidth
@@ -93,7 +94,7 @@ class TarRestore
93
94
  end
94
95
 
95
96
  def touch_sentinel
96
- dir = "/var/opt/opscode"
97
+ dir = "/var/opt/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}"
97
98
  sentinel = File.join(dir, "bootstrapped")
98
99
  FileUtils.mkdir_p(dir) unless File.directory?(dir)
99
100
  File.open(sentinel, "w") { |file| file.write "bootstrapped!" }
@@ -135,11 +136,11 @@ class TarRestore
135
136
 
136
137
  def fix_ha_plugins
137
138
  log "Fixing HA plugins directory (https://github.com/chef/chef-server/issues/115)"
138
- plugins_dir = "/var/opt/opscode/plugins"
139
+ plugins_dir = "/var/opt/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/plugins"
139
140
  drbd_plugin = File.join(plugins_dir, "chef-ha-drbd.rb")
140
141
 
141
142
  FileUtils.mkdir_p(plugins_dir) unless Dir.exist?(plugins_dir)
142
- FileUtils.ln_sf("/opt/opscode/chef-server-plugin.rb", drbd_plugin) unless
143
+ FileUtils.ln_sf("/opt/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/chef-server-plugin.rb", drbd_plugin) unless
143
144
  File.exist?(drbd_plugin)
144
145
  end
145
146
 
@@ -158,8 +159,8 @@ class TarRestore
158
159
 
159
160
  def touch_drbd_ready
160
161
  log "Touching drbd_ready file"
161
- FileUtils.touch("/var/opt/opscode/drbd/drbd_ready") unless
162
- File.exist?("/var/opt/opscode/drbd/drbd_ready")
162
+ FileUtils.touch("/var/opt/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/drbd/drbd_ready") unless
163
+ File.exist?("/var/opt/#{ChefUtils::Dist::Org::LEGACY_CONF_DIR}/drbd/drbd_ready")
163
164
  end
164
165
 
165
166
  def reconfigure_server
@@ -1,4 +1,4 @@
1
1
  # ChefBackup module
2
2
  module ChefBackup
3
- VERSION = "0.1.0".freeze
3
+ VERSION = "0.3.0".freeze
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef_backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Software, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-24 00:00:00.000000000 Z
11
+ date: 2022-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout
@@ -31,25 +31,47 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: '4.0'
33
33
  - !ruby/object:Gem::Dependency
34
- name: highline
34
+ name: pastel
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - "~>"
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
- version: '1.6'
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
40
44
  - - ">="
41
45
  - !ruby/object:Gem::Version
42
- version: 1.6.9
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: tty-prompt
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '0.21'
43
54
  type: :runtime
44
55
  prerelease: false
45
56
  version_requirements: !ruby/object:Gem::Requirement
46
57
  requirements:
47
58
  - - "~>"
48
59
  - !ruby/object:Gem::Version
49
- version: '1.6'
60
+ version: '0.21'
61
+ - !ruby/object:Gem::Dependency
62
+ name: chef-utils
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: 16.5.54
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
50
72
  - - ">="
51
73
  - !ruby/object:Gem::Version
52
- version: 1.6.9
74
+ version: 16.5.54
53
75
  description: A library to backup a Chef Server
54
76
  email:
55
77
  - oss@chef.io
@@ -98,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
120
  - !ruby/object:Gem::Version
99
121
  version: '0'
100
122
  requirements: []
101
- rubygems_version: 3.0.3
123
+ rubygems_version: 3.1.4
102
124
  signing_key:
103
125
  specification_version: 4
104
126
  summary: A library to backup a Chef Server