Skip to content

Commit aaddf02

Browse files
committed
use cloud-init rather than block_devices to create state directory
1 parent 08251f2 commit aaddf02

File tree

8 files changed

+54
-13
lines changed

8 files changed

+54
-13
lines changed

environments/smslabs/inventory/group_vars/all/block_devices.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

environments/smslabs/inventory/groups

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ compute
3737
cluster
3838

3939
[block_devices:children]
40-
control
4140

4241
[fail2ban:children]
4342
login

environments/smslabs/terraform/.terraform.lock.hcl

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#cloud-config
2+
disk_setup:
3+
/dev/vdb:
4+
table_type: gpt
5+
layout: true
6+
fs_setup:
7+
- label: control_state
8+
filesystem: ext4
9+
device: /dev/vdb
10+
partition: auto
11+
mounts:
12+
- [LABEL=control_state, ${state_dir}]

environments/smslabs/terraform/inventory.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ resource "local_file" "hosts" {
33
{
44
"cluster_name": var.cluster_name
55
"control": openstack_compute_instance_v2.control,
6-
"control_volume": openstack_blockstorage_volume_v3.control
6+
"state_dir": var.state_dir
77
"logins": openstack_compute_instance_v2.login,
88
"computes": openstack_compute_instance_v2.compute,
99
"compute_types": var.compute_types,

environments/smslabs/terraform/inventory.tpl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
[all:vars]
22
ansible_user=rocky
33
openhpc_cluster_name=${cluster_name}
4-
state_volume_serial=${control_volume.id}
54

65
[control]
7-
${control.name} ansible_host=${[for n in control.network: n.fixed_ip_v4 if n.access_network][0]} server_networks='${jsonencode({for net in control.network: net.name => [ net.fixed_ip_v4 ] })}'
6+
${control.name} ansible_host=${[for n in control.network: n.fixed_ip_v4 if n.access_network][0]} server_networks='${jsonencode({for net in control.network: net.name => [ net.fixed_ip_v4 ] })}' appliances_state_dir=${state_dir}
87

98
[login]
109
%{ for login in logins ~}

environments/smslabs/terraform/nodes.tf

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@ data "openstack_images_image_v2" "control" {
22
name = var.control_node.image
33
}
44

5+
data "template_cloudinit_config" "config" {
6+
gzip = true
7+
base64_encode = true
8+
9+
part {
10+
filename = "user-data"
11+
content_type = "text/cloud-config"
12+
content = templatefile("${path.module}/init.tpl",
13+
{
14+
state_dir = var.state_dir
15+
}
16+
)
17+
}
18+
}
19+
520
resource "openstack_compute_instance_v2" "control" {
621

722
name = "${var.cluster_name}-control"
@@ -37,6 +52,8 @@ resource "openstack_compute_instance_v2" "control" {
3752
environment_root = var.environment_root
3853
}
3954

55+
user_data = data.template_cloudinit_config.config.rendered
56+
4057
}
4158

4259
resource "openstack_compute_instance_v2" "login" {

environments/smslabs/terraform/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,9 @@ variable "environment_root" {
7171
type = string
7272
description = "Path to environment root, automatically set by activate script"
7373
}
74+
75+
variable "state_dir" {
76+
type = string
77+
description = "Path to state directory on control node"
78+
default = "/var/lib/state"
79+
}

0 commit comments

Comments
 (0)