Skip to content

Commit 961f40a

Browse files
authored
Merge pull request #12 from InputObject2/hotfix/terraform-fmt
Fixed tf fmt so at least first run can pass
2 parents 4ff0153 + 7a89d13 commit 961f40a

File tree

7 files changed

+62
-55
lines changed

7 files changed

+62
-55
lines changed

local_mac_addressses.tf

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

providers.tf

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,25 @@ terraform {
44
required_providers {
55
xenorchestra = {
66
source = "terra-farm/xenorchestra"
7+
version = ">=0.26.1"
78
}
89
macaddress = {
9-
source = "ivoronin/macaddress"
10-
#version = "0.3.0"
11-
}
12-
gitlab = {
13-
source = "gitlabhq/gitlab"
14-
#version = "16.4.1"
10+
source = "ivoronin/macaddress"
11+
version = ">=0.3.0"
1512
}
1613
sshcommand = {
17-
source = "invidian/sshcommand"
18-
#version = "0.2.2"
14+
source = "invidian/sshcommand"
15+
version = ">=0.2.2"
16+
}
17+
null = {
18+
source = "hashicorp/null"
19+
version = ">=3.2.2"
20+
}
21+
random = {
22+
source = "hashicorp/random"
23+
version = ">=3.6.2"
1924
}
2025
}
26+
27+
required_version = ">= 1.0"
2128
}

variables.tf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ variable "node_xoa_network_name" {
4848
variable "node_tags" {
4949
description = "Tags to apply to worker nodes"
5050
type = list(string)
51-
default = [
51+
default = [
5252
"xcp-ng.org/arch:amd64",
5353
"xcp-ng.org/os:ubuntu"
5454
]
@@ -104,7 +104,7 @@ variable "master_xoa_network_name" {
104104
variable "master_tags" {
105105
description = "Tags to apply to master nodes"
106106
type = list(string)
107-
default = [
107+
default = [
108108
"xcp-ng.org/arch:amd64",
109109
"xcp-ng.org/os:ubuntu"
110110
]
@@ -192,9 +192,9 @@ variable "dns_sub_zone" {
192192
}
193193

194194
variable "cluster_name" {
195-
description = "Name used in the virtual machine names, not an actual Kubernetes settings"
196-
type = string
197-
default = "my-cluster"
195+
description = "Name used in the virtual machine names, not an actual Kubernetes settings"
196+
type = string
197+
default = "my-cluster"
198198
}
199199

200200
variable "microk8s_version" {
@@ -206,7 +206,7 @@ variable "microk8s_version" {
206206
variable "cloud_network_config_template" {
207207
description = "Template for cloud network config"
208208
type = string
209-
default = <<EOF
209+
default = <<EOF
210210
network:
211211
version: 1
212212
config:
@@ -218,7 +218,7 @@ EOF
218218
}
219219

220220
variable "tags" {
221-
description = "A list of key+value pairs to apply to the deployment"
222-
type = list(string)
223-
default = []
221+
description = "A list of key+value pairs to apply to the deployment"
222+
type = list(string)
223+
default = []
224224
}

xen_data.tf

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
provider "xenorchestra" {
22
# Configuration options
33
# Must be ws or wss
4-
url = var.xoa_api_url # Or set XOA_URL environment variable
5-
#username = var.xoa_username # Or set XOA_USER environment variable
6-
#password = var.xoa_password # Or set XOA_PASSWORD environment variable
4+
url = var.xoa_api_url # Or set XOA_URL environment variable
5+
username = var.xoa_username # Or set XOA_USER environment variable
6+
password = var.xoa_password # Or set XOA_PASSWORD environment variable
77
insecure = var.xoa_ignore_ssl # Or set XOA_INSECURE environment variable to any value
88
}
99

@@ -12,25 +12,25 @@ provider "xenorchestra" {
1212

1313
locals {
1414
master_pool_name = var.master_xoa_pool_name == null ? var.xoa_pool_name : var.master_xoa_pool_name
15-
node_pool_name = var.node_xoa_pool_name == null ? var.xoa_pool_name : var.node_xoa_pool_name
16-
master_network = var.master_xoa_network_name == null ? var.xoa_network_name : var.master_xoa_network_name
17-
node_network = var.node_xoa_network_name == null ? var.xoa_network_name : var.node_xoa_network_name
15+
node_pool_name = var.node_xoa_pool_name == null ? var.xoa_pool_name : var.node_xoa_pool_name
16+
master_network = var.master_xoa_network_name == null ? var.xoa_network_name : var.master_xoa_network_name
17+
node_network = var.node_xoa_network_name == null ? var.xoa_network_name : var.node_xoa_network_name
1818
}
1919

2020
data "xenorchestra_pool" "xcp_ng_master" {
21-
name_label = local.master_pool_name
21+
name_label = local.master_pool_name
2222
}
2323

2424
data "xenorchestra_pool" "xcp_ng_node" {
25-
name_label = local.node_pool_name
25+
name_label = local.node_pool_name
2626
}
2727

2828
data "xenorchestra_network" "master" {
29-
pool_id = data.xenorchestra_pool.xcp_ng_master.id
29+
pool_id = data.xenorchestra_pool.xcp_ng_master.id
3030
name_label = local.master_network
3131
}
3232

3333
data "xenorchestra_network" "node" {
34-
pool_id = data.xenorchestra_pool.xcp_ng_node.id
34+
pool_id = data.xenorchestra_pool.xcp_ng_node.id
3535
name_label = local.node_network
3636
}

xen_master.tf

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
resource "random_integer" "master" {
2-
count = var.master_count
3-
min = 1000
4-
max = 9999
2+
count = var.master_count
3+
min = 1000
4+
max = 9999
55
}
66

77
resource "random_uuid" "custom_token" {}
88

99
locals {
1010
# Generate a random UUID and extract the first 32 characters
11-
custom_token = substr(random_uuid.custom_token.result, 0, 32)
12-
master_prefix = "${var.master_prefix}-${var.cluster_name}-master"
11+
custom_token = substr(random_uuid.custom_token.result, 0, 32)
12+
master_prefix = "${var.master_prefix}-${var.cluster_name}-master"
1313
microk8s_version_channel = var.microk8s_version == null ? "" : "--channel=${var.microk8s_version}"
1414
}
1515

1616
resource "xenorchestra_cloud_config" "master" {
17-
name = "ubuntu-base-config-master-0-${var.cluster_name}"
17+
name = "ubuntu-base-config-master-0-${var.cluster_name}"
1818
template = <<EOF
1919
#cloud-config
2020
hostname: "${local.master_prefix}-${random_integer.master[0].result}.${var.cluster_dns_zone}"
@@ -166,23 +166,23 @@ resource "xenorchestra_vm" "master" {
166166
tags = concat(var.tags, var.master_tags, ["kubernetes.io/role:primary", "xcp-ng.org/deployment:${var.cluster_name}"])
167167

168168
lifecycle {
169-
ignore_changes = [ disk, affinity_host, template ]
169+
ignore_changes = [disk, affinity_host, template]
170170
}
171171
}
172172

173173
resource "null_resource" "sleep_while_master_readies_up" {
174174
provisioner "local-exec" {
175-
command = "sleep 240" # Sleep to until master is ready
175+
command = "sleep 240" # Sleep to until master is ready
176176
}
177177

178-
depends_on = [ xenorchestra_vm.master ]
178+
depends_on = [xenorchestra_vm.master]
179179
}
180180

181181
resource "sshcommand_command" "get_kubeconfig" {
182-
host = xenorchestra_vm.master.ipv4_addresses[0]
183-
command = "sudo microk8s config get"
184-
private_key = file(var.private_ssh_key_path)
185-
user = "cloud-user"
182+
host = xenorchestra_vm.master.ipv4_addresses[0]
183+
command = "sudo microk8s config get"
184+
private_key = file(var.private_ssh_key_path)
185+
user = "cloud-user"
186186

187-
depends_on = [ null_resource.sleep_while_master_readies_up ]
187+
depends_on = [null_resource.sleep_while_master_readies_up]
188188
}

xen_nodes.tf

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ locals {
33
}
44

55
resource "random_integer" "node" {
6-
count = var.node_count
7-
min = 1000
8-
max = 9999
6+
count = var.node_count
7+
min = 1000
8+
max = 9999
99
}
1010

1111
resource "xenorchestra_cloud_config" "node" {
12-
count = var.node_count
13-
name = "ubuntu-base-config-node-${count.index}"
12+
count = var.node_count
13+
name = "ubuntu-base-config-node-${count.index}"
1414
template = <<EOF
1515
#cloud-config
1616
hostname: "${local.node_prefix}-${random_integer.node[count.index].result}.${var.dns_sub_zone}.${lower(var.dns_zone)}"
@@ -70,7 +70,7 @@ firewall:
7070
source: 0.0.0.0/0
7171
EOF
7272

73-
depends_on = [ xenorchestra_vm.master ]
73+
depends_on = [xenorchestra_vm.master]
7474
}
7575

7676
resource "xenorchestra_vm" "node" {
@@ -104,8 +104,8 @@ resource "xenorchestra_vm" "node" {
104104
tags = concat(var.tags, var.node_tags, ["kubernetes.io/role:worker", "xcp-ng.org/deployment:${var.cluster_name}"])
105105

106106
lifecycle {
107-
ignore_changes = [ disk, affinity_host, template ]
107+
ignore_changes = [disk, affinity_host, template]
108108
}
109109

110-
depends_on = [ xenorchestra_vm.master, null_resource.sleep_while_master_readies_up, xenorchestra_vm.secondary ]
110+
depends_on = [xenorchestra_vm.master, null_resource.sleep_while_master_readies_up, xenorchestra_vm.secondary]
111111
}

xen_secondaries.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
resource "xenorchestra_cloud_config" "secondary" {
2-
count = var.master_count - 1
3-
name = "ubuntu-base-config-master-${count.index + 1}"
2+
count = var.master_count - 1
3+
name = "ubuntu-base-config-master-${count.index + 1}"
44
template = <<EOF
55
#cloud-config
66
hostname: "${local.master_prefix}-${random_integer.master[count.index + 1].result}.${var.cluster_dns_zone}"
@@ -78,7 +78,7 @@ EOF
7878

7979

8080
resource "xenorchestra_vm" "secondary" {
81-
count = var.master_count - 1
81+
count = var.master_count - 1
8282
name_label = "${local.master_prefix}-${random_integer.master[count.index + 1].result}"
8383
cloud_config = xenorchestra_cloud_config.secondary[count.index].template
8484
cloud_network_config = var.cloud_network_config_template
@@ -107,8 +107,8 @@ resource "xenorchestra_vm" "secondary" {
107107
tags = concat(var.tags, var.master_tags, ["kubernetes.io/role:secondary", "xcp-ng.org/deployment:${var.cluster_name}"])
108108

109109
lifecycle {
110-
ignore_changes = [ disk, affinity_host, template ]
110+
ignore_changes = [disk, affinity_host, template]
111111
}
112112

113-
depends_on = [ xenorchestra_vm.master, null_resource.sleep_while_master_readies_up ]
113+
depends_on = [xenorchestra_vm.master, null_resource.sleep_while_master_readies_up]
114114
}

0 commit comments

Comments
 (0)