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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2bfa352b40db68621f19322cdb1dfc060c37ac3faafa423d37b76c9ccd7d544f
4
- data.tar.gz: 1f819e5625acbb197012847d54d15e6bace8b71108d3ad867b9fbb2ee0b8944e
3
+ metadata.gz: 5d5214d06c2b3094351f1e2824fc0d3e9cceba436f2053bb32001b41fe18ea5c
4
+ data.tar.gz: fad9ae85bb184f7dd8fdb6e54cac5a15a8f9036f1f5f4a07b939cd0a4a0e3f3a
5
5
  SHA512:
6
- metadata.gz: e185dc631d2d81abdfa6a0e5e1a3772bc66b8db9096f1fc4a358aa910b52c549f8a3c3b1bde159509b7b7dcc8decbc1433fbc10e56731428b69ce764d1162ea1
7
- data.tar.gz: 26bf397b78eb7e03f832e506ff34ca026e370c416fb5ec2f1a7c2e4428c915229f851a68e404cec34ceb801f1fd8ee9790bdaec0673480e15f53405d45661453
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: "local-lvm",
49
- bridge: "vmbr0",
50
- ciuser: "ubuntu",
51
- nameserver: "10.0.0.1",
52
- searchdomain: "example.com",
53
- target_node: nil,
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`, `--ssh-identity-file`,
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
- # Proxmox bridge interface names: "vmbr" followed by digits (vmbr0, vmbr1, ...).
17
- # IP/gateway validation is handled separately by IPAddr in #validate_ip!/#validate_gateway!.
18
- VMBR_PATTERN = /\Avmbr\d+\z/
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 vmbrN",
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 VMBR_PATTERN.match?(bridge)
199
+ return if BRIDGE_PATTERN.match?(bridge)
197
200
 
198
- ui.fatal!("--bridge #{bridge.inspect} is not a valid bridge name (expected vmbrN, e.g. vmbr0)")
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, or provide a " \
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 = config[:ssh_public_key]
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Knife
4
4
  module Proxmox
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.3"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-proxmox-ve
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Wojcieszonek