Skip to content

Commit 40c65a9

Browse files
authored
Merge pull request #562 from wazuh/enhancement/545-update-ova-documentation-with-local-build
Add documentation for local ova build
2 parents bfdac8a + 18ffd73 commit 40c65a9

File tree

6 files changed

+86
-3
lines changed

6 files changed

+86
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ All notable changes to this project will be documented in this file.
55

66
### Added
77

8+
- Add documentation for local ova build ([#562](https://github.com/wazuh/wazuh-virtual-machines/pull/562))
89
- Add the installation assistant tools revision in the generate presigned urls script ([#531](https://github.com/wazuh/wazuh-virtual-machines/pull/531))
910
- Added debug mode to customizer script for AMI. ([#513](https://github.com/wazuh/wazuh-virtual-machines/pull/513))
1011

docs/SUMMARY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
- [Installation](ref/installation/installation.md)
2323
- [AMI Installation](ref/installation/ami/ami-installation.md)
2424
- [OVA Installation](ref/installation/ova/ova-installation.md)
25+
- [Local OVA Installation](ref/installation/ova/local-ova-installation.md)
2526
- [Configuration](ref/configuration/configuration.md)
2627
- [AMI Configuration](ref/configuration/ami/ami-configuration.md)
2728
- [OVA Configuration](ref/configuration/ova/ova-configuration.md)

docs/ref/installation/installation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ This section covers how to correctly install AMI and OVA. Once the installation
44

55
- **AMI installation** ([ami-installation.md](ami/ami-installation.md)): This section covers the installation of the AMI on AWS. It includes the steps to create an EC2 instance using the AMI.
66
- **OVA installation** ([ova-installation.md](ova/ova-installation.md)): This section covers the installation of the OVA on VirtualBox. It includes the steps to import the OVA into VirtualBox.
7+
- **Local OVA creation** ([local-ova-installation.md](ova/local-ova-installation.md)): This section covers how to create the OVA locally. It includes the steps to set up the environment and build the OVA.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# Local OVA installation
2+
3+
In this section, we describe how to create a virtual machine (VM) in Open Virtual Appliance (OVA) format with the Wazuh server, dashboard, and indexer components pre-installed. To build it locally, we will use the `wazuh_local_ova` module from the [Wazuh Virtual Machines](https://github.com/wazuh/wazuh-virtual-machines/tree/main/wazuh_local_ova) repository.
4+
5+
You need a system with a minimum of 4 CPU cores and 8 GB of RAM to build the virtual machine. Ensure that these dependencies are installed on the system:
6+
7+
- Virtual Box
8+
- Vagrant
9+
- Git
10+
- Python
11+
- Make sure `pip` and `hatch` are installed for Python
12+
13+
14+
## Create the Wazuh VM
15+
16+
To create the Wazuh OVA locally, we will use the `wazuh_local_ova` module. This module is written in Python and has the following options:
17+
18+
| Option | Short | Description | Required | Default |
19+
|--------|-------|-------------|----------|---------|
20+
| `--name` | `-n` | Name of the generated `.ova` file | No | `wazuh-local-ova` |
21+
| `--output` | `-o` | Directory where the `.ova` file will be stored | No | Current directory |
22+
| `--packages_url_path` | `-p` | Path to the file containing the package download URLs | **Yes** | - |
23+
| `--checksum` | `-c` | Generate a `.sha512` file for the OVA | No | `False` |
24+
25+
The file specified in `--packages_url_path` must contain the URLs of the Wazuh core component packages. Below is an example of the file content with the different supported package nomenclatures:
26+
27+
```yaml
28+
wazuh_manager_amd64_deb: "http://example.com/wazuh-manager-amd64.deb"
29+
wazuh_manager_arm64_deb: "http://example.com/wazuh-manager-arm"
30+
wazuh_manager_amd64_rpm: "http://example.com/wazuh-manager-amd64.rpm"
31+
wazuh_manager_arm64_rpm: "http://example.com/wazuh-manager-arm.rpm"
32+
wazuh_indexer_amd64_deb: "http://example.com/wazuh-indexer-amd64.deb"
33+
wazuh_indexer_arm64_deb: "http://example.com/wazuh-indexer-arm"
34+
wazuh_indexer_amd64_rpm: "http://example.com/wazuh-indexer-amd64.rpm"
35+
wazuh_indexer_arm64_rpm: "http://example.com/wazuh-indexer-arm.rpm"
36+
wazuh_dashboard_amd64_deb: "http://example.com/wazuh-dashboard-amd64.deb"
37+
wazuh_dashboard_arm64_deb: "http://example.com/wazuh-dashboard-arm"
38+
wazuh_dashboard_amd64_rpm: "http://example.com/wazuh-dashboard-amd64.rpm"
39+
wazuh_dashboard_arm64_rpm: "http://example.com/wazuh-dashboard-arm.rpm"
40+
...
41+
```
42+
43+
Follow the steps below to create the Wazuh virtual machine:
44+
45+
1. Clone the Wazuh Virtual Machines repository and select the Wazuh version you want to install in the OVA, in this case `5.0.0`:
46+
47+
```bash
48+
git clone https://github.com/wazuh/wazuh-virtual-machines && cd wazuh-virtual-machines/ && git checkout v5.0.0
49+
```
50+
51+
2. Execute the following command to build the OVA image:
52+
53+
```bash
54+
hatch run local-ova:create -p \<path to the urls file\>
55+
```
56+
57+
This command will set up the execution environment, configure the Vagrant VM and export the OVA image.
58+
59+
You can also customize the name and output directory of the OVA file using the `--name` and `--output` options. For example:
60+
61+
```bash
62+
hatch run local-ova:create -p \<path to the urls file\> -n custom-wazuh-ova -o /path/to/output/directory
63+
```
64+
65+
To see all available options, you can use the `-h` or `--help` flag:
66+
67+
```bash
68+
hatch run local-ova:create --help
69+
```

pyproject.toml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencies = [
1010
"paramiko",
1111
"pyyaml",
1212
"jinja2",
13+
"requests",
1314
]
1415
requires-python = ">= 3.12"
1516
description = "Wazuh - Virtual Machines (OVA and AMI)"
@@ -72,7 +73,6 @@ dependencies = [
7273
"pytest-cov~=6.0",
7374
"pytest-xdist",
7475
"ruff",
75-
"requests",
7676
]
7777

7878
[tool.hatch.envs.dev-provisioner]
@@ -186,3 +186,14 @@ run = "python -m wazuh_local_ova {args:}"
186186

187187
[tool.hatch.envs.dev-ova-dependencies.scripts]
188188
install = "python3 -c 'from configurer.ova.ova_pre_configurer.install_dependencies import main; main()'"
189+
190+
[tool.hatch.envs.local-ova]
191+
description = """
192+
Enviroment to be used for testing all virtual-machines modules
193+
"""
194+
dependencies = [
195+
"typer",
196+
]
197+
198+
[tool.hatch.envs.local-ova.scripts]
199+
create = "python -m wazuh_local_ova {args:}"

wazuh_local_ova/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from .build_ova import configure_vagrant_vm, export_ova_image, generate_checksum, setup_execution_environment
66

7-
app = typer.Typer()
7+
app = typer.Typer(context_settings={"help_option_names": ["-h", "--help"]})
88

99

1010
@app.command(name="create", help="Create a new Wazuh OVA image.")
@@ -32,4 +32,4 @@ def create_ova(
3232

3333

3434
if __name__ == "__main__":
35-
app()
35+
app(prog_name="hatch run local-ova:create")

0 commit comments

Comments
 (0)