knife-rackspace 1.0.1 → 2.0.2
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 +5 -5
- data/lib/chef/knife/rackspace_base.rb +40 -39
- data/lib/chef/knife/rackspace_flavor_list.rb +1 -1
- data/lib/chef/knife/rackspace_image_list.rb +1 -1
- data/lib/chef/knife/rackspace_network_create.rb +10 -10
- data/lib/chef/knife/rackspace_network_delete.rb +1 -1
- data/lib/chef/knife/rackspace_network_list.rb +1 -1
- data/lib/chef/knife/rackspace_server_create.rb +200 -185
- data/lib/chef/knife/rackspace_server_delete.rb +15 -17
- data/lib/chef/knife/rackspace_server_list.rb +4 -4
- data/lib/knife-rackspace/version.rb +1 -1
- data/spec/integration_spec_helper.rb +6 -6
- data/spec/unit/rackspace_base_spec.rb +3 -3
- metadata +18 -21
- data/.chef/knife.rb +0 -18
- data/.github/ISSUE_TEMPLATE.md +0 -21
- data/.gitignore +0 -36
- data/.travis.yml +0 -47
- data/CHANGELOG.md +0 -109
- data/Gemfile +0 -10
- data/README.md +0 -230
- data/Rakefile +0 -51
- data/knife-rackspace.gemspec +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4d076b1123a47563c50cc2113b132fcad24792de369fefda5d879af3def6b6fb
|
4
|
+
data.tar.gz: 55fb1c587e13f2a029783891c9cce1585e120fb6f3eb9df2fe5779775fd44982
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 445fe503b0d35b9c07151dc45ab08167ed565ff68ad060e83582976ca5b86bbf517640b76e504fc2209fa8e00a009de863382040fe7cf4eaeb985a973214a48f
|
7
|
+
data.tar.gz: c9936580b82f1d82cc204697c0644c38cf772ea135aee27b24af1ec00bd9b69e1545d5361ffde45095d569e35640b4fc6ccfad74ebf5e1be6dfa9e07aa6020b6
|
@@ -37,37 +37,37 @@ class Chef
|
|
37
37
|
end
|
38
38
|
|
39
39
|
option :rackspace_api_key,
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
40
|
+
short: "-K KEY",
|
41
|
+
long: "--rackspace-api-key KEY",
|
42
|
+
description: "Your rackspace API key",
|
43
|
+
proc: Proc.new { |key| Chef::Config[:knife][:rackspace_api_key] = key }
|
44
44
|
|
45
45
|
option :rackspace_username,
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
49
|
-
:
|
46
|
+
short: "-A USERNAME",
|
47
|
+
long: "--rackspace-username USERNAME",
|
48
|
+
description: "Your rackspace API username",
|
49
|
+
proc: Proc.new { |username| Chef::Config[:knife][:rackspace_username] = username }
|
50
50
|
|
51
51
|
option :rackspace_version,
|
52
|
-
:
|
53
|
-
:
|
54
|
-
:
|
55
|
-
:
|
52
|
+
long: "--rackspace-version VERSION",
|
53
|
+
description: "Rackspace Cloud Servers API version",
|
54
|
+
default: "v2",
|
55
|
+
proc: Proc.new { |version| Chef::Config[:knife][:rackspace_version] = version }
|
56
56
|
|
57
57
|
option :rackspace_auth_url,
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
58
|
+
long: "--rackspace-auth-url URL",
|
59
|
+
description: "Your rackspace API auth url",
|
60
|
+
proc: Proc.new { |url| Chef::Config[:knife][:rackspace_auth_url] = url }
|
61
61
|
|
62
62
|
option :rackspace_region,
|
63
|
-
:
|
64
|
-
:
|
65
|
-
:
|
63
|
+
long: "--rackspace-region REGION",
|
64
|
+
description: "Your rackspace region",
|
65
|
+
proc: Proc.new { |region| Chef::Config[:knife][:rackspace_region] = region }
|
66
66
|
|
67
67
|
option :file,
|
68
|
-
:
|
69
|
-
:
|
70
|
-
:
|
68
|
+
long: "--file DESTINATION-PATH=SOURCE-PATH",
|
69
|
+
description: "File to inject on node",
|
70
|
+
proc: Proc.new { |arg|
|
71
71
|
Chef::Config[:knife][:file] ||= []
|
72
72
|
Chef::Config[:knife][:file] << arg
|
73
73
|
}
|
@@ -94,14 +94,14 @@ class Chef
|
|
94
94
|
region_warning_for_v1
|
95
95
|
@connection ||= begin
|
96
96
|
connection = Fog::Compute.new(connection_params({
|
97
|
-
:
|
97
|
+
version: "v1",
|
98
98
|
}))
|
99
99
|
end
|
100
100
|
else
|
101
101
|
Chef::Log.debug("rackspace v2")
|
102
102
|
@connection ||= begin
|
103
103
|
connection = Fog::Compute.new(connection_params({
|
104
|
-
:
|
104
|
+
version: "v2",
|
105
105
|
}))
|
106
106
|
end
|
107
107
|
end
|
@@ -131,22 +131,22 @@ class Chef
|
|
131
131
|
end
|
132
132
|
|
133
133
|
hash = options.merge({
|
134
|
-
:
|
135
|
-
:
|
136
|
-
:
|
137
|
-
:
|
138
|
-
:
|
134
|
+
provider: "Rackspace",
|
135
|
+
rackspace_api_key: locate_config_value(:rackspace_api_key),
|
136
|
+
rackspace_username: username,
|
137
|
+
rackspace_auth_url: auth_endpoint,
|
138
|
+
rackspace_region: locate_config_value(:rackspace_region),
|
139
139
|
})
|
140
140
|
|
141
141
|
hash[:connection_options] ||= {}
|
142
|
-
Chef::Log.debug("https_proxy #{
|
143
|
-
Chef::Log.debug("http_proxy #{
|
144
|
-
if Chef::Config.
|
145
|
-
hash[:connection_options] = { :
|
142
|
+
Chef::Log.debug("https_proxy #{Chef::Config[:https_proxy] || "<not specified>"} (config)")
|
143
|
+
Chef::Log.debug("http_proxy #{Chef::Config[:http_proxy] || "<not specified>"} (config)")
|
144
|
+
if Chef::Config.key?(:https_proxy) || Chef::Config.key?(:http_proxy)
|
145
|
+
hash[:connection_options] = { proxy: Chef::Config[:https_proxy] || Chef::Config[:http_proxy] }
|
146
146
|
end
|
147
147
|
Chef::Log.debug("using proxy #{hash[:connection_options][:proxy] || "<none>"} (config)")
|
148
|
-
Chef::Log.debug("ssl_verify_peer #{Chef::Config[:knife].
|
149
|
-
hash[:connection_options][:ssl_verify_peer] = Chef::Config[:knife][:ssl_verify_peer] if Chef::Config[:knife].
|
148
|
+
Chef::Log.debug("ssl_verify_peer #{Chef::Config[:knife].key?(:ssl_verify_peer) ? Chef::Config[:knife][:ssl_verify_peer] : "<not specified>"} (config)")
|
149
|
+
hash[:connection_options][:ssl_verify_peer] = Chef::Config[:knife][:ssl_verify_peer] if Chef::Config[:knife].key?(:ssl_verify_peer)
|
150
150
|
|
151
151
|
hash
|
152
152
|
end
|
@@ -154,6 +154,7 @@ class Chef
|
|
154
154
|
def auth_endpoint
|
155
155
|
url = locate_config_value(:rackspace_auth_url)
|
156
156
|
return url if url
|
157
|
+
|
157
158
|
(locate_config_value(:rackspace_region) == "lon") ? ::Fog::Rackspace::UK_AUTH_ENDPOINT : ::Fog::Rackspace::US_AUTH_ENDPOINT
|
158
159
|
end
|
159
160
|
|
@@ -188,8 +189,8 @@ class Chef
|
|
188
189
|
if public_ip_address = ip_address(server, "public")
|
189
190
|
@public_dns_name ||= begin
|
190
191
|
Resolv.getname(public_ip_address)
|
191
|
-
|
192
|
-
|
192
|
+
rescue
|
193
|
+
"#{public_ip_address}.xip.io"
|
193
194
|
end
|
194
195
|
end
|
195
196
|
end
|
@@ -206,11 +207,11 @@ class Chef
|
|
206
207
|
end
|
207
208
|
|
208
209
|
def v1_public_ip(server)
|
209
|
-
server.public_ip_address
|
210
|
+
server.public_ip_address.nil? ? "" : server.public_ip_address
|
210
211
|
end
|
211
212
|
|
212
213
|
def v1_private_ip(server)
|
213
|
-
server.addresses["private"].first
|
214
|
+
server.addresses["private"].first.nil? ? "" : server.addresses["private"].first
|
214
215
|
end
|
215
216
|
|
216
217
|
def v2_ip_address(server, network)
|
@@ -219,7 +220,7 @@ class Chef
|
|
219
220
|
end
|
220
221
|
|
221
222
|
def v2_access_ip(server)
|
222
|
-
server.access_ipv4_address
|
223
|
+
server.access_ipv4_address.nil? ? "" : server.access_ipv4_address
|
223
224
|
end
|
224
225
|
|
225
226
|
def extract_ipv4_address(ip_addresses)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative "rackspace_base"
|
2
2
|
|
3
3
|
class Chef
|
4
4
|
class Knife
|
@@ -9,16 +9,16 @@ class Chef
|
|
9
9
|
banner "knife rackspace network create (options)"
|
10
10
|
|
11
11
|
option :label,
|
12
|
-
:
|
13
|
-
:
|
14
|
-
:
|
15
|
-
:
|
12
|
+
short: "-L LABEL",
|
13
|
+
long: "--label LABEL",
|
14
|
+
description: "Label for the network",
|
15
|
+
required: true
|
16
16
|
|
17
17
|
option :cidr,
|
18
|
-
:
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
18
|
+
short: "-C CIDR",
|
19
|
+
long: "--cidr CIDR",
|
20
|
+
description: "CIDR for the network",
|
21
|
+
required: true
|
22
22
|
|
23
23
|
def run
|
24
24
|
if version_one?
|
@@ -32,7 +32,7 @@ class Chef
|
|
32
32
|
]
|
33
33
|
end
|
34
34
|
options = {}
|
35
|
-
|
35
|
+
%i{cidr label}.each do |key|
|
36
36
|
options[key] = config[key]
|
37
37
|
end
|
38
38
|
net = connection.networks.create(options)
|
@@ -17,7 +17,7 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
|
20
|
+
require_relative "rackspace_base"
|
21
21
|
require "chef/knife/winrm_base"
|
22
22
|
require "chef/knife"
|
23
23
|
|
@@ -41,240 +41,256 @@ class Chef
|
|
41
41
|
attr_accessor :initial_sleep_delay
|
42
42
|
|
43
43
|
option :flavor,
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
48
|
-
:
|
44
|
+
short: "-f FLAVOR",
|
45
|
+
long: "--flavor FLAVOR",
|
46
|
+
description: "The flavor of server; default is 2 (512 MB)",
|
47
|
+
proc: Proc.new { |f| Chef::Config[:knife][:flavor] = f.to_s },
|
48
|
+
default: "2"
|
49
49
|
|
50
50
|
option :image,
|
51
|
-
:
|
52
|
-
:
|
53
|
-
:
|
54
|
-
:
|
51
|
+
short: "-I IMAGE",
|
52
|
+
long: "--image IMAGE",
|
53
|
+
description: "The image of the server",
|
54
|
+
proc: Proc.new { |i| Chef::Config[:knife][:image] = i.to_s }
|
55
55
|
|
56
56
|
option :boot_volume_size,
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
57
|
+
long: "--boot-volume-size GB",
|
58
|
+
description: "The size of the CBS to use as the server's boot device",
|
59
|
+
proc: Proc.new { |i| Chef::Config[:knife][:boot_volume_size] = i.to_s },
|
60
|
+
default: 100
|
61
61
|
|
62
62
|
option :boot_volume_id,
|
63
|
-
:
|
64
|
-
:
|
65
|
-
:
|
66
|
-
:
|
63
|
+
short: "-B BOOT_VOLUME_ID",
|
64
|
+
long: "--boot-volume-id UUID",
|
65
|
+
description: "The image CBS UUID to use as the server's boot device",
|
66
|
+
proc: Proc.new { |i| Chef::Config[:knife][:boot_volume_id] = i.to_s }
|
67
67
|
|
68
68
|
option :server_name,
|
69
|
-
:
|
70
|
-
:
|
71
|
-
:
|
69
|
+
short: "-S NAME",
|
70
|
+
long: "--server-name NAME",
|
71
|
+
description: "The server name"
|
72
72
|
|
73
73
|
option :chef_node_name,
|
74
|
-
:
|
75
|
-
:
|
76
|
-
:
|
74
|
+
short: "-N NAME",
|
75
|
+
long: "--node-name NAME",
|
76
|
+
description: "The Chef node name for your new node"
|
77
77
|
|
78
78
|
option :bootstrap_network,
|
79
|
-
:
|
80
|
-
:
|
81
|
-
:
|
79
|
+
long: "--bootstrap-network LABEL",
|
80
|
+
description: "Use IP address on this network for bootstrap",
|
81
|
+
default: "public"
|
82
82
|
|
83
83
|
option :private_network,
|
84
|
-
:
|
85
|
-
:
|
86
|
-
:
|
87
|
-
:
|
84
|
+
long: "--private-network",
|
85
|
+
description: "Equivalent to --bootstrap-network private",
|
86
|
+
boolean: true,
|
87
|
+
default: false
|
88
88
|
|
89
89
|
option :ssh_user,
|
90
|
-
:
|
91
|
-
:
|
92
|
-
:
|
93
|
-
:
|
90
|
+
short: "-x USERNAME",
|
91
|
+
long: "--ssh-user USERNAME",
|
92
|
+
description: "The ssh username; default is 'root'",
|
93
|
+
default: "root"
|
94
94
|
|
95
95
|
option :ssh_password,
|
96
|
-
:
|
97
|
-
:
|
98
|
-
:
|
96
|
+
short: "-P PASSWORD",
|
97
|
+
long: "--ssh-password PASSWORD",
|
98
|
+
description: "The ssh password"
|
99
99
|
|
100
100
|
option :ssh_port,
|
101
|
-
:
|
102
|
-
:
|
103
|
-
:
|
104
|
-
:
|
105
|
-
:
|
101
|
+
short: "-p PORT",
|
102
|
+
long: "--ssh-port PORT",
|
103
|
+
description: "The ssh port",
|
104
|
+
default: "22",
|
105
|
+
proc: Proc.new { |key| Chef::Config[:knife][:ssh_port] = key }
|
106
106
|
|
107
107
|
option :identity_file,
|
108
|
-
:
|
109
|
-
:
|
110
|
-
:
|
108
|
+
short: "-i IDENTITY_FILE",
|
109
|
+
long: "--identity-file IDENTITY_FILE",
|
110
|
+
description: "The SSH identity file used for authentication"
|
111
111
|
|
112
112
|
option :prerelease,
|
113
|
-
:
|
114
|
-
:
|
115
|
-
:
|
113
|
+
long: "--prerelease",
|
114
|
+
description: "Install the pre-release chef gems",
|
115
|
+
default: false
|
116
116
|
|
117
117
|
option :bootstrap_version,
|
118
|
-
:
|
119
|
-
:
|
120
|
-
:
|
118
|
+
long: "--bootstrap-version VERSION",
|
119
|
+
description: "The version of Chef to install",
|
120
|
+
proc: Proc.new { |v| Chef::Config[:knife][:bootstrap_version] = v }
|
121
121
|
|
122
122
|
option :distro,
|
123
|
-
:
|
124
|
-
:
|
125
|
-
:
|
126
|
-
:
|
123
|
+
short: "-d DISTRO",
|
124
|
+
long: "--distro DISTRO",
|
125
|
+
description: "Bootstrap a distro using a template. [DEPRECATED] Use -t / --bootstrap-template option instead.",
|
126
|
+
proc: Proc.new { |v|
|
127
|
+
Chef::Log.fatal("[DEPRECATED] -d / --distro option is deprecated. Use --bootstrap-template option instead.")
|
128
|
+
v
|
129
|
+
}
|
127
130
|
|
131
|
+
# @todo When we no longer support Chef 13 this can just go away
|
128
132
|
option :template_file,
|
129
|
-
:
|
130
|
-
:
|
131
|
-
:
|
132
|
-
|
133
|
+
long: "--template-file TEMPLATE",
|
134
|
+
description: "Full path to location of template to use. [DEPRECATED] Use -t / --bootstrap-template option instead.",
|
135
|
+
proc: Proc.new { |v|
|
136
|
+
Chef::Log.fatal("[DEPRECATED] --template-file option is deprecated. Use --bootstrap-template option instead.")
|
137
|
+
v
|
138
|
+
}
|
139
|
+
|
140
|
+
option :bootstrap_template,
|
141
|
+
short: "-t TEMPLATE",
|
142
|
+
long: "--bootstrap-template TEMPLATE",
|
143
|
+
description: "Bootstrap Chef using a built-in or custom template. Set to the full path of an erb template or use one of the built-in templates."
|
133
144
|
|
134
145
|
option :run_list,
|
135
|
-
:
|
136
|
-
:
|
137
|
-
:
|
138
|
-
:
|
139
|
-
:
|
146
|
+
short: "-r RUN_LIST",
|
147
|
+
long: "--run-list RUN_LIST",
|
148
|
+
description: "Comma separated list of roles/recipes to apply",
|
149
|
+
proc: lambda { |o| o.split(/[\s,]+/) },
|
150
|
+
default: []
|
140
151
|
|
141
152
|
option :first_boot_attributes,
|
142
|
-
:
|
143
|
-
:
|
144
|
-
:
|
145
|
-
:
|
146
|
-
:
|
153
|
+
short: "-j JSON_ATTRIBS",
|
154
|
+
long: "--json-attributes",
|
155
|
+
description: "A JSON string to be added to the first run of chef-client",
|
156
|
+
proc: lambda { |o| JSON.parse(o) },
|
157
|
+
default: {}
|
147
158
|
|
148
159
|
option :rackspace_metadata,
|
149
|
-
:
|
150
|
-
:
|
151
|
-
:
|
152
|
-
:
|
153
|
-
:
|
160
|
+
short: "-M JSON",
|
161
|
+
long: "--rackspace-metadata JSON",
|
162
|
+
description: "JSON string version of metadata hash to be supplied with the server create call",
|
163
|
+
proc: lambda { |m| JSON.parse(m) },
|
164
|
+
default: {}
|
154
165
|
|
155
166
|
option :rackconnect_wait,
|
156
|
-
:
|
157
|
-
:
|
158
|
-
:
|
159
|
-
:
|
167
|
+
long: "--rackconnect-wait",
|
168
|
+
description: "Wait until the Rackconnect automation setup is complete before bootstrapping chef",
|
169
|
+
boolean: true,
|
170
|
+
default: false
|
160
171
|
|
161
172
|
option :rackconnect_v3_network_id,
|
162
|
-
:
|
163
|
-
:
|
164
|
-
:
|
165
|
-
:
|
173
|
+
long: "--rackconnect-v3-network-id ID",
|
174
|
+
description: "Rackconnect V3 ONLY: Link a new server to an existing network",
|
175
|
+
proc: lambda { |o| Chef::Config[:knife][:rackconnect_v3_network_id] = o },
|
176
|
+
default: nil
|
166
177
|
|
167
178
|
option :rackspace_servicelevel_wait,
|
168
|
-
:
|
169
|
-
:
|
170
|
-
:
|
171
|
-
:
|
179
|
+
long: "--rackspace-servicelevel-wait",
|
180
|
+
description: "Wait until the Rackspace service level automation setup is complete before bootstrapping chef",
|
181
|
+
boolean: true,
|
182
|
+
default: false
|
172
183
|
|
173
184
|
option :hint,
|
174
|
-
:
|
175
|
-
:
|
176
|
-
:
|
185
|
+
long: "--hint HINT_NAME[=HINT_FILE]",
|
186
|
+
description: "Specify Ohai Hint to be set on the bootstrap target. Use multiple --hint options to specify multiple hints.",
|
187
|
+
proc: Proc.new { |h|
|
177
188
|
Chef::Config[:knife][:hints] ||= {}
|
178
189
|
name, path = h.split("=")
|
179
|
-
Chef::Config[:knife][:hints][name] = path ? JSON.parse(::File.read(path)) :
|
190
|
+
Chef::Config[:knife][:hints][name] = path ? JSON.parse(::File.read(path)) : {}
|
180
191
|
}
|
181
192
|
|
182
193
|
option :host_key_verify,
|
183
|
-
:
|
184
|
-
:
|
185
|
-
:
|
186
|
-
:
|
194
|
+
long: "--[no-]host-key-verify",
|
195
|
+
description: "Verify host key, enabled by default",
|
196
|
+
boolean: true,
|
197
|
+
default: true
|
187
198
|
|
188
199
|
option :tcp_test_ssh,
|
189
|
-
:
|
190
|
-
:
|
191
|
-
:
|
192
|
-
:
|
200
|
+
long: "--[no-]tcp-test-ssh",
|
201
|
+
description: "Check that SSH is available using a TCP check directly on port 22, enabled by default",
|
202
|
+
boolean: true,
|
203
|
+
default: true
|
193
204
|
|
194
205
|
option :ssh_wait_timeout,
|
195
|
-
:
|
196
|
-
:
|
197
|
-
:
|
206
|
+
long: "--ssh-wait-timeout TIMEOUT",
|
207
|
+
description: "The ssh wait timeout, before attempting ssh",
|
208
|
+
default: "0"
|
198
209
|
|
199
210
|
option :retry_ssh_every,
|
200
|
-
:
|
201
|
-
:
|
202
|
-
:
|
211
|
+
long: "--retry-ssh-every TIMEOUT",
|
212
|
+
description: "Retry SSH after n seconds (retry each period)",
|
213
|
+
default: "5"
|
203
214
|
|
204
215
|
option :retry_ssh_limit,
|
205
|
-
:
|
206
|
-
:
|
207
|
-
:
|
216
|
+
long: "--retry-ssh-limit COUNT",
|
217
|
+
description: "Retry SSH at most this number of times",
|
218
|
+
default: "5"
|
208
219
|
|
209
220
|
option :default_networks,
|
210
|
-
:
|
211
|
-
:
|
212
|
-
:
|
213
|
-
:
|
221
|
+
long: "--[no-]default-networks",
|
222
|
+
description: "Include public and service networks, enabled by default",
|
223
|
+
boolean: true,
|
224
|
+
default: true
|
214
225
|
|
215
226
|
option :network,
|
216
|
-
:
|
217
|
-
:
|
218
|
-
:
|
227
|
+
long: "--network [LABEL_OR_ID]",
|
228
|
+
description: "Add private network. Use multiple --network options to specify multiple networks.",
|
229
|
+
proc: Proc.new { |name|
|
219
230
|
Chef::Config[:knife][:rackspace_networks] ||= []
|
220
231
|
(Chef::Config[:knife][:rackspace_networks] << name).uniq!
|
221
232
|
}
|
222
233
|
|
223
234
|
option :bootstrap_protocol,
|
224
|
-
:
|
225
|
-
:
|
226
|
-
:
|
235
|
+
long: "--bootstrap-protocol protocol",
|
236
|
+
description: "Protocol to bootstrap Windows servers. options: winrm",
|
237
|
+
default: nil
|
227
238
|
|
228
239
|
option :server_create_timeout,
|
229
|
-
:
|
230
|
-
:
|
231
|
-
:
|
232
|
-
:
|
240
|
+
long: "--server-create-timeout timeout",
|
241
|
+
description: "How long to wait until the server is ready; default is 1200 seconds",
|
242
|
+
default: 1200,
|
243
|
+
proc: Proc.new { |v| Chef::Config[:knife][:server_create_timeout] = v }
|
233
244
|
|
234
245
|
option :bootstrap_proxy,
|
235
|
-
:
|
236
|
-
:
|
237
|
-
:
|
246
|
+
long: "--bootstrap-proxy PROXY_URL",
|
247
|
+
description: "The proxy server for the node being bootstrapped",
|
248
|
+
proc: Proc.new { |v| Chef::Config[:knife][:bootstrap_proxy] = v }
|
238
249
|
|
239
250
|
option :rackspace_disk_config,
|
240
|
-
:
|
241
|
-
:
|
242
|
-
:
|
251
|
+
long: "--rackspace-disk-config DISKCONFIG",
|
252
|
+
description: "Specify if want to manage your own disk partitioning scheme (AUTO or MANUAL)",
|
253
|
+
proc: Proc.new { |k| Chef::Config[:knife][:rackspace_disk_config] = k }
|
243
254
|
|
244
255
|
option :rackspace_config_drive,
|
245
|
-
:
|
246
|
-
:
|
247
|
-
:
|
248
|
-
:
|
256
|
+
long: "--rackspace_config_drive CONFIGDRIVE",
|
257
|
+
description: "Creates a config drive device in /dev/disk/by-label/config-2 if set to TRUE",
|
258
|
+
proc: Proc.new { |k| Chef::Config[:knife][:rackspace_config_drive] = k },
|
259
|
+
default: "false"
|
249
260
|
|
250
261
|
option :rackspace_user_data_file,
|
251
|
-
:
|
252
|
-
:
|
253
|
-
:
|
262
|
+
long: "--rackspace_user_data_file USERDATA",
|
263
|
+
description: "User data file will be placed in the openstack/latest/user_data directory on the config drive",
|
264
|
+
proc: Proc.new { |k| Chef::Config[:knife][:rackspace_user_data] = k }
|
254
265
|
|
255
266
|
option :ssh_keypair,
|
256
|
-
:
|
257
|
-
:
|
258
|
-
:
|
259
|
-
:
|
267
|
+
long: "--ssh-keypair KEYPAIR_NAME",
|
268
|
+
description: "Name of existing nova SSH keypair. Public key will be injected into the instance.",
|
269
|
+
proc: Proc.new { |v| Chef::Config[:knife][:rackspace_ssh_keypair] = v },
|
270
|
+
default: nil
|
271
|
+
|
272
|
+
option :secret,
|
273
|
+
long: "--secret",
|
274
|
+
description: "The secret key to us to encrypt data bag item values",
|
275
|
+
proc: lambda { |s| Chef::Config[:knife][:secret] = s }
|
260
276
|
|
261
277
|
option :secret_file,
|
262
|
-
:
|
263
|
-
:
|
264
|
-
:
|
278
|
+
long: "--secret-file SECRET_FILE",
|
279
|
+
description: "A file containing the secret key to use to encrypt data bag item values",
|
280
|
+
proc: lambda { |sf| Chef::Config[:knife][:secret_file] = sf }
|
265
281
|
|
266
282
|
option :bootstrap_vault_file,
|
267
|
-
:
|
268
|
-
:
|
283
|
+
long: "--bootstrap-vault-file VAULT_FILE",
|
284
|
+
description: "A JSON file with a list of vault(s) and item(s) to be updated"
|
269
285
|
|
270
286
|
option :bootstrap_vault_json,
|
271
|
-
:
|
272
|
-
:
|
287
|
+
long: "--bootstrap-vault-json VAULT_JSON",
|
288
|
+
description: "A JSON string with the vault(s) and item(s) to be updated"
|
273
289
|
|
274
290
|
option :bootstrap_vault_item,
|
275
|
-
:
|
276
|
-
:
|
277
|
-
:
|
291
|
+
long: "--bootstrap-vault-item VAULT_ITEM",
|
292
|
+
description: 'A single vault and item to update as "vault:item"',
|
293
|
+
proc: Proc.new { |i|
|
278
294
|
(vault, item) = i.split(/:/)
|
279
295
|
Chef::Config[:knife][:bootstrap_vault_item] ||= {}
|
280
296
|
Chef::Config[:knife][:bootstrap_vault_item][vault] ||= []
|
@@ -284,20 +300,19 @@ class Chef
|
|
284
300
|
|
285
301
|
def load_winrm_deps
|
286
302
|
require "winrm"
|
287
|
-
require "
|
303
|
+
require "chef/knife/winrm"
|
288
304
|
require "chef/knife/bootstrap_windows_winrm"
|
289
305
|
require "chef/knife/core/windows_bootstrap_context"
|
290
|
-
require "chef/knife/winrm"
|
291
306
|
end
|
292
307
|
|
293
308
|
def tcp_test_ssh(server, bootstrap_ip)
|
294
|
-
return true
|
309
|
+
return true if locate_config_value(:tcp_test_ssh).nil?
|
295
310
|
|
296
311
|
limit = locate_config_value(:retry_ssh_limit).to_i
|
297
312
|
count = 0
|
298
313
|
|
299
314
|
begin
|
300
|
-
Net::SSH.start(bootstrap_ip, "root", :
|
315
|
+
Net::SSH.start(bootstrap_ip, "root", password: server.password ) do |ssh|
|
301
316
|
Chef::Log.debug("sshd accepting connections on #{bootstrap_ip}")
|
302
317
|
break
|
303
318
|
end
|
@@ -343,16 +358,16 @@ class Chef
|
|
343
358
|
dest, src = parse_file_argument(arg)
|
344
359
|
Chef::Log.debug("Inject file #{src} into #{dest}")
|
345
360
|
files << {
|
346
|
-
:
|
347
|
-
:
|
361
|
+
path: dest,
|
362
|
+
contents: encode_file(src),
|
348
363
|
}
|
349
364
|
end
|
350
365
|
files
|
351
366
|
end
|
352
367
|
|
353
368
|
def tcp_test_winrm(hostname, port)
|
354
|
-
TCPSocket.new(hostname, port)
|
355
|
-
|
369
|
+
tcp_socket = TCPSocket.new(hostname, port)
|
370
|
+
true
|
356
371
|
rescue SocketError
|
357
372
|
sleep 2
|
358
373
|
false
|
@@ -369,20 +384,21 @@ class Chef
|
|
369
384
|
rescue Errno::ENETUNREACH
|
370
385
|
sleep 2
|
371
386
|
false
|
387
|
+
tcp_socket && tcp_socket.close
|
372
388
|
end
|
373
389
|
|
374
390
|
def run
|
375
391
|
$stdout.sync = true
|
376
392
|
|
377
393
|
server_create_options = {
|
378
|
-
:
|
379
|
-
:
|
380
|
-
:
|
381
|
-
:
|
382
|
-
:
|
383
|
-
:
|
384
|
-
:
|
385
|
-
:
|
394
|
+
metadata: locate_config_value(:rackspace_metadata),
|
395
|
+
disk_config: locate_config_value(:rackspace_disk_config),
|
396
|
+
user_data: user_data,
|
397
|
+
config_drive: locate_config_value(:rackspace_config_drive) || false,
|
398
|
+
personality: files,
|
399
|
+
key_name: locate_config_value(:rackspace_ssh_keypair),
|
400
|
+
name: get_node_name(config[:chef_node_name] || config[:server_name]),
|
401
|
+
networks: get_networks(locate_config_value(:rackspace_networks), locate_config_value(:rackconnect_v3_network_id)),
|
386
402
|
}
|
387
403
|
|
388
404
|
# Maybe deprecate this option at some point
|
@@ -415,7 +431,7 @@ class Chef
|
|
415
431
|
else
|
416
432
|
server_create_options[:image_id] = locate_config_value(:image)
|
417
433
|
|
418
|
-
|
434
|
+
unless server_create_options[:image_id]
|
419
435
|
ui.error("Please specify an Image ID for the server with --image (-I)")
|
420
436
|
exit 1
|
421
437
|
end
|
@@ -430,7 +446,7 @@ class Chef
|
|
430
446
|
if version_one?
|
431
447
|
server.save
|
432
448
|
else
|
433
|
-
server.save(:
|
449
|
+
server.save(networks: server_create_options[:networks])
|
434
450
|
end
|
435
451
|
|
436
452
|
rackconnect_wait = locate_config_value(:rackconnect_wait)
|
@@ -453,18 +469,18 @@ class Chef
|
|
453
469
|
# wait for it to be ready to do stuff
|
454
470
|
begin
|
455
471
|
server.wait_for(Integer(locate_config_value(:server_create_timeout))) do
|
456
|
-
print "."
|
472
|
+
print "."
|
457
473
|
Chef::Log.debug("#{progress}%")
|
458
474
|
|
459
475
|
if rackconnect_wait && rackspace_servicelevel_wait
|
460
|
-
Chef::Log.debug("rackconnect_automation_status: #{metadata.all[
|
461
|
-
Chef::Log.debug("rax_service_level_automation: #{metadata.all[
|
476
|
+
Chef::Log.debug("rackconnect_automation_status: #{metadata.all["rackconnect_automation_status"]}")
|
477
|
+
Chef::Log.debug("rax_service_level_automation: #{metadata.all["rax_service_level_automation"]}")
|
462
478
|
ready? && metadata.all["rackconnect_automation_status"] == "DEPLOYED" && metadata.all["rax_service_level_automation"] == "Complete"
|
463
479
|
elsif rackconnect_wait
|
464
|
-
Chef::Log.debug("rackconnect_automation_status: #{metadata.all[
|
480
|
+
Chef::Log.debug("rackconnect_automation_status: #{metadata.all["rackconnect_automation_status"]}")
|
465
481
|
ready? && metadata.all["rackconnect_automation_status"] == "DEPLOYED"
|
466
482
|
elsif rackspace_servicelevel_wait
|
467
|
-
Chef::Log.debug("rax_service_level_automation: #{metadata.all[
|
483
|
+
Chef::Log.debug("rax_service_level_automation: #{metadata.all["rax_service_level_automation"]}")
|
468
484
|
ready? && metadata.all["rax_service_level_automation"] == "Complete"
|
469
485
|
else
|
470
486
|
ready?
|
@@ -475,7 +491,7 @@ class Chef
|
|
475
491
|
msg_pair("Progress", "#{server.progress}%")
|
476
492
|
msg_pair("rackconnect_automation_status", server.metadata.all["rackconnect_automation_status"])
|
477
493
|
msg_pair("rax_service_level_automation", server.metadata.all["rax_service_level_automation"])
|
478
|
-
Chef::Application.fatal!
|
494
|
+
Chef::Application.fatal! "Server didn't finish on time"
|
479
495
|
end
|
480
496
|
|
481
497
|
msg_pair("Metadata", server.metadata)
|
@@ -584,7 +600,6 @@ class Chef
|
|
584
600
|
bootstrap.config[:bootstrap_vault_item] = locate_config_value(:bootstrap_vault_item) if locate_config_value(:bootstrap_vault_item)
|
585
601
|
# bootstrap will run as root...sudo (by default) also messes up Ohai on CentOS boxes
|
586
602
|
bootstrap.config[:use_sudo] = true unless locate_config_value(:ssh_user) == "root"
|
587
|
-
bootstrap.config[:distro] = locate_config_value(:distro) || "chef-full"
|
588
603
|
bootstrap_common_params(bootstrap, server)
|
589
604
|
end
|
590
605
|
|
@@ -598,14 +613,13 @@ class Chef
|
|
598
613
|
end
|
599
614
|
bootstrap.config[:prerelease] = locate_config_value(:prerelease)
|
600
615
|
bootstrap.config[:bootstrap_version] = locate_config_value(:bootstrap_version)
|
601
|
-
bootstrap.config[:
|
616
|
+
bootstrap.config[:bootstrap_template] = locate_config_value(:bootstrap_template)
|
602
617
|
bootstrap.config[:first_boot_attributes] = locate_config_value(:first_boot_attributes)
|
603
618
|
bootstrap.config[:bootstrap_proxy] = locate_config_value(:bootstrap_proxy)
|
604
|
-
|
605
|
-
|
606
|
-
# bootstrap.config[:encrypted_data_bag_secret_file] = config[:encrypted_data_bag_secret_file]
|
619
|
+
bootstrap.config[:encrypted_data_bag_secret] = locate_config_value(:secret)
|
620
|
+
bootstrap.config[:encrypted_data_bag_secret_file] = locate_config_value(:secret_file)
|
607
621
|
bootstrap.config[:secret] = locate_config_value(:secret)
|
608
|
-
bootstrap.config[:secret_file] = locate_config_value(:secret_file)
|
622
|
+
bootstrap.config[:secret_file] = locate_config_value(:secret_file)
|
609
623
|
|
610
624
|
Chef::Config[:knife][:hints] ||= {}
|
611
625
|
Chef::Config[:knife][:hints]["rackspace"] ||= {}
|
@@ -624,10 +638,11 @@ class Chef
|
|
624
638
|
end
|
625
639
|
|
626
640
|
end
|
627
|
-
#v2 servers require a name, random if chef_node_name is empty, empty if v1
|
641
|
+
# v2 servers require a name, random if chef_node_name is empty, empty if v1
|
628
642
|
def get_node_name(chef_node_name)
|
629
643
|
return chef_node_name unless chef_node_name.nil?
|
630
|
-
|
644
|
+
|
645
|
+
# lazy uuids
|
631
646
|
chef_node_name = "rs-" + rand.to_s.split(".")[1] unless version_one?
|
632
647
|
end
|
633
648
|
|
@@ -638,10 +653,10 @@ class Chef
|
|
638
653
|
nets = if rackconnect3
|
639
654
|
[locate_config_value(:rackconnect_v3_network_id)]
|
640
655
|
elsif locate_config_value(:default_networks)
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
656
|
+
%w{
|
657
|
+
00000000-0000-0000-0000-000000000000
|
658
|
+
11111111-1111-1111-1111-111111111111
|
659
|
+
}
|
645
660
|
else
|
646
661
|
[]
|
647
662
|
end
|