diff --git a/juju/home-maas/00-variables.tf b/juju/home-maas/00-variables.tf index 455903a..4685ba4 100644 --- a/juju/home-maas/00-variables.tf +++ b/juju/home-maas/00-variables.tf @@ -11,16 +11,26 @@ variable "num_units" { variable "controller_ids" { type = list(string) - default = ["100", "101", "102", + default = ["100", "101", "102", "103", "104", "105"] } +variable "controller_ids_high" { + type = list(string) + default = ["103", "104", "105"] +} + variable "compute_ids" { type = list(string) - default = ["1000", "1001", "1002", "1003", + default = ["1000", "1001", "1002", "1003", "1004", "1005", "1006", "1007"] } +variable "sdn_ids" { + type = list(string) + default = ["400", "401", "402"] +} + variable "apt_mirror" { type = string default = "192.168.1.12" @@ -69,17 +79,17 @@ variable mysql-router-channel { default = "8.0/stable" } -variable "hacluster-channel" { +variable hacluster-channel { type = string default = "2.0.3/stable" } -variable "rabbitmq-server-channel" { +variable rabbitmq-server-channel { type = string default = "3.8/stable" } -variable "ceph-channel" { +variable ceph-channel { type = string default = "octopus/stable" } diff --git a/juju/home-maas/04-keystone.tf b/juju/home-maas/04-keystone.tf index 449586b..fb5b1e4 100644 --- a/juju/home-maas/04-keystone.tf +++ b/juju/home-maas/04-keystone.tf @@ -1,7 +1,7 @@ resource "juju_machine" "keystone" { count = var.num_units model = var.model-name - placement = join(":", ["lxd", juju_machine.all_machines[var.controller_ids[count.index+var.num_units]].machine_id]) + placement = join(":", ["lxd", juju_machine.all_machines[var.controller_ids_high[count.index+var.num_units]].machine_id]) constraints = "spaces=oam" } @@ -18,8 +18,8 @@ resource "juju_application" "keystone" { units = var.num_units placement = "${join(",", sort([ - for index, _ in slice(var.controller_ids, var.num_units, length(var.controller_ids)) : - juju_machine.keystone[index].machine_id + for res in juju_machine.keystone : + res.machine_id ]))}" endpoint_bindings = [{ diff --git a/juju/home-maas/04-mysql.tf b/juju/home-maas/04-mysql.tf index 0b41852..277d0ff 100644 --- a/juju/home-maas/04-mysql.tf +++ b/juju/home-maas/04-mysql.tf @@ -19,8 +19,8 @@ resource "juju_application" "mysql-innodb-cluster" { units = var.num_units placement = "${join(",", sort([ - for index, _ in slice(var.controller_ids, 0, var.num_units+1) : - juju_machine.mysql[index].machine_id + for res in juju_machine.mysql : + res.machine_id ]))}" endpoint_bindings = [{ diff --git a/juju/home-maas/04-rmq.tf b/juju/home-maas/04-rmq.tf index a577516..106cc27 100644 --- a/juju/home-maas/04-rmq.tf +++ b/juju/home-maas/04-rmq.tf @@ -18,8 +18,8 @@ resource "juju_application" "rabbitmq-server" { units = 3 placement = "${join(",", sort([ - for index, _ in slice(var.controller_ids, var.num_units, length(var.controller_ids)) : - juju_machine.rmq[index].machine_id + for res in juju_machine.rmq : + res.machine_id ]))}" endpoint_bindings = [{ diff --git a/juju/home-maas/05-ceilometer.tf b/juju/home-maas/05-ceilometer.tf index 18d0751..1897407 100644 --- a/juju/home-maas/05-ceilometer.tf +++ b/juju/home-maas/05-ceilometer.tf @@ -18,8 +18,8 @@ resource "juju_application" "ceilometer" { units = 3 placement = "${join(",", sort([ - for index, _ in slice(var.controller_ids, var.num_units, length(var.controller_ids)) : - juju_machine.ceilometer[index].machine_id + for res in juju_machine.ceilometer : + res.machine_id ]))}" endpoint_bindings = [{ diff --git a/juju/home-maas/05-ceph.tf b/juju/home-maas/05-ceph.tf index 3451a42..f87b058 100644 --- a/juju/home-maas/05-ceph.tf +++ b/juju/home-maas/05-ceph.tf @@ -5,13 +5,13 @@ resource "juju_application" "ceph-osd" { charm { name = "ceph-osd" - channel = var.ceph-osd-channel + channel = var.ceph-channel } units = length(var.compute_ids) placement = "${join(",", sort([ - for index, _ in var.compute_ids : + for index, _ in var.compute_ids : juju_machine.all_machines[index].machine_id ]))}" @@ -47,8 +47,8 @@ resource "juju_application" "ceph-mon" { units = var.num_units placement = "${join(",", sort([ - for index, _ in slice(var.controller_ids, 0, var.num_units+1) : - juju_machine.ceph-mon[index].machine_id + for res in juju_machine.ceph-mon : + res.machine_id ]))}" endpoint_bindings = [{ @@ -98,8 +98,8 @@ resource "juju_application" "ceph-radosgw" { units = var.num_units placement = "${join(",", sort([ - for index, _ in slice(var.controller_ids, 0, var.num_units+1) : - juju_machine.ceph-rgw[index].machine_id + for res in juju_machine.ceph-rgw : + res.machine_id ]))}" endpoint_bindings = [{ diff --git a/juju/home-maas/05-cinder.tf b/juju/home-maas/05-cinder.tf index bc0fd3e..099b1c6 100644 --- a/juju/home-maas/05-cinder.tf +++ b/juju/home-maas/05-cinder.tf @@ -18,8 +18,8 @@ resource "juju_application" "cinder" { units = var.num_units placement = "${join(",", sort([ - for index, _ in slice(var.controller_ids, 0, var.num_units+1) : - juju_machine.cinder[index].machine_id + for res in juju_machine.cinder : + res.machine_id ]))}" endpoint_bindings = [{ diff --git a/juju/home-maas/05-glance.tf b/juju/home-maas/05-glance.tf index 9b382ec..de7b258 100644 --- a/juju/home-maas/05-glance.tf +++ b/juju/home-maas/05-glance.tf @@ -18,8 +18,8 @@ resource "juju_application" "glance" { units = var.num_units placement = "${join(",", sort([ - for index, _ in slice(var.controller_ids, 0, var.num_units+1) : - juju_machine.glance[index].machine_id + for res in juju_machine.glance : + res.machine_id ]))}" endpoint_bindings = [{ diff --git a/juju/home-maas/05-gnocchi.tf b/juju/home-maas/05-gnocchi.tf index bba71cd..c384bf3 100644 --- a/juju/home-maas/05-gnocchi.tf +++ b/juju/home-maas/05-gnocchi.tf @@ -1,7 +1,7 @@ resource "juju_machine" "gnocchi" { count = var.num_units model = var.model-name - placement = join(":", ["lxd", juju_machine.all_machines[var.controller_ids[count.index+var.num_units]].machine_id]) + placement = join(":", ["lxd", juju_machine.all_machines[var.controller_ids_high[count.index+var.num_units]].machine_id]) constraints = "spaces=oam,ceph-access" } @@ -18,8 +18,8 @@ resource "juju_application" "gnocchi" { units = var.num_units placement = "${join(",", sort([ - for index, _ in slice(var.controller_ids, var.num_units, length(var.controller_ids)) : - juju_machine.gnocchi[index].machine_id + for res in juju_machine.gnocchi : + res.machine_id ]))}" endpoint_bindings = [{ diff --git a/juju/home-maas/05-heat.tf b/juju/home-maas/05-heat.tf index 95b7464..2cab20a 100644 --- a/juju/home-maas/05-heat.tf +++ b/juju/home-maas/05-heat.tf @@ -18,8 +18,8 @@ resource "juju_application" "heat" { units = var.num_units placement = "${join(",", sort([ - for index, _ in slice(var.controller_ids, 0, var.num_units+1) : - juju_machine.heat[index].machine_id + for res in juju_machine.heat : + res.machine_id ]))}" endpoint_bindings = [{ diff --git a/juju/home-maas/05-memcache.tf b/juju/home-maas/05-memcache.tf index b6f82de..b8efaab 100644 --- a/juju/home-maas/05-memcache.tf +++ b/juju/home-maas/05-memcache.tf @@ -19,8 +19,8 @@ resource "juju_application" "memcached" { units = var.num_units placement = "${join(",", sort([ - for index, _ in slice(var.controller_ids, 0, var.num_units+1) : - juju_machine.memcached[index].machine_id + for res in juju_machine.memcache : + res.machine_id ]))}" diff --git a/juju/home-maas/05-nova.tf b/juju/home-maas/05-nova.tf index 0e99924..652e0e5 100644 --- a/juju/home-maas/05-nova.tf +++ b/juju/home-maas/05-nova.tf @@ -1,7 +1,7 @@ resource "juju_machine" "ncc" { count = var.num_units model = var.model-name - placement = join(":", ["lxd", juju_machine.all_machines[var.controller_ids[count.index+var.num_units]].machine_id]) + placement = join(":", ["lxd", juju_machine.all_machines[var.controller_ids_high[count.index+var.num_units]].machine_id]) constraints = "spaces=oam" } @@ -18,8 +18,8 @@ resource "juju_application" "nova-cloud-controller" { units = var.num_units placement = "${join(",", sort([ - for index, _ in slice(var.controller_ids, var.num_units, length(var.controller_ids)) : - juju_machine.ncc[index].machine_id + for res in juju_machine.ncc : + res.machine_id ]))}" endpoint_bindings = [{ diff --git a/juju/home-maas/05-placement.tf b/juju/home-maas/05-placement.tf index d15278c..b233dc1 100644 --- a/juju/home-maas/05-placement.tf +++ b/juju/home-maas/05-placement.tf @@ -1,7 +1,7 @@ resource "juju_machine" "placement" { count = var.num_units model = var.model-name - placement = join(":", ["lxd", juju_machine.all_machines[var.controller_ids[count.index+var.num_units]].machine_id]) + placement = join(":", ["lxd", juju_machine.all_machines[var.controller_ids_high[count.index+var.num_units]].machine_id]) constraints = "spaces=oam" } @@ -18,8 +18,8 @@ resource "juju_application" "placement" { units = var.num_units placement = "${join(",", sort([ - for index, _ in slice(var.controller_ids, var.num_units, length(var.controller_ids)) : - juju_machine.placement[index].machine_id + for res in juju_machine.placement : + res.machine_id ]))}" endpoint_bindings = [{ diff --git a/juju/home-maas/06-nova-compute.tf b/juju/home-maas/06-nova-compute.tf index 6b2c383..a932d84 100644 --- a/juju/home-maas/06-nova-compute.tf +++ b/juju/home-maas/06-nova-compute.tf @@ -11,7 +11,7 @@ resource "juju_application" "nova-compute-kvm" { units = length(var.compute_ids) placement = "${join(",", sort([ - for index, _ in var.compute_ids : + for index, _ in var.compute_ids : juju_machine.all_machines[index].machine_id ]))}" diff --git a/juju/home-maas/07-controllers.tf b/juju/home-maas/07-controllers.tf index b4ae5d1..20743b6 100644 --- a/juju/home-maas/07-controllers.tf +++ b/juju/home-maas/07-controllers.tf @@ -13,7 +13,7 @@ resource "juju_application" "controller-server" { units = length(var.controller_ids) placement = "${join(",", sort([ - for index, _ in var.controller_ids : + for index, _ in var.controller_ids : juju_machine.all_machines[index].machine_id ]))}" } diff --git a/juju/home-maas/08-neutron.tf b/juju/home-maas/08-neutron.tf index c5b9b3f..94045d7 100644 --- a/juju/home-maas/08-neutron.tf +++ b/juju/home-maas/08-neutron.tf @@ -11,8 +11,8 @@ resource "juju_application" "neutron-gateway" { units = var.num_units placement = "${join(",", sort([ - for index, _ in slice(var.controller_ids, 0, var.num_units+1) : - juju_machine.neutron-api[index].machine_id + for index, _ in slice(var.controller_ids, 0, var.num_units+1) : + juju_machine.all_machines[index].machine_id ]))}" @@ -47,8 +47,8 @@ resource "juju_application" "neutron-api" { units = var.num_units placement = "${join(",", sort([ - for index, _ in slice(var.controller_ids, 0, var.num_units+1) : - juju_machine.neutron-api[index].machine_id + for res in juju_machine.neutron-api : + res.machine_id ]))}" endpoint_bindings = [{ diff --git a/juju/home-maas/10-vault.tf b/juju/home-maas/10-vault.tf index 8e245aa..098b927 100644 --- a/juju/home-maas/10-vault.tf +++ b/juju/home-maas/10-vault.tf @@ -1,16 +1,7 @@ -resource "juju_machine" "vault-1" { +resource "juju_machine" "vault" { + count = var.num_units model = var.model-name - placement = join(":",["lxd",juju_machine.all_machines["400"].machine_id]) - constraints = "spaces=oam" -} -resource "juju_machine" "vault-2" { - model = var.model-name - placement = join(":",["lxd",juju_machine.all_machines["401"].machine_id]) - constraints = "spaces=oam" -} -resource "juju_machine" "vault-3" { - model = var.model-name - placement = join(":",["lxd",juju_machine.all_machines["402"].machine_id]) + placement = join(":",["lxd",juju_machine.all_machines[var.sdn_ids[count.index+var.num_units]].machine_id]) constraints = "spaces=oam" } @@ -25,12 +16,11 @@ resource "juju_application" "vault" { base = var.default-base } - units = 3 + units = var.num_units placement = "${join(",",sort([ - juju_machine.vault-1.machine_id, - juju_machine.vault-2.machine_id, - juju_machine.vault-3.machine_id, + for res in juju_machine.vault : + res.machine_id ]))}" config = { @@ -83,19 +73,10 @@ resource "juju_application" "hacluster-vault" { } -resource "juju_machine" "etcd-1" { +resource "juju_machine" "etcd" { + count = var.num_units model = var.model-name - placement = join(":",["lxd",juju_machine.all_machines["400"].machine_id]) - constraints = "spaces=oam" -} -resource "juju_machine" "etcd-2" { - model = var.model-name - placement = join(":",["lxd",juju_machine.all_machines["401"].machine_id]) - constraints = "spaces=oam" -} -resource "juju_machine" "etcd-3" { - model = var.model-name - placement = join(":",["lxd",juju_machine.all_machines["402"].machine_id]) + placement = join(":",["lxd",juju_machine.all_machines[var.sdn_ids[count.index+var.num_units]].machine_id]) constraints = "spaces=oam" } @@ -112,9 +93,8 @@ resource "juju_application" "etcd" { } placement = "${join(",",sort([ - juju_machine.etcd-1.machine_id, - juju_machine.etcd-2.machine_id, - juju_machine.etcd-3.machine_id, + for res in juju_machine.etcd : + res.machine_id ]))}" endpoint_bindings = [{