Fix for another use case of mismanaged default value. This one was a bit trickier to spot as it triggered only when provider is authenticated using root@pam, as architecture change is allowed only for root.
Removing default value altogether, as the PVE API default for this attribute is an empty string.
VM2 resource will have no such issue, related: #1310, #1311
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* feat(lxc): Implement support for container's "protection flag"
The Proxmox VE types already has the `protection` API parameter [1],
but it is not exposed to the provider users.
This pull request implements the missing logic to make it available in
order to allow to protect containers against deletion/update operations,
including the container's disks.
[1]: https://github.com/bpg/terraform-provider-proxmox/blob/v0.63.0/proxmox/nodes/containers/containers_types.go#L59
Relates GH-1126
Signed-off-by: Sven Greb <development@svengreb.de>
* Update example/resource_virtual_environment_container.tf
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: Sven Greb <development@svengreb.de>
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* feat(file): Add support to set the file mode
GH-733 [1] implemented basic support for hook scripts, but the authors
"did not manage to find time to work on" [2] also including support to
set the file mode. This small but important feature makes the use of the
`proxmox_virtual_environment_container.hook_script_file_id` [3] and
`virtual_environment_vm.hook_script_file_id` [34] attributes basically
useless when not combined with the manual step of making the uploaded
file executable (manually running `chmod +x /path/to/script` or using
other methods, based on the storage backend). Using the
`hook_script_file_id` on its own also causes all planned and applies
changes in the same execution to not be saved in the state because the
Proxmox VE API responses with a HTTP `500` because the uploaded and
assigned file is not executable.
This pull request implements the missing feature to set the file mode
by adding a new `file_mode` attribute of type `string` where an
octal-formatted value can be passed, e.g. `0700` or only `600`.
Note that the support for the octal prefixes `0o` and `0x` are not
supported to reduced the complexity, even though Go of course support
it, including the used `os.FileMode` type [5].
Changing the file mode also causes the file to be replaced, which is
true for almost any attribute in the `proxmox_virtual_environment_file`
resource, to ensure that the file mode can also be changed after the
initial creation.
[1]: https://github.com/bpg/terraform-provider-proxmox/pull/733
[2]: https://github.com/bpg/terraform-provider-proxmox/pull/733#issuecomment-2096716738
[3]: https://registry.terraform.io/providers/bpg/proxmox/latest/docs/resources/virtual_environment_container#hook_script_file_id
[4]: https://registry.terraform.io/providers/bpg/proxmox/latest/docs/resources/virtual_environment_vm#hook_script_file_id
[5]: https://pkg.go.dev/os#FileMode
Related to GH-570
Related to GH-733
Signed-off-by: Sven Greb <development@svengreb.de>
---------
Signed-off-by: Sven Greb <development@svengreb.de>
* feat(vm): implement filtering in vms data source.
* Additional attributes for vm data source (status, template)
* fix qodana CI job condition
---------
Signed-off-by: Konstantin Kornienko <konstantin.kornienko@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(vm2): add initial support for `cdrom`
This is a breaking change comparing to v1 - switching the cdrom schema from a nested block to a nested attribute map.
Improvements comparing to v1:
- support for `ide`, `sata`, `scsi` interfaces
- support for multiple cdroms
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Split all `Custom*` structs and marshaling code into separate files from `vms_types.go`
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* misc(vm2): add support for `vga`
* fix: use random VM IDs in parallel acc tests
---------
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* fix: ignore upgrade parameter when custom cloud-init file is used
Signed-off-by: Kai <nankeen@users.noreply.github.com>
* fix acceptance tests, make `upgrade` computed
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: Kai <nankeen@users.noreply.github.com>
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Co-authored-by: Kai <nankeen@users.noreply.github.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* feat(vm): add initial support for IDE
Very broken, doesn't properly work at the moment, WIP
Signed-off-by: DevMiner <devminer@devminer.xyz>
* add acceptance test for ide disks, fixed few issues
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* update VM example
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: DevMiner <devminer@devminer.xyz>
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
Co-authored-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
* fix(vm): compare efiType value instead of address
Signed-off-by: tyxieblub <5111464+tyxieblub@users.noreply.github.com>
* update example to reproduce the error case
Signed-off-by: Pavel Boldyrev <627562+bpg@users.noreply.github.com>
---------
Signed-off-by: tyxieblub <5111464+tyxieblub@users.noreply.github.com>
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 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>