mirror of
https://github.com/letic/terraform-provider-proxmox.git
synced 2024-10-04 17:51:09 +00:00
reconnect provisioner and more docs
This commit is contained in:
parent
a2393a7c01
commit
9488f6f4a4
37
README.md
37
README.md
@ -72,5 +72,42 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
### Provider usage
|
||||||
|
You can start from either an ISO or clone an existing VM.
|
||||||
|
|
||||||
|
Optimally, you could create a VM resource you will use a clone base with an ISO, and make the rest of the VM resources depend on that base "template" and clone it.
|
||||||
|
|
||||||
|
Interesting parameters:
|
||||||
|
|
||||||
|
**ssh_forward_ip** - should be the IP or hostname of the target node or bridge IP. This is where proxmox will create a port forward to your VM with via a user_net.
|
||||||
|
|
||||||
|
**os_type** - ubuntu (https://github.com/Telmate/terraform-ubuntu-proxmox-iso) or centos (TODO: centos iso template)
|
||||||
|
|
||||||
|
|
||||||
|
### Preprovision (internal)
|
||||||
|
|
||||||
|
There is a pre-provision phase which is used to set a hostname, intialize eth0, and resize the VM disk to available space. This is done over SSH with the ssh_forward_ip, ssh_user and ssh_private_key.
|
||||||
|
|
||||||
|
Disk resize is done if the file /etc/auto_resize_vda.sh exists. Source: https://github.com/Telmate/terraform-ubuntu-proxmox-iso/blob/master/auto_resize_vda.sh
|
||||||
|
|
||||||
|
### Provisioner usage
|
||||||
|
|
||||||
|
|
||||||
|
Remove the temporary net1 adapter.
|
||||||
|
Inside the VM this usually triggers the routes back to the provisioning machine on net0.
|
||||||
|
```
|
||||||
|
provisioner "proxmox" {
|
||||||
|
action = "sshbackward"
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace the temporary net1 adapter with a new persistent net1.
|
||||||
|
```
|
||||||
|
provisioner "proxmox" {
|
||||||
|
action = "reconnect"
|
||||||
|
net1 = "virtio,bridge=vmbr0,tag=99"
|
||||||
|
}
|
||||||
|
|
||||||
|
```
|
||||||
|
If net1 needs a config other than DHCP you should prior to this use provisioner "remote-exec" to modify the network config.
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
pxapi "github.com/Telmate/proxmox-api-go/proxmox"
|
pxapi "github.com/Telmate/proxmox-api-go/proxmox"
|
||||||
"github.com/hashicorp/terraform/helper/schema"
|
"github.com/hashicorp/terraform/helper/schema"
|
||||||
"github.com/hashicorp/terraform/terraform"
|
"github.com/hashicorp/terraform/terraform"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Provisioner() terraform.ResourceProvisioner {
|
func Provisioner() terraform.ResourceProvisioner {
|
||||||
@ -51,6 +52,19 @@ func applyFn(ctx context.Context) error {
|
|||||||
switch act {
|
switch act {
|
||||||
case "sshbackward":
|
case "sshbackward":
|
||||||
return pxapi.RemoveSshForwardUsernet(vmr, client)
|
return pxapi.RemoveSshForwardUsernet(vmr, client)
|
||||||
|
|
||||||
|
case "reconnect":
|
||||||
|
err = pxapi.RemoveSshForwardUsernet(vmr, client)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
time.Sleep(5 * time.Second)
|
||||||
|
vmParams := map[string]string{
|
||||||
|
"net1": data.Get("net1").(string),
|
||||||
|
}
|
||||||
|
_, err = client.SetVmConfig(vmr, vmParams)
|
||||||
|
|
||||||
|
return err
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("Unkown action: %s", act)
|
return fmt.Errorf("Unkown action: %s", act)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user