Skip to content

Commit 4d33b65

Browse files
authored
Merge pull request #26 from stackhpc/wazuh
Add option to deploy wazuh
2 parents 4365b7d + 36c5607 commit 4d33b65

File tree

9 files changed

+80
-3
lines changed

9 files changed

+80
-3
lines changed

.terraform.lock.hcl

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ Generate Terraform variables:
125125
storage_flavor = "general.v1.small"
126126
storage_disk_size = 100
127127
128+
deploy_wazuh = true
129+
infra_vm_flavor = "general.v1.small"
130+
infra_vm_disk_size = 100
131+
128132
EOF
129133
130134
You will need to set the `multinode_flavor`, `multinode_keypair`, `prefix`,
@@ -136,6 +140,10 @@ nodes. Both virtual machines and baremetal are supported, but the
136140
`controller_disk_size` and `compute_disk_size` must be set to 0 when using
137141
baremetal host. This will stop a block device being allocated.
138142

143+
If `deploy_wazuh` is set to true, an infrastructure VM will be created that
144+
hosts the Wazuh manager. The Wazuh deployment playbooks will also be triggered
145+
automatically to deploy Wazuh agents to the overcloud hosts.
146+
139147
Generate a plan:
140148

141149
.. code-block:: console

ansible/deploy-openstack-config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
loop:
6060
- overcloud-host-configure/pre.d/
6161
- seed-host-configure/pre.d/
62+
- infra-vm-host-configure/pre.d/
6263

6364
- name: Ensure Kayobe hooks are present
6465
ansible.builtin.file:
@@ -73,6 +74,9 @@
7374
- { src: growroot.yml, dest: seed-host-configure/pre.d/5-growroot.yml }
7475
- { src: fix-networking.yml, dest: seed-host-configure/pre.d/15-fix-networking.yml }
7576
- { src: configure-vxlan.yml, dest: seed-host-configure/pre.d/20-configure-vxlan.yml }
77+
- { src: growroot.yml, dest: infra-vm-host-configure/pre.d/5-growroot.yml }
78+
- { src: fix-networking.yml, dest: infra-vm-host-configure/pre.d/15-fix-networking.yml }
79+
- { src: configure-vxlan.yml, dest: infra-vm-host-configure/pre.d/20-configure-vxlan.yml }
7680

7781

7882
- name: Ensure Admin Overcloud Network file is present

compute_instances.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,3 +134,27 @@ resource "openstack_compute_instance_v2" "storage" {
134134
create = "90m"
135135
}
136136
}
137+
138+
resource "openstack_compute_instance_v2" "wazuh_manager" {
139+
name = format("%s-wazuh-manager-%02d", var.prefix, count.index + 1)
140+
flavor_name = var.infra_vm_flavor
141+
key_pair = resource.openstack_compute_keypair_v2.keypair.name
142+
image_name = var.multinode_image
143+
config_drive = true
144+
user_data = file("templates/userdata.cfg.tpl")
145+
count = var.deploy_wazuh ? 1 : 0
146+
network {
147+
name = var.multinode_vm_network
148+
}
149+
block_device {
150+
uuid = data.openstack_images_image_v2.multinode_image.id
151+
source_type = "image"
152+
volume_size = var.infra_vm_disk_size
153+
boot_index = 0
154+
destination_type = "volume"
155+
delete_on_termination = true
156+
}
157+
timeouts {
158+
create = "90m"
159+
}
160+
}

outputs.tf

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ resource "local_file" "hosts" {
1111
ansible_control_hostname = openstack_compute_instance_v2.ansible_control.name
1212
storage_hostname = openstack_compute_instance_v2.storage.*.name
1313
seed_hostname = openstack_compute_instance_v2.seed.name
14+
wazuh_manager_hostname = openstack_compute_instance_v2.wazuh_manager.*.name
1415
}
1516
)
1617
filename = "ansible/files/hosts"
@@ -32,6 +33,8 @@ resource "local_file" "admin_networks" {
3233
storage = openstack_compute_instance_v2.storage.*.access_ip_v4
3334
seed_hostname = openstack_compute_instance_v2.seed.name
3435
seed = openstack_compute_instance_v2.seed.access_ip_v4
36+
wazuh_manager_hostname = openstack_compute_instance_v2.wazuh_manager.*.name
37+
wazuh_manager = openstack_compute_instance_v2.wazuh_manager.*.access_ip_v4
3538
}
3639
)
3740
filename = "ansible/files/admin-oc-networks.yml"
@@ -54,8 +57,9 @@ resource "local_file" "deploy_openstack" {
5457
content = templatefile(
5558
"${path.module}/templates/deploy-openstack.tpl",
5659
{
57-
seed_addr = openstack_compute_instance_v2.seed.access_ip_v4
58-
ssh_user = var.ssh_user
60+
seed_addr = openstack_compute_instance_v2.seed.access_ip_v4,
61+
ssh_user = var.ssh_user,
62+
deploy_wazuh = var.deploy_wazuh
5963
}
6064
)
6165
filename = "ansible/files/deploy-openstack.sh"

templates/admin-oc-networks.tpl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,7 @@ admin_oc_ips:
1414
${seed_hostname}: ${seed}
1515
%{ for hostname, addr in zipmap(storage_hostname, storage) ~}
1616
${ hostname }: ${ addr }
17-
%{ endfor ~}
17+
%{ endfor ~}
18+
%{ for hostname, addr in zipmap(wazuh_manager_hostname, wazuh_manager) ~}
19+
${ hostname }: ${ addr }
20+
%{ endfor ~}

templates/deploy-openstack.tpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ set -x
4545
kayobe control host bootstrap
4646
kayobe seed host configure
4747
kayobe overcloud host configure
48+
%{ if deploy_wazuh }kayobe infra vm host configure%{ endif }
4849

4950
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/cephadm-deploy.yml
5051
sleep 30
@@ -53,6 +54,13 @@ kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/cephadm-gather-keys.yml
5354

5455
kayobe overcloud service deploy
5556

57+
%{ if deploy_wazuh }
58+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/wazuh-secrets.yml
59+
ansible-vault encrypt --vault-password-file ~/vault.password $KAYOBE_CONFIG_PATH/environments/ci-multinode/wazuh-secrets.yml
60+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/wazuh-manager.yml
61+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/wazuh-agent.yml
62+
%{ endif }
63+
5664
activate_virt_env "openstack"
5765
activate_kayobe_env
5866

templates/hosts.tpl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,11 @@ ${ element }
3939

4040
[monitoring:children]
4141
controllers
42+
43+
[wazuh-manager]
44+
%{ for element in wazuh_manager_hostname ~}
45+
${ element }
46+
%{ endfor ~}
47+
48+
[infra-vms:children]
49+
wazuh-manager

variables.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ variable "storage_flavor" {
5151
type = string
5252
}
5353

54+
variable "infra_vm_flavor" {
55+
type = string
56+
}
57+
5458
variable "multinode_vm_network" {
5559
type = string
5660
}
@@ -86,3 +90,15 @@ variable "storage_disk_size" {
8690
type = number
8791
default = 100
8892
}
93+
94+
variable "infra_vm_disk_size" {
95+
description = "Block storage root disk size for infrastructure VMs."
96+
type = number
97+
default = 100
98+
}
99+
100+
variable "deploy_wazuh" {
101+
description = "Bool, whether or not to deploy Wazuh."
102+
type = bool
103+
default = false
104+
}

0 commit comments

Comments
 (0)