mirror of
https://github.com/bunkerity/bunkerweb
synced 2026-05-24 09:28:37 +00:00
ci/cd - retrieve private IPs from IPAM
This commit is contained in:
parent
d49ad54f28
commit
690782174c
1 changed files with 15 additions and 4 deletions
|
|
@ -30,16 +30,27 @@ resource "scaleway_instance_server" "instances" {
|
|||
image = "debian_bookworm"
|
||||
routed_ip_enabled = true
|
||||
ip_id = var.swarm_ips_id[count.index]
|
||||
private_network {
|
||||
pn_id = scaleway_vpc_private_network.pn.id
|
||||
}
|
||||
}
|
||||
|
||||
# Attach to PVC
|
||||
resource "scaleway_instance_private_nic" "nics" {
|
||||
count = 3
|
||||
server_id = scaleway_instance_server.instances[count.index].id
|
||||
private_network_id = scaleway_vpc_private_network.pn.id
|
||||
}
|
||||
|
||||
# Retrieve private IPs
|
||||
data "scaleway_ipam_ip" "ips" {
|
||||
count = 3
|
||||
mac_address = scaleway_instance_private_nic.nics[count.index].mac_address
|
||||
type = "ipv4"
|
||||
}
|
||||
|
||||
# Create Ansible inventory file
|
||||
resource "local_sensitive_file" "ansible_inventory" {
|
||||
content = templatefile("templates/swarm_inventory.tftpl", {
|
||||
public_ips = var.swarm_ips
|
||||
local_ips = scaleway_instance_server.instances[*].private_ip
|
||||
local_ips = data.scaleway_ipam_ip.ips[*].address
|
||||
})
|
||||
filename = "/tmp/swarm_inventory"
|
||||
}
|
||||
Loading…
Reference in a new issue