feat: Initial code
Signed-off-by: Julien Riou <julien@riou.xyz>
This commit is contained in:
parent
0e18170cdf
commit
fc59b4f9a5
18 changed files with 478 additions and 1 deletions
43
tofu/main.tf
Normal file
43
tofu/main.tf
Normal file
|
@ -0,0 +1,43 @@
|
|||
resource "tls_private_key" "ssh_key" {
|
||||
algorithm = "ED25519"
|
||||
}
|
||||
|
||||
resource "openstack_compute_keypair_v2" "ssh_key" {
|
||||
name = replace(join(".", [var.hostname, var.domain]), ".", "-")
|
||||
public_key = tls_private_key.ssh_key.public_key_openssh
|
||||
}
|
||||
|
||||
resource "local_file" "ansible_ssh_key" {
|
||||
content = tls_private_key.ssh_key.private_key_openssh
|
||||
filename = "../ansible/ssh_key"
|
||||
directory_permission = "0755"
|
||||
file_permission = "0600"
|
||||
}
|
||||
|
||||
resource "openstack_compute_instance_v2" "instance" {
|
||||
name = join(".", [var.hostname, var.domain])
|
||||
image_name = var.openstack_image
|
||||
flavor_name = var.openstack_flavor
|
||||
key_pair = openstack_compute_keypair_v2.ssh_key.name
|
||||
network {
|
||||
name = "Ext-Net"
|
||||
}
|
||||
}
|
||||
|
||||
resource "ovh_domain_zone_record" "subdomain" {
|
||||
zone = var.domain
|
||||
subdomain = var.hostname
|
||||
fieldtype = "A"
|
||||
ttl = 3600
|
||||
target = openstack_compute_instance_v2.instance.access_ip_v4
|
||||
}
|
||||
|
||||
resource "local_file" "inventory" {
|
||||
content = templatefile("templates/hosts.tpl",
|
||||
{
|
||||
ipaddr = openstack_compute_instance_v2.instance.access_ip_v4
|
||||
})
|
||||
filename = "../ansible/inventory/hosts"
|
||||
file_permission = "0644"
|
||||
directory_permission = "0755"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue