* feat(vm): add support for cpu `affinity` attribute (#1148)
It helps to pin VMs to the special cpu.
Signed-off-by: Serge Logvinov <serge.logvinov@sinextra.dev>
* add clarification about the format and permission requirements for `affinity`
* do not add `affinity` property to the API call if is not set
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: Serge Logvinov <serge.logvinov@sinextra.dev>
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* feat(vm): add proxmox_virtual_environment_node datasource
It helps to get CPU model, number of cores and sockets.
Signed-off-by: Serge Logvinov <serge.logvinov@sinextra.dev>
* fix node_name ref
* add acceptance test
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: Serge Logvinov <serge.logvinov@sinextra.dev>
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* Fix some obvious errors, remove dead code
* Add instructions for manually adding public key to authorized_keys file
* Add GitHub context dump step and update testacc workflow condition
---------
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* feat(vm): add `VLAN` trunk support
Signed-off-by: Jack Hodgkiss <identity@jackhodgkiss.uk>
* update docs
* better error handling
* add trunks to acceptance test
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: Jack Hodgkiss <identity@jackhodgkiss.uk>
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* feat(file)!: safer snippets upload using SSH input stream
* fixes for acceptance tests on windows
* enable other OS-es for acceptance tests
* update example templates to use api token auth
---------
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* feat(provider): add support for private key authentication for SSH
Also fix bunch of issues with acceptance tests
---------
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* fix(vm): regression: `mac_addresses` list is missing some interfaces
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* add acceptance test
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
cleaning up and refactoring the VM code, add some acceptance tests around disks, few minor bugfixes
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* fix(file): use `sudo` for snippets upload
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* fix: linter
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* fix: no more rm -rf
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* feat(provider): add support for SOCKS5 proxy for SSH connection.
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* fix: linter
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* feat(provider): use `sudo` to execute commands over SSH
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* fix: simplify everything, use sudo per command
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* feat: add documentation
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* minor doc fix
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* chore: cleanup docs
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* fix(vm): missing disks when importing VM to a TF state
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* fix: add error handling
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* Use GetDatastoreFile instead of ListDatastoreFiles
Signed-off-by: CppBunny <noah@vantiggel.be>
* make linter happy
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: CppBunny <noah@vantiggel.be>
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
The default value of "ignore" was missing from the disk discard
parameter of the terraform module. This commit sets the default to
"ignore" instead of the current "".
This fixes terraform incorrectly flagging that the state is different than
what is currently running on the proxmox node when the discard option isn't
defined under the disk object.
Signed-off-by: Daniel Lowry <development@daniellowry.co.uk>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
fix: accept ipv6 in dns servers initialization
Signed-off-by: Guillaume <4112243+LEI@users.noreply.github.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* fix(provider): removed ip check/limitation to mkProviderSSHNode
It is now possible to use an FQDN instead of an IP Address when the SSH
node is configured
Changes to be committed:
modified: proxmoxtf/provider/schema.go
Signed-off-by: bitchecker <ciro.deluca@autistici.org>
* fix(docs): Updating documentation after the code updates
Signed-off-by: bitchecker <ciro.deluca@autistici.org>
---------
Signed-off-by: bitchecker <ciro.deluca@autistici.org>
* Added NetworkDevices and IPs
Removed previous limitation to 8 network interfaces/ips and moved to
new proxmox limit (up to 32)
Modifiche di cui verrà eseguito il commit:
modificato: proxmox/nodes/vms/vms_types.go
Signed-off-by: bitchecker <ciro.deluca@autistici.org>
* Code alignment for vm resource
After updates to vm_types structure definition, updated the resource
code in order to reflect changes
Modifiche di cui verrà eseguito il commit:
modificato: proxmoxtf/resource/vm.go
Signed-off-by: bitchecker <ciro.deluca@autistici.org>
* fix few typos, fix struct to state mapping
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: bitchecker <ciro.deluca@autistici.org>
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* bug(vm): fix hostpci devices not showing up in refresh plan
Signed-off-by: Michael Iseli <michael.iseli@bsi-software.com>
* fix pci & usb devices set on read, fix test
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: Michael Iseli <michael.iseli@bsi-software.com>
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* fix(vm): panic at read when cloud-init drive is on directory storage
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* fix linter, add tests
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* feat(lxc): allow to update features, add mount type support
Signed-off-by: tarik02 <taras.fomin@gmail.com>
* updates according to the MR
Signed-off-by: tarik02 <taras.fomin@gmail.com>
* update according to the pull request
Signed-off-by: tarik02 <taras.fomin@gmail.com>
---------
Signed-off-by: tarik02 <taras.fomin@gmail.com>
* fix(vm): unable to clone as non-root due to `hook_script`
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* fix linter error
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
specify right content type for backups
This now matches with the folder used by proxmox for backups
Also update documentation to reflect the change
Signed-off-by: DanielHabenicht <daniel-habenicht@outlook.de>
* fix(provider): use int64 for vm and disk storage
Signed-off-by: DanielHabenicht <daniel-habenicht@outlook.de>
* revert changes for memory
Signed-off-by: DanielHabenicht <daniel-habenicht@outlook.de>
* revert changes for memory
Signed-off-by: DanielHabenicht <daniel-habenicht@outlook.de>
* fix test
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* fix int -> int64 conversion for disk size
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: DanielHabenicht <daniel-habenicht@outlook.de>
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
fix: display warning if directory is not found
Signed-off-by: DanielHabenicht <daniel-habenicht@outlook.de>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
For SSH access, try in order:
- IPv4 address of the interface with IPv4 Gateway (if there is one)
- IPv6 address of the interface with IPv6 Gateway (if there is one)
- fallback to the first interface with IPv4 address
Signed-off-by: Oto Petřík <oto.petrik@gmail.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* fix(vm): update validation and docs for `machine` attribute.
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* chore: remove certificate resource from acceptance tests
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* feat: support usb devices for vm; fixes#665
Signed-off-by: Daniel Muehlbachler-Pietrzykowski <daniel@muehlbachler.io>
* chore: fix linter errors
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: Daniel Muehlbachler-Pietrzykowski <daniel@muehlbachler.io>
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Disks imported using `file_id` argument do not have FileVolume set,
that makes PathInDatastore return an empty string, which makes
IsOwnedBy return fales for any vm id.
The end result is the inability to resize imported disks,
this fixes it.
Signed-off-by: Oto Petřík <oto.petrik@gmail.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* feat(vm): add 'path_in_datastore' disk argument
Provide access to actual in-datastore path to disk image,
and experimental support for attaching other VM's disks or host devices.
Signed-off-by: Oto Petřík <oto.petrik@gmail.com>
* chore: added to `/example` for acceptance testing
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: Oto Petřík <oto.petrik@gmail.com>
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* feat(provider): configure temp directory
Resource 'proxmox_virtual_environment_file' often requires lot of disk
space in /tmp, which can be space-limited.
Instead of requiring to set TMPDIR environment variable before running
terraform, make it a provider configuration option.
Signed-off-by: Oto Petřík <oto.petrik@gmail.com>
* fix: lint error, align names in the `client` struct
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: Oto Petřík <oto.petrik@gmail.com>
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* feat(lxc): add support for the `start_on_boot` option
Signed-off-by: Simon Caron <simon.caron.8@gmail.com>
* Move code next to started blocks + update default value
Signed-off-by: Simon Caron <simon.caron.8@gmail.com>
---------
Signed-off-by: Simon Caron <simon.caron.8@gmail.com>
Co-authored-by: Simon Caron <simon.caron.8@gmail.com>
* fix(api): set min TLS version 1.3, secure HTTP-only cookie
* remove `all-tests-passed` job
---------
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* chore: add file test
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* add file updated test, file_name / ID is getting changed :/
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* more tests, refactor file's read, more consistency in the attributes
TODO: need to check backward compatibility
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* fix error message, enable import test
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* more tests
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* more tests for owerwrite, update docs
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* fix tests on CI
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* feat(file): FORMAT CHANGE: update **import id**, so it matches the resource's format: `<node_name>/<datastore_id>:<content_type>/<file>`
* better example
The CloudInit interface can be left empty in order to allow
autodetection of the drive being used. However, it would seem that this
value was causing problems (see #539).
This commit adds an additional validator for CloudInit interfaces which
allows the `""` value.
move `types` back from `internal` to `proxmox` and adjust a few other types, to make sure `proxmox` package is not dependent on anything else, and therefore can be extracted to a separate repo (#423)
* feat: Add optional SSH port param to node in provider ssh block
* fix: minor cleanups
---------
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* fix(vm): wait for VMs to actually stop when sending a shutdown command
Due to how a Proxmox cluster reacts to a VM shutdown command when
running in HA mode, the VM might still be running when the shutdown API
calls returns. This commit adds a loop that actively waits for the VM's
status to change to "stopped" (while also accounting for the shutdown
timeout) after the call's return.
* chore(refactoring): extracted VM state change wait loop into a separate function
* fix(vm): wait for VMs to actually start after requesting it from the cluster
This commit forces the plugin to wait for a VM to actually run after
requesting it to be started. This avoids problems with Proxmox's High
Availability mode, where a start request may not be immediately honoured
by the cluster.
* fix: linter errors
* fix: use `vmAPI.WaitForVMState`
---------
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
The datastore update support introduced in #486 only worked if the
CloudInit interface was also changed at the same time. This commit
fixes the problem.
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* feat(vm): support for migration when the node name is modified
* Added a `migrate` VM flag which changes the provider's behaviour
when the VM's `node_name` is updated. If `true`, the VM will be
migrated to the specified node instead of being re-created.
* Added a `timeout_migrate` setting to control the timeout for VM
migration.
* Fixed a bug in the API's migration data structure that prevented
the online migration flag to be set.
* fix: update description
---------
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* feat(vm): pool update support
This commit removed the ForceNew flag from the VM resource's `pool_id`
argument and implements pool update:
* if the VM was part of a pool, it is removed from it,
* if the new `pool_id` value is non-empty, the VM is added to that new
pool.
* fix: use `types.CustomCommaSeparatedList` in `PoolUpdateRequestBody` datatype, minor error fix
---------
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
fix: linter error in ambush
* This commit fixes a linter error that somehow doesn't manifest
unless some other, unrelated changes trigger it (see #501 and
#505).
* In addition it fixes a similar issue that had so far gone undetected
by the linter.
* Refactored the code in question into a function, since it was mostly
duplicated.
* Simplified a pair of conditionals that had the same code in both
branches.
* feat(provider): ensure upload of ISO/VSTMPL completes before starting VM and add timeout to config for this
* remove `ForceNew: true` for the timeout attribute
* minor docs update
---------
Co-authored-by: dandaolrian <dandaolrian@users.noreply.github.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* fix(vm): Don't add an extra efi_disk entry
* fix(vm): Don't add an extra efi_disk entry
---------
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* feat(lxc): add support for lxc mount points
* update docs and examples
* improve error handling for container creation / start operations, fix size propagation for storage mounts
---------
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* add more valid cpu types
(cherry picked from commit c62e76707b897912628adc7dda0871b3146c7aa8)
* add docs
---------
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* add import support for a lot of resources
* fix lints
* set user_id after importing
(cherry picked from commit c3d09ed00f6e1d7b0bb3ab01a1fc5c81510aa2e1)
* add tests, fix empty ID
* add import docs
* fix lint
* (fix) search for vm in cluster resources before calling node api
* (lint) search for vm in cluster resources before calling node api
* cleanup redundant error checks
---------
Co-authored-by: michalg91 <michal.gawrys@g2a.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Token logins using root@pam!sometoken=uuid are not considered
by PVE as 'root' logins, and fail to change VM's arch.
Make sure the provider does not try to set/change VM's arch.
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* efi disks support
* make size a string
* add cpu numa support
* add docs
* fix description
* string size fixes
(cherry picked from commit 254724d1d10c5191d294f0377adac49ad41dc880)
* fix lints
* fix(vm): replace `size` with `type` for efi disk
also
- add support for `pre-enrolled-keys`
- add example
- fix handling of `numa` flag when it's not in the template
- cleanup linter errors
---------
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* fix(vm): Make vm_id computed, fix#364
Defaulting vm_id to -1 prevents resources depending on vm_id value.
Make vm_id computed, also update existing vm_id = -1 with correct vm_id.
* update examples to use auto-generated `vm_id`s
---------
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
fix(code): Do not limit cluster size to 1
Allow using repeated 'node' blocks in ssh configuration.
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Fields `network_interface_names`, `ipv4_addresses` and `ipv6_addresses`
are sometimes be marked `computed` again, using `CustomizeDiff`.
Changes in `VMStarted` or `VMNetworkDevice` attributes invalidate
those values. Marking fields `computed` again avoids stale values.
`network_device` configuration block without `mac_address` results
in MAC address set to its default value (an empty string).
Terraform state expects `mac_address` to be an empty string, server
provides the actual (random) MAC address of the network device.
Terraform detects there are changes to be made, but because of
`DiffSuppressFunc` on `mac_address` they are hidden from the user,
but not from d.HasChange(mkResourceVirtualEnvironmentVMNetworkDevice)
By making `mac_address` also `computed`, the server-generated MAC
address is stored locally, avoiding spurious changes that trigger
re-computation of `network_interface_names`, `ipv4_addresses` and
`ipv6_addresses`.
* cleanup 1
* continue refactoring
* more refactoring
* move VMs under nodes
* move container and other apis under nodes
* cleanups
* enabled revive.exported linter & add comments to exported stuff
* enable godot linter
* enable wsl linter
* enable thelper linter
* enable govet linter
* cleanup after rebase
* cleanup after rebase
* extract SSH ops into a separate interface
* fix linter error
* move ssh code to its own package
* cleaning up VirtualEnvironmentClient receivers
* on the finish line
* not sure what else I forgot... 🤔
* fix ssh connection and upload
* renaming client interfaces
* final cleanups