diff --git a/juju/home-maas/00-variables.tf b/juju/home-maas/00-variables.tf index 5c140a1..bae33ea 100644 --- a/juju/home-maas/00-variables.tf +++ b/juju/home-maas/00-variables.tf @@ -63,6 +63,15 @@ variable "machines" { type = list(object({ machine_id = number constraints = string + base = optional(string) + })) +} + +variable "lma-machines" { + type = list(object({ + machine_id = number + constraints = string + base = optional(string) })) } @@ -71,6 +80,11 @@ variable model-name { default = "openstack" } +variable lma-model-name { + type = string + default = "lma" +} + variable openstack-origin { type = string default = "distro" diff --git a/juju/home-maas/09-filebeat.tf b/juju/home-maas/09-filebeat.tf new file mode 100644 index 0000000..b7a2543 --- /dev/null +++ b/juju/home-maas/09-filebeat.tf @@ -0,0 +1,85 @@ +resource "juju_application" "filebeat" { + name = "filebeat" + + model = var.model-name + + charm { + name = "filebeat" + channel = "latest/stable" + } + + units = 0 + + endpoint_bindings = [{ + space = var.oam-space + }] + + config = { + logpath = "/var/log/*.log /var/log/*/*.log /var/log/syslog" + install_sources = <<-EOF + - 'deb http://192.168.1.12/artifacts.elastic.co/packages/6.x/apt stable main' + EOF + install_keys = <<-EOF + - | + -----BEGIN PGP PUBLIC KEY BLOCK----- + Version: SKS 1.1.6 + Comment: Hostname: keyserver.ubuntu.com + mQENBFI3HsoBCADXDtbNJnxbPqB1vDNtCsqhe49vFYsZN9IOZsZXgp7aHjh6CJBDA+bGFOwy + hbd7at35jQjWAw1O3cfYsKAmFy+Ar3LHCMkV3oZspJACTIgCrwnkic/9CUliQe324qvObU2Q + RtP4Fl0zWcfb/S8UYzWXWIFuJqMvE9MaRY1bwUBvzoqavLGZj3SF1SPO+TB5QrHkrQHBsmX+ + Jda6d4Ylt8/t6CvMwgQNlrlzIO9WT+YN6zS+sqHd1YK/aY5qhoLNhp9G/HxhcSVCkLq8SStj + 1ZZ1S9juBPoXV1ZWNbxFNGwOh/NYGldD2kmBf3YgCqeLzHahsAEpvAm8TBa7Q9W21C8vABEB + AAG0RUVsYXN0aWNzZWFyY2ggKEVsYX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q1iTeyHkMZ + EyUJ8SKsaHh4jV9wp9KmC8C+9CwMukL7vM5w8cgvJoAwsp3Fn59AxWthN3XJYcnMfStkIuWg + R7U2r+a210W6vnUxU4oN0PmMcursYPyeV0NX/KQeUeNMwGTFB6QHS/anRaGQewijkrYYoTNt + fllxIu9XYmiBERQ/qPDlGRlOgVTd9xUfHFkzB52c70E= + =92oX + -----END PGP PUBLIC KEY BLOCK----- + EOF + } +} + +resource "juju_integration" "filebeat-integration" { + for_each = toset(var.all_services) + + model = var.model-name + + application { + name = juju_application.filebeat.name + endpoint = "beats-host" + } + + application { + name = "${each.value}" + endpoint = "juju-info" + } +} + + +resource "juju_integration" "filebeat-graylog" { + + model = var.model-name + + application { + name = juju_application.filebeat.name + endpoint = "logstash" + } + + application { + offer_url = juju_offer.graylog.url + } +} diff --git a/juju/home-maas/20-model.tf b/juju/home-maas/20-model.tf new file mode 100644 index 0000000..8f71cdd --- /dev/null +++ b/juju/home-maas/20-model.tf @@ -0,0 +1,18 @@ +resource "juju_model" "lma" { + name = var.lma-model-name + + cloud { + name = var.cloud + } + + config = { + apt-mirror = "http://${var.apt_mirror}/archive.ubuntu.com/ubuntu" + lxd-snap-channel = var.lxd-snap-channel + + container-image-metadata-url = "http://${var.apt_mirror}/lxd/" + container-image-stream = "released" + + agent-metadata-url = "http://${var.apt_mirror}/juju/tools/" + agent-stream = "released" + } +} diff --git a/juju/home-maas/21-machines.tf b/juju/home-maas/21-machines.tf new file mode 100644 index 0000000..ddc308f --- /dev/null +++ b/juju/home-maas/21-machines.tf @@ -0,0 +1,10 @@ +resource "juju_machine" "lma_machines" { + for_each = { + for index, machine in var.lma-machines: + machine.machine_id => machine + } + model = var.lma-model-name + name = each.value.machine_id + constraints = each.value.constraints + base = each.value.base +} diff --git a/juju/home-maas/22-graylog.tf b/juju/home-maas/22-graylog.tf new file mode 100644 index 0000000..12d844c --- /dev/null +++ b/juju/home-maas/22-graylog.tf @@ -0,0 +1,78 @@ +resource "juju_application" "graylog" { + name = "graylog" + + model = var.lma-model-name + + charm { + name = "graylog" + channel = "latest/stable" + base = "ubuntu@20.04" + } + + units = 1 + + placement = juju_machine.lma_machines["200"].machine_id + + endpoint_bindings = [{ + space = var.oam-space + }] + + config = { + channel = "4/stable" + jvm_heap_size = "1G" + rest_transport_uri = "http://graylog.example.com:9001" + index_rotation_period = "PT3H" + } +} + +resource "juju_machine" "graylog-mongodb" { + model = var.lma-model-name + placement = join(":", ["lxd", juju_machine.lma_machines["200"].machine_id]) + constraints = "spaces=oam" +} + + +resource "juju_application" "graylog-mongodb" { + name = "graylog-mongodb" + + model = var.lma-model-name + + charm { + name = "mongodb" + channel = "3.6/stable" + base = "ubuntu@20.04" + } + + units = 1 + + placement = juju_machine.graylog-mongodb.machine_id + + endpoint_bindings = [{ + space = var.oam-space + }] + + config = { + nagios_context = var.nagios-context + } +} + +resource "juju_integration" "graylog-mongodb" { + + model = var.lma-model-name + + application { + name = juju_application.graylog.name + endpoint = "mongodb" + } + + application { + name = juju_application.graylog-mongodb.name + endpoint = "database" + } +} + +resource "juju_offer" "graylog" { + model = var.lma-model-name + application_name = juju_application.graylog.name + endpoint = "beats" +} diff --git a/juju/home-maas/23-elastic.tf b/juju/home-maas/23-elastic.tf new file mode 100644 index 0000000..9103ac3 --- /dev/null +++ b/juju/home-maas/23-elastic.tf @@ -0,0 +1,75 @@ +resource "juju_application" "elasticsearch" { + name = "elasticsearch" + + model = var.lma-model-name + + charm { + name = "elasticsearch" + channel = "latest/stable" + base = "ubuntu@20.04" + } + + units = 2 + + placement = "${join(",", sort([ + for index in ["201","202"] : + juju_machine.lma_machines[index].machine_id + ]))}" + + + endpoint_bindings = [{ + space = var.oam-space + }] + + config = { + firewall_enabled = false + gpg-key = <<-EOF + -----BEGIN PGP PUBLIC KEY BLOCK----- + Version: SKS 1.1.6 + Comment: Hostname: keyserver.ubuntu.com + + mQENBFI3HsoBCADXDtbNJnxbPqB1vDNtCsqhe49vFYsZN9IOZsZXgp7aHjh6CJ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G7sHRFvePFU0ZS6JFx9GJqjSBbHRRkam+4emW3uWgVfZxuwcUCn1ayNgRt + KiFv9jQrg2TIWEvzYx9tywTCxc+FFMWAlbCzi+m4WD+QUWWfDQ009U/WM0ks0KwwEwSk/UDu + ToxGnKU2dQARAQABiQEfBBgBAgAJBQJSNx7KAhsMAAoJENJ9ZmzYjkK0c3MIAIE9hAR20mqJ + WLcsxLtrRs6uNF1VrpB+4n/55QU7oxA1iVBO6IFu4qgsF12JTavnJ5MLaETlggXY+zDef9sy + TPXoQctpzcaNVDmedwo1SiL03uMoblOvWpMR/Y0j6rm7IgrMWUDXDPvoPGjMl2q1iTeyHkMZ + EyUJ8SKsaHh4jV9wp9KmC8C+9CwMukL7vM5w8cgvJoAwsp3Fn59AxWthN3XJYcnMfStkIuWg + R7U2r+a210W6vnUxU4oN0PmMcursYPyeV0NX/KQeUeNMwGTFB6QHS/anRaGQewijkrYYoTNt + fllxIu9XYmiBERQ/qPDlGRlOgVTd9xUfHFkzB52c70E= + =92oX + -----END PGP PUBLIC KEY BLOCK----- + EOF + apt-repository = "deb http://192.168.1.12/artifacts.elastic.co/packages/6.x/apt stable main" + } +} + +resource "juju_integration" "graylog-elastic" { + + model = var.lma-model-name + + application { + name = juju_application.graylog.name + endpoint = "elasticsearch" + } + + application { + name = juju_application.elasticsearch.name + endpoint = "client" + } +} + diff --git a/juju/home-maas/24-grafana.tf b/juju/home-maas/24-grafana.tf new file mode 100644 index 0000000..c8822e7 --- /dev/null +++ b/juju/home-maas/24-grafana.tf @@ -0,0 +1,32 @@ +resource "juju_machine" "grafana" { + model = var.lma-model-name + placement = join(":", ["lxd", juju_machine.lma_machines["201"].machine_id]) + constraints = "spaces=oam" +} + +resource "juju_application" "grafana" { + name = "grafana" + + model = var.lma-model-name + + charm { + name = "grafana" + channel = "latest/stable" + base = "ubuntu@20.04" + } + + units = 1 + + placement = juju_machine.grafana.machine_id + + endpoint_bindings = [{ + space = var.oam-space + }] + + config = { + port = "3000" + install_method = "snap" + } +} + +#- [ "graylog:mongodb", "graylog-mongodb:database" ] diff --git a/juju/home-maas/terraform.tfvars b/juju/home-maas/terraform.tfvars index bab08ba..384617b 100644 --- a/juju/home-maas/terraform.tfvars +++ b/juju/home-maas/terraform.tfvars @@ -20,6 +20,15 @@ machines = [ {machine_id=1007,constraints="tags=compute,asrock04"}, ] +lma-machines = [ + {machine_id=200,constraints="tags=compute,asrock01"}, + {machine_id=201,constraints="tags=compute,asrock04"}, + {machine_id=202,constraints="tags=compute,asrock02"}, + {machine_id=300,constraints="tags=compute,asrock04",base="ubuntu@18.04"}, + {machine_id=301,constraints="tags=compute,asrock03",base="ubuntu@18.04"}, + {machine_id=302,constraints="tags=compute,asrock01",base="ubuntu@18.04"}, +] + osd-devices = "/dev/sdb /dev/sdc" nagios-context = "arif-nc01"