diff --git a/lb-user.tpl b/lb-user.tpl new file mode 100644 index 0000000..389a474 --- /dev/null +++ b/lb-user.tpl @@ -0,0 +1,19 @@ +#cloud-config + +packages: + - chrony + - git + - lvm2 + - xfsprogs +write_files: + - path: /etc/chrony/chrony.conf + permissions: "0644" + content: | +%{ for line in split("\n",file("chrony.conf")) ~} + ${line} +%{ endfor ~} + owner: root:root + +runcmd: + - [ systemctl, enable, chronyd ] + - systemctl restart chronyd diff --git a/lb.tf b/lb.tf index c227511..2e13fa9 100644 --- a/lb.tf +++ b/lb.tf @@ -24,5 +24,36 @@ resource "openstack_networking_port_v2" "lbvip" { admin_state_up = "false" } +resource "openstack_blockstorage_volume_v3" "lbvolumeboot" { + count = var.lbsize # size of cluster + name = "lb${count.index + 1}-matrix-test-sunet-se-vol" + description = "OS volume for lb node ${count.index + 1}" + size = 50 + image_id = data.openstack_images_image_v2.debian12image.id + enable_online_resize = true # Allow us to resize volume while attached. +} +# Create instances of lb nodes +resource "openstack_compute_instance_v2" "lb" { + name = "lb${count.index + 1}.matrix.test.sunet.se" + count = var.lbsize + flavor_id = data.openstack_compute_flavor_v2.b2c4r16.id + key_pair = data.openstack_compute_keypair_v2.manderssonpub.id + security_groups = [ + data.openstack_networking_secgroup_v2.sshfromjumphosts.name, + data.openstack_networking_secgroup_v2.allegress.name, + resource.openstack_networking_secgroup_v2.lbnode.name + ] + user_data = templatefile("lb-user.tpl",{}) + network { + port = resource.openstack_networking_port_v2.lbport[count.index].id + } + + block_device { + uuid = resource.openstack_blockstorage_volume_v3.lbvolumeboot[count.index].id + source_type = "volume" + destination_type = "volume" + boot_index = 0 + } +}