Skip to content

Commit 5acaaf4

Browse files
committed
Merge stackhpc/xena into stackhpc/yoga
2 parents 6368678 + 8bfb7bd commit 5acaaf4

File tree

14 files changed

+895
-1
lines changed

14 files changed

+895
-1
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,15 @@ etc/kayobe/inventory/group_vars/seed/ansible-host
4343
# Ignore kolla configuration.
4444
etc/kolla
4545

46+
# Ignore wazuh
47+
etc/kayobe/ansible/roles/wazuh-ansible/
48+
etc/kayobe/ansible/wazuh/certificates/*
49+
etc/kayobe/ansible/wazuh/certificates/custom_certificates/*
50+
4651
# Ignore ceph generated config in AUFN env
4752
etc/kayobe/environments/aufn-ceph/kolla/config/glance/ceph.conf
4853
etc/kayobe/environments/aufn-ceph/kolla/config/glance/ceph.client.glance.keyring
4954
etc/kayobe/environments/aufn-ceph/kolla/config/cinder/ceph.conf
5055
etc/kayobe/environments/aufn-ceph/kolla/config/cinder/ceph.client.glance.keyring
5156
etc/kayobe/environments/aufn-ceph/kolla/config/nova/ceph.conf
52-
etc/kayobe/environments/aufn-ceph/kolla/config/nova/ceph.client.glance.keyring
57+
etc/kayobe/environments/aufn-ceph/kolla/config/nova/ceph.client.glance.keyring

doc/source/configuration/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ the various features provided.
1515
swap
1616
cephadm
1717
monitoring
18+
wazuh

doc/source/configuration/wazuh.rst

Lines changed: 330 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,330 @@
1+
=====
2+
Wazuh
3+
=====
4+
5+
Wazuh Manager
6+
=============
7+
8+
Provision using infra-vms
9+
-------------------------
10+
11+
Provisioning an infra VM for Wazuh Manager.
12+
13+
From Xena, Kayobe supports :kayobe-doc:`provisioning infra VMs <deployment.html#infrastructure-vms>`. The StackHPC fork of Kayobe has backported this to Wallaby.
14+
The following configuration may be used as a guide. Config for infra VMs is documented :kayobe-doc:`here <configuration/reference/infra-vms>`.
15+
16+
17+
Set the python interpreter in
18+
``etc/kayobe/inventory/group_vars/infra-vms/ansible-python-interpreter``:
19+
20+
21+
.. code-block:: console
22+
23+
---
24+
# Use a virtual environment for remote operations.
25+
ansible_python_interpreter: "{{ virtualenv_path }}/kayobe/bin/python"
26+
27+
28+
Define VM sizing in ``etc/kayobe/inventory/group_vars/wazuh-manager/infra-vms``:
29+
30+
.. code-block:: console
31+
32+
---
33+
# Memory in MB.
34+
infra_vm_memory_mb: 16384
35+
36+
37+
# Number of vCPUs.
38+
infra_vm_vcpus: 8
39+
40+
41+
# Capacity of the infra VM data volume.
42+
infra_vm_data_capacity: "200G"
43+
44+
45+
Optional: define LVM volumes ``etc/kayobe/inventory/group_vars/wazuh-manager/lvm``:
46+
47+
.. code-block:: console
48+
49+
# List of infra VM volume groups. See mrlesmithjr.manage-lvm role for
50+
# format.
51+
infra_vm_lvm_groups:
52+
- vgname: "data"
53+
disks:
54+
- "/dev/vdb"
55+
create: true
56+
lvnames:
57+
- lvname: "data"
58+
size: "100%VG"
59+
filesystem: "ext4"
60+
mount: true
61+
mntp: “/var/lib/elasticsearch”
62+
create: true
63+
64+
65+
Define network interfaces ``etc/kayobe/inventory/group_vars/wazuh-manager/network-interfaces``:
66+
67+
(The following is an example - the names will depend on your particular network configuration.)
68+
69+
.. code-block:: console
70+
71+
---
72+
# Overcloud provisioning network IP information.
73+
provision_oc_net_interface: "ens3"
74+
75+
76+
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.
79+
80+
.. code-block:: console
81+
82+
infra_vm_extra_network_interfaces:
83+
- "extra_net"
84+
85+
# External network connectivity on ens2
86+
extra_net_interface: "ens2"
87+
88+
89+
Follow the Kayobe instructions to :kayobe-doc:`provision the VM <deployment.html#infrastructure-vms>` and configure the host.
90+
91+
92+
Network Setup
93+
-------------
94+
95+
Your wazuh-manager VM needs to have network connection with servers which will have the wazuh-agent installed, preferably it should be in the `provision_oc_net`.
96+
97+
98+
Required ports
99+
--------------
100+
101+
Several services are used for the communication of Wazuh components. Below is the list of default ports used by these services.
102+
103+
+-----------------+-----------+----------------+------------------------------------------------+
104+
| Component | Port | Protocol | Purpose |
105+
+=================+===========+================+================================================+
106+
| | 1514 | TCP (default) | Agent connection service |
107+
+ +-----------+----------------+------------------------------------------------+
108+
| | 1514 | UDP (optional) | Agent connection service (disabled by default) |
109+
+ +-----------+----------------+------------------------------------------------+
110+
| Wazuh server | 1515 | TCP | Agent enrollment service |
111+
+ +-----------+----------------+------------------------------------------------+
112+
| | 1516 | TCP | Wazuh cluster daemon |
113+
+ +-----------+----------------+------------------------------------------------+
114+
| | 514 | UDP (default) | Wazuh Syslog collector (disabled by default) |
115+
+ +-----------+----------------+------------------------------------------------+
116+
| | 514 | TCP (optional) | Wazuh Syslog collector (disabled by default) |
117+
+ +-----------+----------------+------------------------------------------------+
118+
| | 55000 | TCP | Wazuh server RESTful API |
119+
+-----------------+-----------+----------------+------------------------------------------------+
120+
| | 9200 | TCP | Wazuh indexer RESTful API |
121+
+ Wazuh indexer +-----------+----------------+------------------------------------------------+
122+
| | 9300-9400 | TCP | Wazuh indexer cluster communication |
123+
+-----------------+-----------+----------------+------------------------------------------------+
124+
| Wazuh dashboard | 443 | TCP | Wazuh web user interface |
125+
+-----------------+-----------+----------------+------------------------------------------------+
126+
127+
128+
Manually provisioned VM
129+
-----------------------
130+
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):
133+
134+
* Depending on preferences host have to be part of some group in inventory. ``infra-vms`` group still seems as best choice
135+
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.
138+
It can be achieved in many different ways, depending on your setup.
139+
* 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``.
143+
For example, if using host with IP 10.10.224.5 in network 10.10.224.0/24 one have to add:
144+
145+
146+
``networks.yml``:
147+
148+
.. code-block:: console
149+
150+
undercloud_admin_net_cidr: 10.10.224.0/24
151+
undercloud_admin_net_allocation_pool_start: 10.10.224.3
152+
undercloud_admin_net_allocation_pool_end: 10.10.224.200
153+
undercloud_admin_net_gateway: 10.10.224.254
154+
155+
156+
``network-allocation.yml``:
157+
158+
.. code-block:: console
159+
160+
undercloud_admin_net_ips:
161+
nesmetprd01: 10.10.224.5
162+
163+
Note that in this example network name is ``undercloud`` to demonstrate that this network isn't "standard" kayobe network.
164+
165+
166+
Deploying Wazuh Manager services
167+
================================
168+
169+
Setup
170+
-----
171+
172+
To install specific version modify wazuh-ansible entry in ``etc/kayobe/ansible/requirements.yml``:
173+
174+
.. code-block:: console
175+
176+
roles:
177+
- name: wazuh-ansible
178+
src: https://github.com/stackhpc/wazuh-ansible
179+
version: stackhpc
180+
181+
Version above was tested and verified, but there is no reason to use not different one.
182+
183+
Install the role:
184+
185+
``kayobe control host bootstrap``
186+
187+
188+
Edit the playbook and variables to your needs:
189+
190+
Wazuh manager configuration
191+
---------------------------
192+
193+
Wazuh manager playbook is located in ``etc/kayobe/ansible/wazuh-manager.yml``.
194+
Running this playbook will:
195+
196+
* generate certificates for wazuh-manager
197+
* setup and deploy filebeat on wazuh-manager vm
198+
* setup and deploy wazuh-indexer on wazuh-manager vm
199+
* setup and deploy wazuh-manager on wazuh-manager vm
200+
* setup and deploy wazuh-dashboard on wazuh-manager vm
201+
* copy certificates over to wazuh-manager vm
202+
203+
Wazuh manager variables file is located in ``etc/kayobe/inventory/group_vars/wazuh-manager/wazuh-manager``.
204+
205+
You may need to modify some of the variables, including:
206+
207+
* wazuh_manager_ip
208+
209+
210+
.. note::
211+
212+
NOTE:
213+
If you are using multiple environments, and you need to customise Wazuh in each environement, create override files in an appropriate directory,
214+
for example `etc/kayobe/environments/production/inventory/group_vars/`
215+
Files which values can be overridden (in context of Wazuh):
216+
- etc/kayobe/inventory/group_vars/wazuh/wazuh-manager/wazuh-manager
217+
- etc/kayobe/wazuh-manager.yml
218+
- etc/kayobe/inventory/group_vars/wazuh/wazuh-agent/wazuh-agent
219+
220+
Secrets
221+
-------
222+
223+
Wazuh secrets playbook is located in ``etc/kayobe/ansible/wazuh-secrets.yml``.
224+
Running this playbook will generate and put pertinent security items into secrets
225+
vault file which will be placed in ``$KAYOBE_CONFIG_PATH/wazuh-secrets.yml``.
226+
If using environments it ends up in ``$KAYOBE_CONFIG_PATH/environments/<env_name>/wazuh-secrets.yml``
227+
Remember to encrypt!
228+
229+
Wazuh secrets template is located in ``etc/kayobe/ansible/templates/wazuh-secrets.yml.j2``.
230+
It will be used by wazuh secrets playbook to generate wazuh secrets vault file.
231+
232+
233+
.. code-block:: console
234+
235+
kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/wazuh-secrets.yml
236+
ansible-vault encrypt --vault-password-file ~/vault.pass $KAYOBE_CONFIG_PATH/inventory/group_vars/wazuh/wazuh-manager/wazuh-secrets
237+
238+
239+
TLS (optional)
240+
--------------
241+
242+
You can generate your own TLS certificates, otherwise skip this section.
243+
By default, Wazuh Ansible uses `wazuh-cert-tool.sh <https://documentation.wazuh.com/current/user-manual/certificates.html>`__
244+
to automatically
245+
generate certificates for wazuh-indexer (previously Elasticsearch and opendistro)
246+
and wazuh-dashbooard (previously Kibana) using a local CA.
247+
If the certificates directory ``etc/kayobe/ansible/wazuh/certificates``
248+
does not exist, it will generate the following certificates in ``etc/kayobe/ansible/wazuh/certificates/certs/``
249+
(here os-wazuh is set as ``elasticsearch_node_name`` and ``kibana_node_name``:
250+
251+
252+
* Admin certificate for opendistro security
253+
* admin-key.pem, admin.pem
254+
* Node certificate
255+
* os-wazuh-key.pem, os-wazuh.pem
256+
* HTTP certificate for wazuh-dashboard (port 5601) & wazuh-indexer (port 9200)
257+
* os-wazuh_http.key, os-wazuh_http.pem
258+
* Root CA certificate
259+
* root-ca.key root-ca.pem
260+
261+
262+
263+
It is also possible to use externally generated certificates for wazuh-dashboard. root-ca.pem should contain the CA chain.
264+
Those certificates can be uploaded to ``etc/kayobe/ansible/wazuh/custom_certificates``,
265+
and will replace certificates generated by wazuh.
266+
Certificates should have the same name scheme as those generated by wazuh (typicaly <node-name>.pem)
267+
The key for the external certificate should be in PKCS#8 format
268+
(in its header it may have BEGIN PRIVATE KEY instead of BEGIN RSA PRIVATE KEY or BEGIN OPENSSH PRIVATE KEY).
269+
270+
Example OpenSSL rune to convert to PKCS#8:
271+
272+
``openssl pkcs8 -topk8 -nocrypt -in wazuh.key -out wazuh.key.pkcs8``
273+
274+
TODO: document how to use a local certificate. Do we need to override all certificates?
275+
276+
Deploy
277+
------
278+
279+
Deploy Wazuh manager:
280+
281+
``kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/wazuh-manager.yml``
282+
283+
If you are using the wazuh generated certificates,
284+
this will result in the creation of some certificates and keys (in case of custom certs adjust path to it).
285+
Encrypt the keys (and remember to commit to git):
286+
287+
288+
``ansible-vault encrypt --vault-password-file ~/vault.pass $KAYOBE_CONFIG_PATH/ansible/wazuh/certificates/certs/*.key``
289+
290+
Verification
291+
==============
292+
293+
The Wazuh portal should be accessible on port 443 of the Wazuh
294+
manager’s IPs (using HTTPS, with the root CA cert in ``etc/kayobe/ansible/wazuh/certificates/wazuh-certificates/root-ca.pem``).
295+
The first login should be as the admin user,
296+
with the opendistro_admin_password password in ``$KAYOBE_CONFIG_PATH/wazuh-secrets.yml``.
297+
This will create the necessary indices.
298+
299+
Troubleshooting
300+
301+
Logs are in ``/var/log/wazuh-indexer/wazuh.log``. There are also logs in the journal.
302+
303+
============
304+
Wazuh agents
305+
============
306+
307+
308+
Wazuh agent playbook is located in ``etc/kayobe/ansible/wazuh-agent.yml``.
309+
310+
Wazuh agent variables file is located in ``etc/kayobe/inventory/group_vars/wazuh-agent/wazuh-agent``.
311+
312+
You may need to modify some variables, including:
313+
314+
* wazuh_manager_address
315+
316+
Deploy the Wazuh agents:
317+
318+
``kayobe playbook run $KAYOBE_CONFIG_PATH/ansible/wazuh-agent.yml``
319+
320+
Verification
321+
=============
322+
323+
The Wazuh agents should register with the Wazuh manager. This can be verified via the agents page in Wazuh Portal.
324+
Check CIS benchmark output in agent section.
325+
326+
Additional resources:
327+
=====================
328+
329+
For times when you need to upgrade wazuh with elasticsearch to version with opensearch or you just need to deinstall all wazuh components:
330+
Wazuh purge script: https://github.com/stackhpc/wazuh-server-purge

doc/source/contributor/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ This guide is for contributors of the StackHPC Kayobe configuration project.
1010
documentation
1111
release-notes
1212
environments/index
13+
package-updates

0 commit comments

Comments
 (0)