Skip to content

Commit caa6a3b

Browse files
authored
Merge branch 'main' into jph/designate
2 parents 04dcdea + 6e3f10f commit caa6a3b

File tree

9 files changed

+128
-4
lines changed

9 files changed

+128
-4
lines changed

.terraform.lock.hcl

Lines changed: 1 addition & 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
@@ -49,6 +49,7 @@
4949
loop:
5050
- overcloud-host-configure/pre.d/
5151
- seed-host-configure/pre.d/
52+
- infra-vm-host-configure/pre.d/
5253

5354
- name: Ensure Kayobe hooks are present
5455
ansible.builtin.file:
@@ -63,6 +64,9 @@
6364
- { src: growroot.yml, dest: seed-host-configure/pre.d/5-growroot.yml }
6465
- { src: fix-networking.yml, dest: seed-host-configure/pre.d/15-fix-networking.yml }
6566
- { src: configure-vxlan.yml, dest: seed-host-configure/pre.d/20-configure-vxlan.yml }
67+
- { src: growroot.yml, dest: infra-vm-host-configure/pre.d/5-growroot.yml }
68+
- { src: fix-networking.yml, dest: infra-vm-host-configure/pre.d/15-fix-networking.yml }
69+
- { src: configure-vxlan.yml, dest: infra-vm-host-configure/pre.d/20-configure-vxlan.yml }
6670

6771

6872
- 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: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ resource "local_file" "hosts" {
1919
ansible_control_hostname = openstack_compute_instance_v2.ansible_control.name
2020
storage_hostname = openstack_compute_instance_v2.storage.*.name
2121
seed_hostname = openstack_compute_instance_v2.seed.name
22+
wazuh_manager_hostname = openstack_compute_instance_v2.wazuh_manager.*.name
2223
}
2324
)
2425
filename = "ansible/files/hosts"
@@ -40,6 +41,8 @@ resource "local_file" "admin_networks" {
4041
storage = openstack_compute_instance_v2.storage.*.access_ip_v4
4142
seed_hostname = openstack_compute_instance_v2.seed.name
4243
seed = openstack_compute_instance_v2.seed.access_ip_v4
44+
wazuh_manager_hostname = openstack_compute_instance_v2.wazuh_manager.*.name
45+
wazuh_manager = openstack_compute_instance_v2.wazuh_manager.*.access_ip_v4
4346
}
4447
)
4548
filename = "ansible/files/admin-oc-networks.yml"
@@ -62,8 +65,10 @@ resource "local_file" "deploy_openstack" {
6265
content = templatefile(
6366
"${path.module}/templates/deploy-openstack.tpl",
6467
{
65-
seed_addr = openstack_compute_instance_v2.seed.access_ip_v4
66-
ssh_user = var.ssh_user
68+
seed_addr = openstack_compute_instance_v2.seed.access_ip_v4,
69+
ssh_user = var.ssh_user,
70+
deploy_wazuh = var.deploy_wazuh
71+
controller_hostname = openstack_compute_instance_v2.controller.*.name
6772
}
6873
)
6974
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: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,71 @@ set +x
4242
export KAYOBE_VAULT_PASSWORD=$(cat ~/vault.password)
4343
set -x
4444

45+
# Configure hosts
4546
kayobe control host bootstrap
4647
kayobe seed host configure
4748
kayobe overcloud host configure
49+
%{ if deploy_wazuh }kayobe infra vm host configure%{ endif }
4850

51+
# Deploy Ceph
4952
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/cephadm-deploy.yml
5053
sleep 30
5154
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/cephadm.yml
5255
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/cephadm-gather-keys.yml
5356

57+
pip install -r $${config_directories[kayobe]}/requirements.txt
58+
59+
# Deploy hashicorp vault to the seed
60+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/vault-deploy-seed.yml
61+
ansible-vault encrypt --vault-password-file ~/vault.password $KAYOBE_CONFIG_PATH/environments/$KAYOBE_ENVIRONMENT/vault/OS-TLS-INT.pem
62+
ansible-vault encrypt --vault-password-file ~/vault.password $KAYOBE_CONFIG_PATH/environments/$KAYOBE_ENVIRONMENT/vault/seed-vault-keys.json
63+
ansible-vault encrypt --vault-password-file ~/vault.password $KAYOBE_CONFIG_PATH/environments/$KAYOBE_ENVIRONMENT/vault/overcloud.key
64+
65+
kayobe overcloud service deploy -kt haproxy
66+
67+
# Deploy hashicorp vault to the controllers
68+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/vault-deploy-overcloud.yml
69+
ansible-vault encrypt --vault-password-file ~/vault.password $KAYOBE_CONFIG_PATH/environments/$KAYOBE_ENVIRONMENT/vault/overcloud-vault-keys.json
70+
71+
# Generate internal tls certificates
72+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/vault-generate-internal-tls.yml
73+
ansible-vault encrypt --vault-password-file ~/vault.password $KAYOBE_CONFIG_PATH/environments/$KAYOBE_ENVIRONMENT/kolla/certificates/haproxy-internal.pem
74+
75+
# Generate backend tls certificates
76+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/vault-generate-backend-tls.yml
77+
%{ for hostname in controller_hostname ~}
78+
ansible-vault encrypt --vault-password-file ~/vault.password $KAYOBE_CONFIG_PATH/environments/$KAYOBE_ENVIRONMENT/kolla/certificates/${ hostname }-key.pem
79+
%{ endfor ~}
80+
81+
# Set config to use tls
82+
sed -i 's/# kolla_enable_tls_internal: true/kolla_enable_tls_internal: true/g' $KAYOBE_CONFIG_PATH/environments/$KAYOBE_ENVIRONMENT/kolla.yml
83+
cat $KAYOBE_CONFIG_PATH/environments/$KAYOBE_ENVIRONMENT/kolla/globals-tls-config.yml >> $KAYOBE_CONFIG_PATH/environments/$KAYOBE_ENVIRONMENT/kolla/globals.yml
84+
85+
# Create vault configuration for barbican
86+
cat << EOF >> $KAYOBE_CONFIG_PATH/environments/$KAYOBE_ENVIRONMENT/secrets.yml
87+
---
88+
secrets_barbican_approle_secret_id: $(uuidgen)
89+
EOF
90+
ansible-vault encrypt --vault-password-file ~/vault.password $KAYOBE_CONFIG_PATH/environments/$KAYOBE_ENVIRONMENT/secrets.yml
91+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/vault-deploy-barbican.yml
92+
ansible-vault decrypt --vault-password-file ~/vault.password $KAYOBE_CONFIG_PATH/environments/$KAYOBE_ENVIRONMENT/secrets.yml
93+
cat << EOF >> $KAYOBE_CONFIG_PATH/environments/$KAYOBE_ENVIRONMENT/secrets.yml
94+
secrets_barbican_approle_role_id: $(cat /tmp/barbican-role-id)
95+
EOF
96+
ansible-vault encrypt --vault-password-file ~/vault.password $KAYOBE_CONFIG_PATH/environments/$KAYOBE_ENVIRONMENT/secrets.yml
97+
rm /tmp/barbican-role-id
98+
99+
# Deploy all services
54100
kayobe overcloud service deploy
55101

102+
%{ if deploy_wazuh }
103+
# Deploy Wazuh
104+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/wazuh-secrets.yml
105+
ansible-vault encrypt --vault-password-file ~/vault.password $KAYOBE_CONFIG_PATH/environments/ci-multinode/wazuh-secrets.yml
106+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/wazuh-manager.yml
107+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/wazuh-agent.yml
108+
%{ endif }
109+
56110
activate_virt_env "openstack"
57111
activate_kayobe_env
58112

@@ -75,10 +129,11 @@ set +x
75129
export KAYOBE_AUTOMATION_SSH_PRIVATE_KEY=$(cat ~/.ssh/id_rsa)
76130
set -x
77131

132+
# Run tempest
78133
sudo -E docker run --detach --rm --network host -v $${config_directories[kayobe]}:/stack/kayobe-automation-env/src/kayobe-config -v $${config_directories[kayobe]}/tempest-artifacts:/stack/tempest-artifacts -e KAYOBE_ENVIRONMENT -e KAYOBE_VAULT_PASSWORD -e KAYOBE_AUTOMATION_SSH_PRIVATE_KEY kayobe:latest /stack/kayobe-automation-env/src/kayobe-config/.automation/pipeline/tempest.sh -e ansible_user=stack
79134

80135
# During the initial deployment the seed node must receive the `gwee/rally` image before we can follow the logs.
81136
# Therefore, we must wait a reasonable amount time before attempting to do so.
82137
sleep 360
83138

84-
ssh -oStrictHostKeyChecking=no ${ ssh_user }@${ seed_addr } 'sudo docker logs --follow $(sudo docker ps -q)'
139+
ssh -oStrictHostKeyChecking=no ${ ssh_user }@${ seed_addr } 'sudo docker logs --follow $(sudo docker ps -q | head -n 1)'

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)