knife-proxmox-ve 0.1.1 → 0.1.3
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 +14 -9
- data/lib/chef/knife/helpers/proxmox_vm_provision.rb +15 -11
- data/lib/chef/knife/proxmox_vm_bootstrap.rb +5 -0
- data/lib/knife-proxmox-ve/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5d5214d06c2b3094351f1e2824fc0d3e9cceba436f2053bb32001b41fe18ea5c
|
|
4
|
+
data.tar.gz: fad9ae85bb184f7dd8fdb6e54cac5a15a8f9036f1f5f4a07b939cd0a4a0e3f3a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c4d3a3bdff34585a82c46888572244512f06a7a17b94475b135f2d5f520c2b47d983e07f69cb40baa2ebc2fca8526db2cd5c6c7928ab1f778d2db28061167a05
|
|
7
|
+
data.tar.gz: 9008cdcd204db73879b3f2a4602e202d821dd70b9df217ebc8ff90e59342e7ff805c516497cd7c62970c531fd6f04df7e69f2fac84305836ba1f9faf821f7630
|
data/README.md
CHANGED
|
@@ -45,12 +45,16 @@ knife[:proxmox_clusters] = {
|
|
|
45
45
|
verify_ssl: true, # optional (default true); false warns every run
|
|
46
46
|
|
|
47
47
|
# Optional per-cluster provisioning defaults (any CLI flag overrides these):
|
|
48
|
-
storage:
|
|
49
|
-
bridge:
|
|
50
|
-
ciuser:
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
48
|
+
storage: "local-lvm",
|
|
49
|
+
bridge: "vmbr0",
|
|
50
|
+
ciuser: "ubuntu",
|
|
51
|
+
ssh_public_key: "~/.ssh/id_ed25519.pub", # default authorized key; satisfies the auth
|
|
52
|
+
# requirement without --ssh-public-key. For
|
|
53
|
+
# `vm bootstrap`, :ciuser also becomes the
|
|
54
|
+
# default --connection-user.
|
|
55
|
+
nameserver: "10.0.0.1",
|
|
56
|
+
searchdomain: "example.com",
|
|
57
|
+
target_node: nil,
|
|
54
58
|
},
|
|
55
59
|
}
|
|
56
60
|
|
|
@@ -150,13 +154,14 @@ Both commands share the provisioning flags below.
|
|
|
150
154
|
| `--bridge vmbrN` / `--vlan TAG` | net0 bridge and VLAN tag (needs a VLAN-aware bridge). |
|
|
151
155
|
| `--ip CIDR\|dhcp` / `--gateway IP` / `--prefix N` | Static IPv4 (`10.0.10.5/24`, or a bare IP with `--prefix`) or `dhcp`. |
|
|
152
156
|
| `--nameserver IP` / `--searchdomain DOMAIN` | cloud-init DNS. |
|
|
153
|
-
| `--ciuser USER` | cloud-init user. |
|
|
154
|
-
| `--ssh-public-key PATH` | Public key injected via cloud-init (preferred auth). |
|
|
157
|
+
| `--ciuser USER` | cloud-init user. For `vm bootstrap`, also the default `--connection-user`. |
|
|
158
|
+
| `--ssh-public-key PATH` | Public key injected via cloud-init (preferred auth). Falls back to the cluster's `:ssh_public_key`. |
|
|
155
159
|
| `--cipassword` | Prompt (no echo) for a cloud-init password; or set `KNIFE_PROXMOX_CIPASSWORD`. |
|
|
156
160
|
| `--clone-timeout SEC` / `--boot-timeout SEC` | Clone and boot/SSH wait limits (default 600 / 300). |
|
|
157
161
|
|
|
158
162
|
For `vm bootstrap`, the standard `knife bootstrap` options are inherited: `-N/--node-name`,
|
|
159
|
-
`-r/--run-list`, `-E/--environment`, `--connection-user
|
|
163
|
+
`-r/--run-list`, `-E/--environment`, `--connection-user` (defaults to the resolved `:ciuser`,
|
|
164
|
+
since cloud-init creates the guest account under that name), `--ssh-identity-file`,
|
|
160
165
|
`--bootstrap-version`, `--ssh-verify-host-key` (defaults to `:accept_new` for the
|
|
161
166
|
freshly-created host), `--yes`, etc. They do not apply to `vm create`, which never bootstraps.
|
|
162
167
|
|
|
@@ -13,9 +13,11 @@ class Chef
|
|
|
13
13
|
# cloud-init auth and plants it on the guest, but never touches the bootstrap connection.
|
|
14
14
|
# The bootstrap command layers that on by overriding #apply_provision_auth!.
|
|
15
15
|
module ProxmoxVmProvision
|
|
16
|
-
#
|
|
17
|
-
#
|
|
18
|
-
|
|
16
|
+
# A bridge is any Linux network interface: a classic bridge (vmbr0), an SDN VNet
|
|
17
|
+
# (arbitrary name, e.g. "mail"), an OVS bridge, a bond, etc. We only enforce what the
|
|
18
|
+
# kernel itself does on an interface name — 1..15 chars, no whitespace, no "/", and not
|
|
19
|
+
# "." or "..". IP/gateway validation is handled separately by IPAddr below.
|
|
20
|
+
BRIDGE_PATTERN = %r{\A(?!\.{1,2}\z)[^\s/]{1,15}\z}
|
|
19
21
|
|
|
20
22
|
# A pasted PRIVATE key must never travel as an authorized public key.
|
|
21
23
|
PRIVATE_KEY_MARKER = /-----BEGIN [A-Z ]*PRIVATE KEY-----/
|
|
@@ -73,8 +75,8 @@ class Chef
|
|
|
73
75
|
# --- Networking -------------------------------------------------------
|
|
74
76
|
|
|
75
77
|
option :bridge,
|
|
76
|
-
long: "--bridge
|
|
77
|
-
description: "Network bridge for net0 (e.g. vmbr0)."
|
|
78
|
+
long: "--bridge NAME",
|
|
79
|
+
description: "Network bridge for net0 (e.g. vmbr0 or an SDN VNet name)."
|
|
78
80
|
|
|
79
81
|
option :vlan,
|
|
80
82
|
long: "--vlan TAG",
|
|
@@ -108,7 +110,8 @@ class Chef
|
|
|
108
110
|
|
|
109
111
|
option :ssh_public_key,
|
|
110
112
|
long: "--ssh-public-key PATH",
|
|
111
|
-
description: "Path to an SSH PUBLIC key authorized for the cloud-init user."
|
|
113
|
+
description: "Path to an SSH PUBLIC key authorized for the cloud-init user. " \
|
|
114
|
+
"Defaults to the cluster's :ssh_public_key when set."
|
|
112
115
|
|
|
113
116
|
option :cipassword,
|
|
114
117
|
long: "--cipassword",
|
|
@@ -193,9 +196,10 @@ class Chef
|
|
|
193
196
|
def validate_bridge!
|
|
194
197
|
bridge = config[:bridge]
|
|
195
198
|
return if bridge.nil?
|
|
196
|
-
return if
|
|
199
|
+
return if BRIDGE_PATTERN.match?(bridge)
|
|
197
200
|
|
|
198
|
-
ui.fatal!("--bridge #{bridge.inspect} is not a valid
|
|
201
|
+
ui.fatal!("--bridge #{bridge.inspect} is not a valid interface name " \
|
|
202
|
+
"(1-15 chars, no whitespace or '/'; e.g. vmbr0 or an SDN VNet name)")
|
|
199
203
|
end
|
|
200
204
|
|
|
201
205
|
def validate_ip!
|
|
@@ -243,8 +247,8 @@ class Chef
|
|
|
243
247
|
return if @ssh_public_key || @cipassword
|
|
244
248
|
|
|
245
249
|
ui.fatal!(
|
|
246
|
-
"no SSH credential for the new VM: pass --ssh-public-key PATH
|
|
247
|
-
"cloud-init password via #{ENV_CIPASSWORD} or --cipassword"
|
|
250
|
+
"no SSH credential for the new VM: pass --ssh-public-key PATH (or set the cluster's " \
|
|
251
|
+
":ssh_public_key), or provide a cloud-init password via #{ENV_CIPASSWORD} or --cipassword"
|
|
248
252
|
)
|
|
249
253
|
end
|
|
250
254
|
|
|
@@ -261,7 +265,7 @@ class Chef
|
|
|
261
265
|
# looks like a private key (a common copy-paste mistake that must never be
|
|
262
266
|
# uploaded as an authorized key).
|
|
263
267
|
def resolve_ssh_public_key
|
|
264
|
-
path =
|
|
268
|
+
path = from_cli_or_cluster(:ssh_public_key)
|
|
265
269
|
return nil if blank?(path)
|
|
266
270
|
|
|
267
271
|
@ssh_public_key_path = File.expand_path(path)
|
|
@@ -95,6 +95,11 @@ class Chef
|
|
|
95
95
|
def apply_provision_auth!(spec)
|
|
96
96
|
super
|
|
97
97
|
|
|
98
|
+
# cloud-init creates the guest account as :ciuser, so the bootstrap must connect as that
|
|
99
|
+
# same user. Fall back to it when the operator did not pass an explicit --connection-user.
|
|
100
|
+
ciuser = from_cli_or_cluster(:ciuser)
|
|
101
|
+
config[:connection_user] ||= ciuser if ciuser
|
|
102
|
+
|
|
98
103
|
config[:connection_password] = @cipassword if @cipassword
|
|
99
104
|
|
|
100
105
|
return unless @ssh_public_key
|