chef_backup 0.0.1.dev.3 → 0.0.1.dev.4

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
  SHA1:
3
- metadata.gz: 09b1eb6deacbd6c56ebe568a9f35f901dc84fd44
4
- data.tar.gz: 9d46e9ecc8b151b30f84b10ec1b87967d59ed1cf
3
+ metadata.gz: 94cbd6726cb86fe838709bb6cd0102f18ff98a02
4
+ data.tar.gz: 7a38dd28ef497ae4b1ec8a59adb22634e28f2fc4
5
5
  SHA512:
6
- metadata.gz: fc18b6429543be51b9181a7f41824884729827d4d3b2ff1b9590b0798ee63c4a354af3c55fc87750b643fc4da114884feb7572554e754450b256bffe794482cc
7
- data.tar.gz: e91dc44182e140a32685ac618ebc5a129b648fa1c2a953529da9c476d579b19df5a6ec7cfc305df224a53d823cf18f75caf0d6fb3c2a8de3d2a5ca31df6aa324
6
+ metadata.gz: 4f1c58f55e246331ab7cc8c9919f6e9dafaba9922d4c597e5546bd59701634e3766461d4e58f3efffcea09cf1267724e52d3f11b4b9fc6b37be68eecdc1664b4
7
+ data.tar.gz: af600e295428765fb2e8bd0316039108a1133c5fd7a82ea8df83b1c518019c965a4239935cc9625010522b2bc82ff23aab588ab4afc9f0f24e06a0ebac846478
@@ -2,8 +2,12 @@ Style/ClassAndModuleChildren:
2
2
  Enabled: false
3
3
  Style/GuardClause:
4
4
  Enabled: false
5
+ Metrics/LineLength:
6
+ Max: 120
5
7
  Metrics/ClassLength:
6
8
  Max: 200
9
+ Metrics/ModuleLength:
10
+ Max: 200
7
11
  Metrics/CyclomaticComplexity:
8
12
  Max: 10
9
13
  Metrics/PerceivedComplexity:
@@ -11,7 +15,7 @@ Metrics/PerceivedComplexity:
11
15
  Metrics/MethodLength:
12
16
  Max: 40
13
17
  Metrics/AbcSize:
14
- Max: 30
18
+ Max: 40
15
19
  AllCops:
16
20
  Exclude:
17
21
  - 'Guardfile'
@@ -28,6 +28,6 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency 'rspec', '~> 3.0'
29
29
  spec.add_development_dependency 'guard-rspec'
30
30
  spec.add_development_dependency 'pry-rescue'
31
- spec.add_development_dependency 'rubocop', '>= 0.28'
31
+ spec.add_development_dependency 'rubocop', '>= 0.32.1'
32
32
  spec.add_development_dependency 'simplecov'
33
33
  end
@@ -11,15 +11,17 @@ module ChefBackup
11
11
  attr_writer :data_map
12
12
  end
13
13
 
14
- attr_accessor :strategy, :backup_time, :configs, :services
14
+ attr_accessor :strategy, :backup_time, :topology, :configs, :services, :ha
15
15
 
16
16
  def initialize
17
17
  @services = {}
18
18
  @configs = {}
19
+ @ha = {}
19
20
  yield self if block_given?
20
21
 
21
22
  @backup_time ||= Time.now.iso8601
22
23
  @strategy ||= 'none'
24
+ @toplogy ||= 'idontknow'
23
25
  end
24
26
 
25
27
  def add_service(service, data_dir)
@@ -32,10 +34,16 @@ module ChefBackup
32
34
  @configs[config]['data_dir'] = path
33
35
  end
34
36
 
37
+ def add_ha_info(k, v)
38
+ @ha[k] = v
39
+ end
40
+
35
41
  def manifest
36
42
  {
37
43
  'strategy' => strategy,
38
44
  'backup_time' => backup_time,
45
+ 'topology' => topology,
46
+ 'ha' => ha,
39
47
  'services' => services,
40
48
  'configs' => configs
41
49
  }
@@ -104,18 +104,34 @@ module Helpers
104
104
  private_chef['backup']['strategy']
105
105
  end
106
106
 
107
+ def topology
108
+ private_chef['topology']
109
+ end
110
+
107
111
  def frontend?
108
112
  private_chef['role'] == 'frontend'
109
113
  end
110
114
 
111
115
  def backend?
112
- private_chef['role'] =~ /backend|standalone/
116
+ private_chef['role'] =~ /backend|standalone/
113
117
  end
114
118
 
115
119
  def online?
116
120
  private_chef['backup']['mode'] == 'online'
117
121
  end
118
122
 
123
+ def ha?
124
+ topology == 'ha'
125
+ end
126
+
127
+ def tier?
128
+ topology == 'tier'
129
+ end
130
+
131
+ def standalone?
132
+ topology == 'standalone'
133
+ end
134
+
119
135
  def tmp_dir
120
136
  @tmp_dir ||= begin
121
137
  dir = safe_key { config['tmp_dir'] } ||
@@ -75,6 +75,12 @@ class TarBackup
75
75
  if private_chef.key?('upgrades')
76
76
  data_map.add_service('upgrades', private_chef['upgrades']['dir'])
77
77
  end
78
+
79
+ if ha?
80
+ data_map.add_service('keepalived', private_chef['keepalived']['dir'])
81
+ data_map.add_ha_info('provider', private_chef['ha']['provider'])
82
+ data_map.add_ha_info('path', private_chef['ha']['path'])
83
+ end
78
84
  end
79
85
 
80
86
  def manifest
@@ -111,6 +117,7 @@ class TarBackup
111
117
  @data_map ||= ChefBackup::DataMap.new do |data|
112
118
  data.backup_time = backup_time
113
119
  data.strategy = strategy
120
+ data.topology = topology
114
121
  end
115
122
  end
116
123
 
@@ -26,6 +26,12 @@ class TarRestore
26
26
  def restore
27
27
  log 'Restoring Chef Server from backup'
28
28
  cleanse_chef_server(config['agree_to_cleanse'])
29
+ if manifest['topology'] == 'ha'
30
+ log 'Performing HA restore - please ensure that keepalived is not running on the standby host'
31
+ fix_ha_plugins
32
+ check_ha_volume
33
+ touch_drbd_ready
34
+ end
29
35
  restore_configs
30
36
  restore_services unless frontend?
31
37
  touch_sentinel
@@ -102,6 +108,35 @@ class TarRestore
102
108
  @backup_name ||= Pathname.new(tarball_path).basename.sub_ext('').to_s
103
109
  end
104
110
 
111
+ def fix_ha_plugins
112
+ log 'Fixing HA plugins directory (https://github.com/chef/chef-server/issues/115)'
113
+ plugins_dir = '/var/opt/opscode/plugins'
114
+ drbd_plugin = File.join(plugins_dir, 'chef-ha-drbd.rb')
115
+
116
+ FileUtils.mkdir_p(plugins_dir) unless Dir.exist?(plugins_dir)
117
+ FileUtils.ln_sf('/opt/opscode/chef-server-plugin.rb', drbd_plugin) unless
118
+ File.exist?(drbd_plugin)
119
+ end
120
+
121
+ def check_ha_volume
122
+ log 'Checking that the HA storage volume is mounted'
123
+ ha_data_dir = manifest['ha']['path']
124
+
125
+ unless ha_data_dir_mounted?(ha_data_dir)
126
+ fail "Please mount the data directory #{ha_data_dir} and perform any DRBD configuration before continuing"
127
+ end
128
+ end
129
+
130
+ def ha_data_dir_mounted?(ha_data_dir)
131
+ File.read('/proc/mounts').split("\n").grep(/#{ha_data_dir}/).count > 0
132
+ end
133
+
134
+ def touch_drbd_ready
135
+ log 'Touching drbd_ready file'
136
+ FileUtils.touch('/var/opt/opscode/drbd/drbd_ready') unless
137
+ File.exist?('/var/opt/opscode/drbd/drbd_ready')
138
+ end
139
+
105
140
  def reconfigure_server
106
141
  log 'Reconfiguring the Chef Server'
107
142
  shell_out('chef-server-ctl reconfigure')
@@ -1,4 +1,4 @@
1
1
  # ChefBackup module
2
2
  module ChefBackup
3
- VERSION = '0.0.1.dev.3'
3
+ VERSION = '0.0.1.dev.4'
4
4
  end
@@ -534,6 +534,10 @@
534
534
  },
535
535
  "lb-internal": {
536
536
  },
537
+ "ha": {
538
+ "provider": "drbd",
539
+ "path": "/var/opt/opscode/drbd/data"
540
+ },
537
541
  "topology": "ha",
538
542
  "servers": {
539
543
  "backend1.opscode.kryptonite": {
@@ -60,7 +60,7 @@ describe ChefBackup::Strategy::TarBackup do
60
60
  end
61
61
  end
62
62
 
63
- context 'on a standlone' do
63
+ context 'on a standalone' do
64
64
  before { private_chef('role' => 'standalone') }
65
65
 
66
66
  context 'during an online backup' do
@@ -224,7 +224,7 @@ describe ChefBackup::Strategy::TarBackup do
224
224
  allow(subject).to receive(:data_map).and_return(data_map)
225
225
  allow(subject).to receive(:stateful_services).and_return(services)
226
226
  allow(subject).to receive(:config_directories).and_return(configs)
227
- %w(add_service add_config).each do |method|
227
+ %w(add_service add_config add_ha_info).each do |method|
228
228
  allow(data_map).to receive(method.to_sym).and_return(true)
229
229
  end
230
230
  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.0.1.dev.3
4
+ version: 0.0.1.dev.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Cragun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-28 00:00:00.000000000 Z
11
+ date: 2015-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: di-ruby-lvm
@@ -142,14 +142,14 @@ dependencies:
142
142
  requirements:
143
143
  - - ">="
144
144
  - !ruby/object:Gem::Version
145
- version: '0.28'
145
+ version: 0.32.1
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
- version: '0.28'
152
+ version: 0.32.1
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: simplecov
155
155
  requirement: !ruby/object:Gem::Requirement
@@ -251,3 +251,4 @@ test_files:
251
251
  - spec/unit/strategy/restore/shared_examples/restore.rb
252
252
  - spec/unit/strategy/restore/tar_spec.rb
253
253
  - spec/unit/strategy_spec.rb
254
+ has_rdoc: