knife-ec-backup 1.1.4 → 1.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fff49faa32b80dca130c569470c7294e5b3b85ac
4
- data.tar.gz: d704f4be0d92946605874737c318a8c79e57c163
3
+ metadata.gz: 3eb5963efae70a51a2f7e1c7668040a474387b4e
4
+ data.tar.gz: be734d4f4c46e9034e1dc11cb7765ad54e9cbf45
5
5
  SHA512:
6
- metadata.gz: 5550e8d418ecd3e27284c6b6d6d273037599fcc7009c1fa571ef76a353b96fc9442d69b7d9fcf2788e6d200b1b2ed23c7edf1c94d392ee795c1d13d3fc3542f7
7
- data.tar.gz: b7aa8833898097da9b0c3cd697c4e2afa089b3608673594ba5d86a099319b2e3cce2ea8af04ab5c408fa52cd8084458c81868c2df7a7852ec1c8801b61d480e8
6
+ metadata.gz: f37485fee5ddbde8c0478b7f7ff7a7420d970da080ceb237fbc55922ae4e185c4f9d3e215b1479d10a5c19d550f3469d67459476a3f1475235494faf4c34304e
7
+ data.tar.gz: 7a2883b1e6bab1a4450357604ec120946c99cd06f2631fa1bef08897fd0acd38bebc49434c42bf82c4c6103183040942b7ee8c3a223e4c1489d94de070f5dbcf
data/README.md CHANGED
@@ -119,5 +119,7 @@ Restores all data from a repository to an Enterprise Chef / Private Chef server.
119
119
 
120
120
  * Ensure easy installation into embedded ruby gemset on Chef Server.
121
121
  * Remove requirement for Knife Essentials gem to be installed.
122
+ * Single org backups.
122
123
  * This plugin does **NOT** currently backup user passwords. **They will have to be reset after a restore.**
124
+ * This plugin does **NOT** currently restore user public keys. **Private keys will have to be reset after a restore.**
123
125
  * This plugin does **NOT** currently restore custom user ACLs. **It will revert back to default ACLs on a restore.**
@@ -197,6 +197,10 @@ class Chef
197
197
  if ::ChefFS::FileSystem.copy_to(pattern, chef_fs_config.chef_fs, chef_fs_config.local_fs, nil, config, ui, proc { |entry| chef_fs_config.format_path(entry) })
198
198
  @error = true
199
199
  end
200
+ pattern = ::ChefFS::FilePattern.new('/groups/admins.json')
201
+ if ::ChefFS::FileSystem.copy_to(pattern, chef_fs_config.chef_fs, chef_fs_config.local_fs, nil, config, ui, proc { |entry| chef_fs_config.format_path(entry) })
202
+ @error = true
203
+ end
200
204
 
201
205
  # Figure out who the admin is so we can spoof him and retrieve his stuff
202
206
  rest = Chef::REST.new(Chef::Config.chef_server_url)
@@ -213,7 +217,7 @@ class Chef
213
217
  acl_paths = ::ChefFS::FileSystem.list(chef_fs_config.chef_fs, ::ChefFS::FilePattern.new('/acls/*')).select { |entry| entry.name != 'groups' }.map { |entry| entry.path }
214
218
  group_acl_paths = ::ChefFS::FileSystem.list(chef_fs_config.chef_fs, ::ChefFS::FilePattern.new('/acls/groups/*')).select { |entry| entry.name != 'billing-admins.json' }.map { |entry| entry.path }
215
219
  group_paths = ::ChefFS::FileSystem.list(chef_fs_config.chef_fs, ::ChefFS::FilePattern.new('/groups/*')).select { |entry| entry.name != 'billing-admins.json' }.map { |entry| entry.path }
216
- (top_level_paths + group_acl_paths + acl_paths).each do |path|
220
+ (top_level_paths + group_acl_paths + acl_paths + group_paths).each do |path|
217
221
  ::ChefFS::FileSystem.copy_to(::ChefFS::FilePattern.new(path), chef_fs_config.chef_fs, chef_fs_config.local_fs, nil, config, ui, proc { |entry| chef_fs_config.format_path(entry) })
218
222
  end
219
223
 
@@ -64,8 +64,8 @@ class Chef
64
64
  ui.error("Username not configured as pivotal and /etc/opscode/pivotal.pem does not exist. It is recommended that you run this plugin from your Chef server.")
65
65
  exit 1
66
66
  end
67
- the_node_name = 'pivotal'
68
- the_client_key = '/etc/opscode/pivotal.pem'
67
+ node_name = 'pivotal'
68
+ client_key = '/etc/opscode/pivotal.pem'
69
69
  end
70
70
 
71
71
  #Check for WebUI Key
@@ -124,7 +124,7 @@ class Chef
124
124
  next if filename !~ /(.+)\.json/
125
125
  name = $1
126
126
  if name == 'pivotal' && !config[:overwrite_pivotal]
127
- ui.warn("Skipping pivotal update. To overwrite pivotal, pass --overwrite-pivotal. Once pivotal is updated, you will need to modify #{Chef::Config.client_key} to be the corresponding private key.")
127
+ ui.warn("Skipping pivotal update. To overwrite pivotal, pass --overwrite-pivotal.")
128
128
  next
129
129
  end
130
130
 
@@ -203,7 +203,7 @@ class Chef
203
203
  next
204
204
  end
205
205
  if name == 'pivotal' && !config[:overwrite_pivotal]
206
- ui.warn("Skipping pivotal update. To overwrite pivotal, pass --overwrite-pivotal. Once pivotal is updated, you will need to modify #{Chef::Config.client_key} to be the corresponding private key.")
206
+ ui.warn("Skipping pivotal update. To overwrite pivotal, pass --overwrite-pivotal.")
207
207
  next
208
208
  end
209
209
 
@@ -236,6 +236,7 @@ class Chef
236
236
  Chef::Config.chef_server_url = "#{Chef::Config.chef_server_root}/organizations/#{name}"
237
237
 
238
238
  # Upload the admins group and billing-admins acls
239
+ puts "Restoring the org admin data"
239
240
  chef_fs_config = ::ChefFS::Config.new
240
241
  %w(/groups/admins.json /groups/billing-admins.json /acls/groups/billing-admins.json).each do |name|
241
242
  pattern = ::ChefFS::FilePattern.new(name)
@@ -246,34 +247,30 @@ class Chef
246
247
 
247
248
  # Figure out who the admin is so we can spoof him and retrieve his stuff
248
249
  rest = Chef::REST.new(Chef::Config.chef_server_url)
249
- admin_users = rest.get_rest('groups/admins')['users']
250
+ org_admins = rest.get_rest('groups/admins')['users']
250
251
  org_members = rest.get_rest('users').map { |user| user['user']['username'] }
251
- admin_users.delete_if { |user| !org_members.include?(user) }
252
- Chef::Config.node_name = admin_users[0]
253
- Chef::Config.client_key = webui_key
252
+ org_admins.delete_if { |user| !org_members.include?(user) }
253
+ if org_admins[0] != nil
254
+ # Using an org admin already on the destination server
255
+ Chef::Config.node_name = org_admins[0]
256
+ Chef::Config.client_key = webui_key
257
+ else
258
+ # No suitable org admins found, defaulting to pivotal
259
+ ui.warn("No suitable Organizational Admins found. Defaulting to pivotal for org creation")
260
+ end
254
261
  Chef::Config.custom_http_headers = (Chef::Config.custom_http_headers || {}).merge({'x-ops-request-source' => 'web'})
255
262
 
256
- # Do the upload.
263
+ # Restore the entire org skipping the admin data and restoring groups and acls last
264
+ puts "Restoring the rest of the org"
257
265
  chef_fs_config = ::ChefFS::Config.new
258
- # groups and acls come last.
259
- children = chef_fs_config.chef_fs.children.map { |child| child.name }
260
- children.delete('acls')
261
- children.delete('groups')
262
- parallelize(children) do |child_name|
263
- pattern = ::ChefFS::FilePattern.new("/#{child_name}")
264
- if ::ChefFS::FileSystem.copy_to(pattern, chef_fs_config.local_fs, chef_fs_config.chef_fs, nil, config, ui, proc { |entry| chef_fs_config.format_path(entry) })
265
- @error = true
266
- end
267
- end
268
- pattern = ::ChefFS::FilePattern.new("/groups")
269
- if ::ChefFS::FileSystem.copy_to(pattern, chef_fs_config.local_fs, chef_fs_config.chef_fs, nil, config, ui, proc { |entry| chef_fs_config.format_path(entry) })
270
- @error = true
271
- end
272
- pattern = ::ChefFS::FilePattern.new("/acls")
273
- if ::ChefFS::FileSystem.copy_to(pattern, chef_fs_config.local_fs, chef_fs_config.chef_fs, nil, config, ui, proc { |entry| chef_fs_config.format_path(entry) })
274
- @error = true
266
+ top_level_paths = chef_fs_config.local_fs.children.select { |entry| entry.name != 'acls' && entry.name != 'groups' }.map { |entry| entry.path }
267
+ acl_paths = ::ChefFS::FileSystem.list(chef_fs_config.local_fs, ::ChefFS::FilePattern.new('/acls/*')).select { |entry| entry.name != 'groups' }.map { |entry| entry.path }
268
+ group_acl_paths = ::ChefFS::FileSystem.list(chef_fs_config.local_fs, ::ChefFS::FilePattern.new('/acls/groups/*')).select { |entry| entry.name != 'billing-admins.json' }.map { |entry| entry.path }
269
+ group_paths = ::ChefFS::FileSystem.list(chef_fs_config.local_fs, ::ChefFS::FilePattern.new('/groups/*')).select { |entry| entry.name != 'billing-admins.json' }.map { |entry| entry.path }
270
+ (top_level_paths + group_paths + group_acl_paths + acl_paths).each do |path|
271
+ ::ChefFS::FileSystem.copy_to(::ChefFS::FilePattern.new(path), chef_fs_config.local_fs, chef_fs_config.chef_fs, nil, config, ui, proc { |entry| chef_fs_config.format_path(entry) })
275
272
  end
276
- ensure
273
+ ensure
277
274
  CONFIG_VARS.each do |key|
278
275
  Chef::Config[key.to_sym] = old_config[key]
279
276
  end
@@ -1,3 +1,3 @@
1
1
  module KnifeECBackup
2
- VERSION = '1.1.4'
2
+ VERSION = '1.1.5'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-ec-backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Keiser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-23 00:00:00.000000000 Z
11
+ date: 2014-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec