Skip to content

Commit d884705

Browse files
authored
Merge pull request #552 from stackhpc/multinode-wazuh
Support wazuh in the ci-multinode environment
2 parents 8224331 + 97abe7d commit d884705

File tree

12 files changed

+168
-22
lines changed

12 files changed

+168
-22
lines changed

doc/source/configuration/wazuh.rst

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22
Wazuh
33
=====
44

5+
The short version
6+
=================
7+
8+
#. Create an infrastructure VM for the Wazuh manager, and add it to the wazuh-manager group
9+
#. Configure the infrastructure VM with kayobe: ``kayobe infra vm host configure``
10+
#. Edit your config under
11+
``etc/kayobe/inventory/group_vars/wazuh-manager/wazuh-manager``, in
12+
particular the defaults assume that the ``provision_oc_net`` network will be
13+
used.
14+
#. Generate secrets: ``kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/wazuh-secrets.yml``
15+
#. Encrypt the secrets: ``ansible-vault encrypt --vault-password-file ~/vault.password $KAYOBE_CONFIG_PATH/environments/ci-multinode/wazuh-secrets.yml``
16+
#. Deploy the Wazuh manager: ``kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/wazuh-manager.yml``
17+
#. Deploy the Wazuh agents: ``kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/wazuh-agent.yml``
18+
19+
520
Wazuh Manager
621
=============
722

@@ -74,8 +89,8 @@ Define network interfaces ``etc/kayobe/inventory/group_vars/wazuh-manager/networ
7489
7590
7691
The Wazuh manager may need to be exposed externally, in which case it may require another interface.
77-
This can be done as follows in ``etc/kayobe/inventory/group_vars/wazuh-manager/network-interfaces`` ,
78-
with the network defined in network.yml as usual.
92+
This can be done as follows in ``etc/kayobe/inventory/group_vars/wazuh-manager/network-interfaces``,
93+
with the network defined in ``networks.yml`` as usual.
7994

8095
.. code-block:: console
8196
@@ -128,18 +143,18 @@ Several services are used for the communication of Wazuh components. Below is th
128143
Manually provisioned VM
129144
-----------------------
130145

131-
In case where you can’t use infra-vms to deploy your wazuh-manager VM but you want to configure
132-
host using kayobe, there are some tips (note that depending on your setup this don’t have to always apply):
146+
In cases where you can’t use infra-vms to deploy your wazuh-manager VM but you want to configure
147+
the host using kayobe, here are some tips (note that depending on your setup this doesn't have to always apply):
133148

134-
* Depending on preferences host have to be part of some group in inventory. ``infra-vms`` group still seems as best choice
149+
* Depending on preferences, hosts have to be part of some group in inventory. ``infra-vms`` group still seems like the best choice.
135150
You can use ``kayobe infra vm host configure`` to configure host in this case.
136-
Bellow tips are based on assumption that infra-vm will be used.
137-
* user ``stack`` with password less sudo and accessible with ssh keys needs to be present on host.
151+
The tips below are based on the assumption that infra-vm will be used.
152+
* user ``stack`` with passwordless sudo and access with ssh keys needs to be present on the host.
138153
It can be achieved in many different ways, depending on your setup.
139154
* lvm configuration should be placed in ``host_vars/<host_name>``
140-
* wazuh-manager host have to be part of ``infra-vms`` group (directly or as child)
141-
* network used on host needs to be defined in ``networks.yml`` and
142-
if you have pre-alocated IP, it should be added to ``network-allocation.yml``.
155+
* wazuh-manager hosts have to be part of ``infra-vms`` group (directly or as child)
156+
* The network used on the host needs to be defined in ``networks.yml`` and
157+
if you have pre-alocated an IP, it should be added to ``network-allocation.yml``.
143158
For example, if using host with IP 10.10.224.5 in network 10.10.224.0/24 one have to add:
144159

145160

@@ -169,18 +184,18 @@ Deploying Wazuh Manager services
169184
Setup
170185
-----
171186

172-
To install specific version modify wazuh-ansible entry in ``etc/kayobe/ansible/requirements.yml``:
187+
To install a specific version modify the wazuh-ansible entry in ``etc/kayobe/ansible/requirements.yml``:
173188

174189
.. code-block:: console
175190
176191
roles:
177192
- name: wazuh-ansible
178193
src: https://github.com/stackhpc/wazuh-ansible
179-
version: stackhpc
194+
version: custom-branch
180195
181-
Version above was tested and verified, but there is no reason to use not different one.
196+
The default version has been tested and verified, but there is no reason not to use a different one.
182197

183-
Install the role:
198+
Reinstall the role if required:
184199

185200
``kayobe control host bootstrap``
186201

@@ -210,9 +225,10 @@ You may need to modify some of the variables, including:
210225
.. note::
211226

212227
NOTE:
213-
If you are using multiple environments, and you need to customise Wazuh in each environement, create override files in an appropriate directory,
228+
If you are using multiple environments, and you need to customise Wazuh in
229+
each environment, create override files in an appropriate directory,
214230
for example `etc/kayobe/environments/production/inventory/group_vars/`
215-
Files which values can be overridden (in context of Wazuh):
231+
Files which values can be overridden (in the context of Wazuh):
216232
- etc/kayobe/inventory/group_vars/wazuh/wazuh-manager/wazuh-manager
217233
- etc/kayobe/wazuh-manager.yml
218234
- etc/kayobe/inventory/group_vars/wazuh/wazuh-agent/wazuh-agent
@@ -259,7 +275,6 @@ does not exist, it will generate the following certificates in ``etc/kayobe/ansi
259275
* root-ca.key root-ca.pem
260276

261277

262-
263278
It is also possible to use externally generated certificates for wazuh-dashboard. root-ca.pem should contain the CA chain.
264279
Those certificates can be uploaded to ``etc/kayobe/ansible/wazuh/custom_certificates``,
265280
and will replace certificates generated by wazuh.

doc/source/contributor/environments/ci-multinode.rst

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,3 +324,77 @@ with:
324324
325325
There are various other options for sonobuoy, see the `documentation
326326
<https://sonobuoy.io/docs/>`_ for more details.
327+
328+
Wazuh
329+
======
330+
331+
Adding Wazuh to a new deployment
332+
--------------------------------
333+
334+
Wazuh is supported but not deployed by default. If you are using the standard
335+
[StackHPC multinode
336+
terraform](https://github.com/stackhpc/terraform-kayobe-multinode), there is a
337+
``deploy_wazuh`` terraform variable that will add it to the automated setup.
338+
339+
Adding Wazuh to an existing deployment
340+
--------------------------------------
341+
342+
Create an additional VM with the same basic configuration (key, image, flavour
343+
etc.) as the existing deployment.
344+
345+
Add the IP and hostname to ``/etc/hosts`` on the ansible control host.
346+
347+
Add the hostname to the ``[wazuh-manager]`` group in
348+
``$KAYOBE_CONFIG_PATH/environments/ci-multinode/inventory/hosts``.
349+
350+
Add the host to the ``[infra-vms]`` group, either directly or by making the
351+
``wazuh-manager`` group a child group of ``infra-vms``.
352+
353+
Create the following directory structure:
354+
``$KAYOBE_CONFIG_PATH/hooks/infra-vm-host-configure/pre.d/``
355+
356+
Either copy or symlink in the growroot, networking, and vxlan playbooks as
357+
shown in ``$KAYOBE_CONFIG_PATH/hooks/seed-host-configure/pre.d/``.
358+
359+
Configure the Wazuh manager VM:
360+
361+
.. code-block:: bash
362+
363+
kayobe infra vm host configure
364+
365+
Create and encrypt the Wazuh secrets
366+
367+
.. code-block:: bash
368+
369+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/wazuh-secrets.yml
370+
ansible-vault encrypt --vault-password-file ~/vault.password $KAYOBE_CONFIG_PATH/environments/ci-multinode/wazuh-secrets.yml
371+
372+
Run the Wazuh manager and agent deployment playbooks:
373+
374+
.. code-block:: bash
375+
376+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/wazuh-manager.yml
377+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/wazuh-agent.yml
378+
379+
Wazuh should now be fully deployed. To test the service, you can use sshuttle
380+
or some other forwarding protocol to access the Wazuh dashboard.
381+
382+
.. code-block:: bash
383+
384+
sshuttle -r <wazuh-manager-hostname> <wazuh-manager-ip>
385+
386+
The above example assumes an SSH configuration that allows access with
387+
``ssh <wazuh-manager-hostname>``.
388+
389+
Open ``https://<wazuh-manager-ip>/`` in a web browser, and you should see a
390+
login screen.
391+
392+
The default username is ``admin`` and the password is the
393+
``opendistro_admin_password`` which can be found in ``wazuh-secrets.yml`` e.g.
394+
395+
.. code-block:: bash
396+
397+
ansible-vault view $KAYOBE_CONFIG_PATH/environments/ci-multinode/wazuh-secrets.yml --vault-password-file ~/vault.password | grep opendistro_admin_password
398+
399+
If the deployment has been successful, you should be able to see a Wazuh agent
400+
for each host in your deployment (aside from the Wazuh manager itself).

etc/kayobe/ansible/configure-vxlan.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
- name: Configure VXLAN
3-
hosts: controllers,compute,seed,storage
3+
hosts: controllers,compute,infra-vms,seed,storage
44
gather_facts: true
55
vars:
66
ansible_user: "{{ bootstrap_user }}"

etc/kayobe/ansible/fix-networking.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
- name: Fix networking
3-
hosts: seed,compute,controllers,storage
3+
hosts: controllers,compute,infra-vms,seed,storage
44
gather_facts: false
55
vars:
66
ansible_user: "{{ bootstrap_user }}"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
growroot_group: "seed:overcloud"
2+
growroot_group: "seed:overcloud:infra-vms"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
infra_vm_bootstrap_user: "{{ os_distribution if os_distribution == 'ubuntu' else 'cloud-user' }}"
3+
# List of storage volume groups. See mrlesmithjr.manage-lvm role for
4+
# format.
5+
infra_vm_lvm_groups:
6+
- "{{ stackhpc_lvm_group_rootvg }}"

etc/kayobe/environments/ci-multinode/inventory/group_vars/seed/network-interfaces

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
###############################################################################
33
# Network interface definitions for the seed group.
44

5-
admin_oc_interface: "{{ 'ens2' if (os_distribution == 'ubuntu' and ansible_facts['distribution_release'] != 'jammy') else 'ens3' }}"
5+
admin_oc_interface: "{{ ansible_facts.default_ipv4.interface }}"
66

77
provision_oc_interface: "{{ vxlan_interfaces[0].device}}.{{ provision_oc_vlan }}"
88

etc/kayobe/environments/ci-multinode/inventory/group_vars/storage/network-interfaces

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
###############################################################################
33
# Network interface definitions for the storage group.
44

5-
admin_oc_interface: "ens3"
5+
admin_oc_interface: "{{ ansible_facts.default_ipv4.interface }}"
66

77
internal_interface: "{{ vxlan_interfaces[0].device }}.{{ internal_vlan }}"
88

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
# List of extra LVs to include in the rootvg VG.
3+
stackhpc_lvm_group_rootvg_lvs_extra:
4+
- "{{ stackhpc_lvm_lv_docker }}"
5+
6+
###############################################################################
7+
# StackHPC LVM Logical Volume (LV) configuration.
8+
9+
# StackHPC LVM lv_swap LV size.
10+
stackhpc_lvm_lv_swap_size: 1g
11+
12+
# StackHPC LVM lv_root LV size.
13+
stackhpc_lvm_lv_root_size: 10g
14+
15+
# StackHPC LVM lv_tmp LV size.
16+
stackhpc_lvm_lv_tmp_size: 10g
17+
18+
# StackHPC LVM lv_var LV size.
19+
stackhpc_lvm_lv_var_size: 20g
20+
21+
# StackHPC LVM lv_var_tmp LV size.
22+
stackhpc_lvm_lv_var_tmp_size: 5g
23+
24+
# StackHPC LVM lv_log LV size.
25+
stackhpc_lvm_lv_log_size: 10g
26+
27+
# StackHPC LVM lv_audit LV size.
28+
stackhpc_lvm_lv_audit_size: 5g
29+
30+
# StackHPC LVM lv_home LV size.
31+
stackhpc_lvm_lv_home_size: 5g
32+
33+
# StackHPC LVM lv_docker LV size.
34+
stackhpc_lvm_lv_docker_size: 75%FREE
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
###############################################################################
3+
# Network interface definitions for the wazuh-manager group.
4+
5+
admin_oc_interface: "{{ ansible_facts.default_ipv4.interface }}"
6+
7+
###############################################################################
8+
# Dummy variable to allow Ansible to accept this file.
9+
workaround_ansible_issue_8743: yes

0 commit comments

Comments
 (0)