mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-11 08:05:33 -06:00
Populate the provisioner connection info for packet.net devices with the ipv4 public address
This commit is contained in:
parent
7f95311491
commit
e2ef92f50f
@ -184,7 +184,7 @@ func resourcePacketDeviceRead(d *schema.ResourceData, meta interface{}) error {
|
|||||||
d.Set("billing_cycle", device.BillingCycle)
|
d.Set("billing_cycle", device.BillingCycle)
|
||||||
d.Set("locked", device.Locked)
|
d.Set("locked", device.Locked)
|
||||||
d.Set("created", device.Created)
|
d.Set("created", device.Created)
|
||||||
d.Set("udpated", device.Updated)
|
d.Set("updated", device.Updated)
|
||||||
|
|
||||||
tags := make([]string, 0)
|
tags := make([]string, 0)
|
||||||
for _, tag := range device.Tags {
|
for _, tag := range device.Tags {
|
||||||
@ -192,6 +192,8 @@ func resourcePacketDeviceRead(d *schema.ResourceData, meta interface{}) error {
|
|||||||
}
|
}
|
||||||
d.Set("tags", tags)
|
d.Set("tags", tags)
|
||||||
|
|
||||||
|
provisionerAddress := ""
|
||||||
|
|
||||||
networks := make([]map[string]interface{}, 0, 1)
|
networks := make([]map[string]interface{}, 0, 1)
|
||||||
for _, ip := range device.Network {
|
for _, ip := range device.Network {
|
||||||
network := make(map[string]interface{})
|
network := make(map[string]interface{})
|
||||||
@ -201,9 +203,21 @@ func resourcePacketDeviceRead(d *schema.ResourceData, meta interface{}) error {
|
|||||||
network["cidr"] = ip.Cidr
|
network["cidr"] = ip.Cidr
|
||||||
network["public"] = ip.Public
|
network["public"] = ip.Public
|
||||||
networks = append(networks, network)
|
networks = append(networks, network)
|
||||||
|
if ip.Family == 4 && ip.Public == true {
|
||||||
|
provisionerAddress = ip.Address
|
||||||
|
}
|
||||||
}
|
}
|
||||||
d.Set("network", networks)
|
d.Set("network", networks)
|
||||||
|
|
||||||
|
log.Printf("[DEBUG] Provisioner Address set to %v", provisionerAddress)
|
||||||
|
|
||||||
|
if provisionerAddress != "" {
|
||||||
|
d.SetConnInfo(map[string]string{
|
||||||
|
"type": "ssh",
|
||||||
|
"host": provisionerAddress,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user