knife-ec-backup 1.1.0 → 1.1.1
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 +4 -4
- data/README.md +13 -3
- data/lib/chef/knife/ec_backup.rb +36 -25
- data/lib/chef/knife/ec_restore.rb +26 -16
- data/lib/knife_ec_backup/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76b450dcd76db4d13569e2a0bb2698f33903f0bb
|
4
|
+
data.tar.gz: 70a79178d91d74240cd2db487e4ba0e6a0d1ca24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da50a45648d1e64559b71aefad81a9e9b2097c2a8673c46346546ea03ca89753c9f1c2cfa81ee1e18cb9ac023d241d36dc9cda3c413d751be51e61359ff523b9
|
7
|
+
data.tar.gz: db4a3f1de0962d1dd30eabb0bf441c49073f796d6f5af7499161cf8dfc94cf7daa6faabe0df33a4b03d872bcd1bad7dbca44ec4797da83f8001d69a718ead63b
|
data/README.md
CHANGED
@@ -12,11 +12,17 @@ This knife plugin currently requires the Knife-Essentials gem to be installed in
|
|
12
12
|
|
13
13
|
# Installation
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
## Chef Server Install (Recommended)
|
16
|
+
This will install the plugin directly on the Chef Server:
|
17
|
+
|
18
|
+
/opt/opscode/embedded/bin/gem install knife-ec-backup
|
19
|
+
/opt/opscode/embedded/bin/gem install knife-ec-backup
|
20
|
+
|
21
|
+
## Build from source
|
22
|
+
Clone the git repository and run the following from inside:
|
17
23
|
|
18
24
|
gem build knife-ec-backup.gemspec
|
19
|
-
gem install knife-ec-backup-1.
|
25
|
+
gem install knife-ec-backup-1.1.1.gem
|
20
26
|
|
21
27
|
# Configuration
|
22
28
|
|
@@ -37,6 +43,8 @@ It is recommended that you run this from a frontend Enterprise Chef Server, you
|
|
37
43
|
Used to set the path to the WebUI Key (default: /etc/opscode/webui_priv.pem)
|
38
44
|
* `--skip-useracl`:
|
39
45
|
Whether to skip downloading User ACLs. This is required for EC 11.0.0 and lower (default: false)
|
46
|
+
* `--skip-version-check'`:
|
47
|
+
Whether to skip checking the Chef Server version. This will also skip any auto-configured options (default: false)
|
40
48
|
|
41
49
|
Creates a repository of an entire Enterprise Chef / Private Chef server.
|
42
50
|
|
@@ -102,6 +110,8 @@ This compares very closely with the "knife download /" from an OSC server:
|
|
102
110
|
Whether to overwrite pivotal's key. Once this is done, future requests will fail until you fix the private key (default: false)
|
103
111
|
* `--skip-useracl`:
|
104
112
|
Whether to skip downloading User ACLs. This is required for EC 11.0.0 and lower (default: false)
|
113
|
+
* `--skip-version-check'`:
|
114
|
+
Whether to skip checking the Chef Server version. This will also skip any auto-configured options (default: false)
|
105
115
|
|
106
116
|
Restores all data from a repository to an Enterprise Chef / Private Chef server.
|
107
117
|
|
data/lib/chef/knife/ec_backup.rb
CHANGED
@@ -19,6 +19,12 @@ class Chef
|
|
19
19
|
:default => false,
|
20
20
|
:description => "Whether to skip downloading User ACLs. This is required for EC 11.0.0 and lower"
|
21
21
|
|
22
|
+
option :skip_version,
|
23
|
+
:long => '--skip-version-check',
|
24
|
+
:boolean => true,
|
25
|
+
:default => false,
|
26
|
+
:description => "Whether to skip checking the Chef Server version. This will also skip any auto-configured options"
|
27
|
+
|
22
28
|
deps do
|
23
29
|
require 'chef_fs/config'
|
24
30
|
require 'chef_fs/file_system'
|
@@ -74,33 +80,38 @@ class Chef
|
|
74
80
|
end
|
75
81
|
|
76
82
|
rest = Chef::REST.new(Chef::Config.chef_server_root)
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
83
|
+
|
84
|
+
if config[:skip_version] && config[:skip_useracl]
|
85
|
+
ui.warn("Skipping the Chef Server version check. This will also skip any auto-configured options")
|
86
|
+
user_acl_rest = nil
|
87
|
+
elsif config[:skip_version] && !config[:skip_useracl]
|
88
|
+
ui.warn("Skipping the Chef Server version check. This will also skip any auto-configured options")
|
89
|
+
user_acl_rest = rest
|
90
|
+
else # Grab Chef Server version number so that we can auto set options
|
91
|
+
uri = URI.parse("#{Chef::Config.chef_server_root}/version")
|
92
|
+
server_version = open(uri, {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE}).each_line.first.split(' ').last
|
93
|
+
server_version_parts = server_version.split('.')
|
94
|
+
|
95
|
+
if server_version_parts.count == 3
|
96
|
+
puts "Detected Enterprise Chef Server version: #{server_version}"
|
97
|
+
|
98
|
+
# All versions of Chef Server below 11.0.1 are missing the GET User ACL helper in nginx
|
99
|
+
if server_version_parts[0] < 11 || (server_version_parts[0] == 11 && server_version_parts[1] == 0 && server_version_parts[0] < 1)
|
100
|
+
#Check to see if Opscode-Account can be directly from the local machine
|
101
|
+
begin
|
102
|
+
user_acl_rest.get('users')
|
103
|
+
ui.warn("Your version of Enterprise Chef Server does not support the downloading of User ACLs. Using local connection to backup")
|
104
|
+
user_acl_rest = Chef::REST.new("http://127.0.0.1:9465")
|
105
|
+
rescue
|
106
|
+
ui.warn("Your version of Enterprise Chef Server does not support the downloading of User ACLs. Setting skip-useracl to TRUE")
|
107
|
+
config[:skip_useracl] = true
|
108
|
+
user_acl_rest = nil
|
109
|
+
end
|
99
110
|
end
|
100
|
-
end
|
101
111
|
|
102
|
-
|
103
|
-
|
112
|
+
else
|
113
|
+
ui.warn("Unable to detect Chef Server version.")
|
114
|
+
end
|
104
115
|
end
|
105
116
|
|
106
117
|
# Grab users
|
@@ -25,6 +25,11 @@ class Chef
|
|
25
25
|
:default => false,
|
26
26
|
:description => "Whether to skip restoring User ACLs. This is required for EC 11.0.2 and lower"
|
27
27
|
|
28
|
+
option :skip_version,
|
29
|
+
:long => '--skip-version-check',
|
30
|
+
:boolean => true,
|
31
|
+
:default => false,
|
32
|
+
:description => "Whether to skip checking the Chef Server version. This will also skip any auto-configured options"
|
28
33
|
|
29
34
|
deps do
|
30
35
|
require 'chef/json_compat'
|
@@ -83,23 +88,28 @@ class Chef
|
|
83
88
|
Chef::Config.chef_server_root = server_root
|
84
89
|
end
|
85
90
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
if server_version_parts
|
98
|
-
|
99
|
-
|
91
|
+
if config[:skip_version] && config[:skip_useracl]
|
92
|
+
ui.warn("Skipping the Chef Server version check. This will also skip any auto-configured options")
|
93
|
+
user_acl_rest = nil
|
94
|
+
elsif config[:skip_version] && !config[:skip_useracl]
|
95
|
+
ui.warn("Skipping the Chef Server version check. This will also skip any auto-configured options")
|
96
|
+
user_acl_rest = rest
|
97
|
+
else # Grab Chef Server version number so that we can auto set options
|
98
|
+
uri = URI.parse("#{Chef::Config.chef_server_root}/version")
|
99
|
+
server_version = open(uri, {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE}).each_line.first.split(' ').last
|
100
|
+
server_version_parts = server_version.split('.')
|
101
|
+
|
102
|
+
if server_version_parts.count == 3
|
103
|
+
puts "Detected Enterprise Chef Server version: #{server_version}"
|
104
|
+
|
105
|
+
# All versions of Chef Server below 11.0.X are unable to update user acls
|
106
|
+
if server_version_parts[0] < 11 || (server_version_parts[0] == 11 && server_version_parts[1] == 0)
|
107
|
+
ui.warn("Your version of Enterprise Chef Server does not support the updating of User ACLs. Setting skip-useracl to TRUE")
|
108
|
+
config[:skip_useracl] = true
|
109
|
+
end
|
110
|
+
else
|
111
|
+
ui.warn("Unable to detect Chef Server version.")
|
100
112
|
end
|
101
|
-
else
|
102
|
-
ui.warn("Unable to detect Chef Server version.")
|
103
113
|
end
|
104
114
|
|
105
115
|
# Restore users
|