mirror of
https://github.com/letic/terraform-provider-proxmox.git
synced 2024-10-05 02:01:04 +00:00
support retry on first ssh commands
This commit is contained in:
parent
28dbb40192
commit
39a47f793f
@ -11,6 +11,7 @@ import (
|
|||||||
"log"
|
"log"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const eth0Payload = "echo $'%s' > /tmp/tf_eth0_payload"
|
const eth0Payload = "echo $'%s' > /tmp/tf_eth0_payload"
|
||||||
@ -59,9 +60,20 @@ func preProvisionUbuntu(d *schema.ResourceData) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Print("[DEBUG] sending os_network_config")
|
log.Print("[DEBUG] sending os_network_config")
|
||||||
err = runCommand(comm, fmt.Sprintf(eth0Payload, strings.Trim(strconv.Quote(d.Get("os_network_config").(string)), "\"")))
|
|
||||||
if err != nil {
|
// on this first one allow some retries to connect
|
||||||
return err
|
rr := 0
|
||||||
|
for {
|
||||||
|
rr++
|
||||||
|
err = runCommand(comm, fmt.Sprintf(eth0Payload, strings.Trim(strconv.Quote(d.Get("os_network_config").(string)), "\"")))
|
||||||
|
if err != nil {
|
||||||
|
if rr > 3 {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
time.Sleep(2 * time.Second)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
hostname := d.Get("name").(string)
|
hostname := d.Get("name").(string)
|
||||||
|
@ -25,6 +25,7 @@ func Provider() *schema.Provider {
|
|||||||
Required: true,
|
Required: true,
|
||||||
DefaultFunc: schema.EnvDefaultFunc("PM_PASS", nil),
|
DefaultFunc: schema.EnvDefaultFunc("PM_PASS", nil),
|
||||||
Description: "secret",
|
Description: "secret",
|
||||||
|
Sensitive: true,
|
||||||
},
|
},
|
||||||
"pm_api_url": {
|
"pm_api_url": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
|
@ -95,9 +95,10 @@ func resourceVmQemu() *schema.Resource {
|
|||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
"ssh_private_key": {
|
"ssh_private_key": {
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
|
Sensitive: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user