knife-ec-backup 2.0.0.beta.1 → 2.0.0.beta.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/chef/knife/ec_backup.rb +23 -2
- data/lib/chef/knife/ec_key_export.rb +1 -1
- data/lib/chef/knife/ec_key_import.rb +19 -20
- data/lib/chef/knife/ec_restore.rb +25 -5
- data/lib/knife_ec_backup/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a427844677521bea76fb22774f405ae3ed97af6
|
4
|
+
data.tar.gz: ac92e509e8ecee7a4e14852f99c5e43a72305306
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f27a84674dc02eaee070700efc7f8bf4e898710342d1059b3881deb6c4bd9b75b4aef109708604364a0188cf65a7c67b665460b08c47e019c3abdf77ca0a8a3
|
7
|
+
data.tar.gz: ad983d25da97492db691b431ac6fef6f60f468d314ea2909f74132eec633053a8a26cd88b03890703d6fa86f8bd133b7f9ca77091fccda2fdb603406682ff817
|
data/lib/chef/knife/ec_backup.rb
CHANGED
@@ -33,6 +33,25 @@ class Chef
|
|
33
33
|
:long => '--only-org ORGNAME',
|
34
34
|
:description => "Only back up objects in the named organization (default: all orgs)"
|
35
35
|
|
36
|
+
option :sql_host,
|
37
|
+
:long => '--sql-host HOSTNAME',
|
38
|
+
:description => 'Postgresql database hostname (default: localhost)',
|
39
|
+
:default => "localhost"
|
40
|
+
|
41
|
+
option :sql_port,
|
42
|
+
:long => '--sql-port PORT',
|
43
|
+
:description => 'Postgresql database port (default: 5432)',
|
44
|
+
:default => 5432
|
45
|
+
|
46
|
+
option :sql_user,
|
47
|
+
:long => "--sql-user USERNAME",
|
48
|
+
:description => 'User used to connect to the postgresql database.'
|
49
|
+
|
50
|
+
option :sql_password,
|
51
|
+
:long => "--sql-password PASSWORD",
|
52
|
+
:description => 'Password used to connect to the postgresql database'
|
53
|
+
|
54
|
+
|
36
55
|
deps do
|
37
56
|
require 'chef/chef_fs/config'
|
38
57
|
require 'chef/chef_fs/file_system'
|
@@ -149,8 +168,10 @@ class Chef
|
|
149
168
|
Chef::Knife::EcKeyExport.deps
|
150
169
|
k = Chef::Knife::EcKeyExport.new
|
151
170
|
k.name_args = ["#{dest_dir}/key_dump.json"]
|
152
|
-
k.config[:sql_host] =
|
153
|
-
k.config[:sql_port] =
|
171
|
+
k.config[:sql_host] = config[:sql_host]
|
172
|
+
k.config[:sql_port] = config[:sql_port]
|
173
|
+
k.config[:sql_user] = config[:sql_user]
|
174
|
+
k.config[:sql_password] = config[:sql_password]
|
154
175
|
k.run
|
155
176
|
end
|
156
177
|
|
@@ -37,7 +37,7 @@ class Chef
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def export(path)
|
40
|
-
users = db.select
|
40
|
+
users = db.select.from(:users)
|
41
41
|
File.open(path, 'w') { |file| file.write(users.all.to_json) }
|
42
42
|
end
|
43
43
|
end
|
@@ -52,32 +52,31 @@ class Chef
|
|
52
52
|
def import(path)
|
53
53
|
key_data = JSON.parse(File.read(path))
|
54
54
|
key_data.each do |d|
|
55
|
-
|
56
|
-
username = d['username']
|
57
|
-
key = d['public_key']
|
58
|
-
version = d['pubkey_version']
|
59
|
-
hashed_password = d['hashed_password']
|
60
|
-
hash_type = d['hash_type']
|
61
|
-
salt = d['salt']
|
62
|
-
|
63
|
-
if username == 'pivotal' && config[:skip_pivotal]
|
55
|
+
if d['username'] == 'pivotal' && config[:skip_pivotal]
|
64
56
|
ui.warn "Skipping pivotal user."
|
65
57
|
next
|
66
58
|
end
|
67
59
|
|
68
|
-
ui.msg "Updating key for #{username}"
|
69
|
-
users_to_update = db[:users].where(:username => username)
|
60
|
+
ui.msg "Updating key for #{d['username']}"
|
61
|
+
users_to_update = db[:users].where(:username => d['username'])
|
62
|
+
|
70
63
|
if users_to_update.count != 1
|
71
|
-
ui.warn "Wrong number of users to update for #{username}. Skipping"
|
64
|
+
ui.warn "Wrong number of users to update for #{d['username']}. Skipping"
|
72
65
|
else
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
66
|
+
# Remove authz id from import since this will no longer
|
67
|
+
# be valid.
|
68
|
+
d.delete('authz_id')
|
69
|
+
d.delete('id') if config[:skip_ids]
|
70
|
+
# If the hash_type in the export,
|
71
|
+
# we are dealing with a record where the password is still in the
|
72
|
+
# serialized_obejct. Explictly setting these to nil ensures that the
|
73
|
+
# password set in the restore is wiped out.
|
74
|
+
unless d.has_key?('hash_type')
|
75
|
+
d['hash_type'] = nil
|
76
|
+
d['hashed_password'] = nil
|
77
|
+
d['salt'] = nil
|
78
|
+
end
|
79
|
+
users_to_update.update(d)
|
81
80
|
end
|
82
81
|
end
|
83
82
|
end
|
@@ -43,6 +43,24 @@ class Chef
|
|
43
43
|
:long => "--with-user-sql",
|
44
44
|
:description => "Restore user id's, passwords, and keys from sql export"
|
45
45
|
|
46
|
+
option :sql_host,
|
47
|
+
:long => '--sql-host HOSTNAME',
|
48
|
+
:description => 'Postgresql database hostname (default: localhost)',
|
49
|
+
:default => "localhost"
|
50
|
+
|
51
|
+
option :sql_port,
|
52
|
+
:long => '--sql-port PORT',
|
53
|
+
:description => 'Postgresql database port (default: 5432)',
|
54
|
+
:default => 5432
|
55
|
+
|
56
|
+
option :sql_user,
|
57
|
+
:long => "--sql-user USERNAME",
|
58
|
+
:description => 'User used to connect to the postgresql database.'
|
59
|
+
|
60
|
+
option :sql_password,
|
61
|
+
:long => "--sql-password PASSWORD",
|
62
|
+
:description => 'Password used to connect to the postgresql database'
|
63
|
+
|
46
64
|
deps do
|
47
65
|
require 'chef/json_compat'
|
48
66
|
require 'chef/chef_fs/config'
|
@@ -218,7 +236,7 @@ class Chef
|
|
218
236
|
ui.warn("Skipping pivotal update. To overwrite pivotal, pass --overwrite-pivotal.")
|
219
237
|
next
|
220
238
|
end
|
221
|
-
|
239
|
+
|
222
240
|
# Update user object
|
223
241
|
user = JSONCompat.from_json(IO.read("#{dest_dir}/users/#{name}.json"))
|
224
242
|
begin
|
@@ -242,8 +260,10 @@ class Chef
|
|
242
260
|
k.name_args = ["#{dest_dir}/key_dump.json"]
|
243
261
|
k.config[:skip_pivotal] = true
|
244
262
|
k.config[:skip_ids] = false
|
245
|
-
k.config[:sql_host] =
|
246
|
-
k.config[:sql_port] =
|
263
|
+
k.config[:sql_host] = config[:sql_host]
|
264
|
+
k.config[:sql_port] = config[:sql_port]
|
265
|
+
k.config[:sql_user] = config[:sql_user]
|
266
|
+
k.config[:sql_password] = config[:sql_password]
|
247
267
|
k.run
|
248
268
|
end
|
249
269
|
|
@@ -307,8 +327,8 @@ class Chef
|
|
307
327
|
Chef::ChefFS::FileSystem.copy_to(Chef::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) })
|
308
328
|
end
|
309
329
|
# restore clients to groups, using the pivotal key again
|
310
|
-
Chef::Config[:node_name] = old_config[
|
311
|
-
Chef::Config[:client_key] = old_config[
|
330
|
+
Chef::Config[:node_name] = old_config[:node_name]
|
331
|
+
Chef::Config[:client_key] = old_config[:client_key]
|
312
332
|
Chef::Config.custom_http_headers = {}
|
313
333
|
['admins', 'billing-admins'].each do |group|
|
314
334
|
restore_group(Chef::ChefFS::Config.new, group)
|
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: 2.0.0.beta.
|
4
|
+
version: 2.0.0.beta.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Keiser
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sequel
|
@@ -118,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
version: 1.3.1
|
119
119
|
requirements: []
|
120
120
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.2.
|
121
|
+
rubygems_version: 2.2.1
|
122
122
|
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: Backup and Restore of Enterprise Chef
|