knife-ec-backup 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/chef/knife/ec_backup.rb +5 -1
- data/lib/chef/knife/ec_restore.rb +24 -27
- data/lib/knife_ec_backup/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3eb5963efae70a51a2f7e1c7668040a474387b4e
|
4
|
+
data.tar.gz: be734d4f4c46e9034e1dc11cb7765ad54e9cbf45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.**
|
data/lib/chef/knife/ec_backup.rb
CHANGED
@@ -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
|
-
|
68
|
-
|
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.
|
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.
|
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
|
-
|
250
|
+
org_admins = rest.get_rest('groups/admins')['users']
|
250
251
|
org_members = rest.get_rest('users').map { |user| user['user']['username'] }
|
251
|
-
|
252
|
-
|
253
|
-
|
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
|
-
#
|
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
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
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
|
-
|
273
|
+
ensure
|
277
274
|
CONFIG_VARS.each do |key|
|
278
275
|
Chef::Config[key.to_sym] = old_config[key]
|
279
276
|
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
|
+
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:
|
11
|
+
date: 2014-01-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|