Wazuh with Puppet - Configuration Management

The wazuh-puppet module provides classes for installing and configuring all Wazuh 4.14 components through Puppet. It covers the manager, agent, indexer, and dashboard, with full Hiera support for centralized parameter management.

Prerequisites

Puppet infrastructure

  • Puppet Server 7.x or 8.x
  • Puppet Agent 7.x or 8.x on target nodes
  • PuppetDB (recommended for exported resource management)
  • r10k or Code Manager for module management

Target nodes

Module installation

From Puppet Forge

puppet module install wazuh-wazuh

Via Puppetfile (r10k)

Add to your Puppetfile:

mod 'wazuh-wazuh',
  :git => 'https://github.com/wazuh/wazuh-puppet.git',
  :tag => 'v4.14.3'

Deploy the environment:

r10k deploy environment production

Module dependencies

The wazuh-puppet module depends on the following modules:

ModulePurpose
puppetlabs-stdlibStandard functions and types
puppetlabs-aptAPT repository management (Debian/Ubuntu)
puppetlabs-concatConfiguration file assembly
puppetlabs-firewallFirewall rule management (optional)

Install dependencies:

puppet module install puppetlabs-stdlib
puppet module install puppetlabs-apt
puppet module install puppetlabs-concat

Module classes

Class overview

ClassPurpose
wazuh::managerInstall and configure the Wazuh Manager
wazuh::agentInstall and configure the Wazuh Agent
wazuh::indexerInstall and configure the Wazuh Indexer
wazuh::dashboardInstall and configure the Wazuh Dashboard
wazuh::repoConfigure the Wazuh package repository

Manager deployment

Basic configuration

class { 'wazuh::manager':
  ossec_manager_config => {
    'global' => {
      'jsonout_output' => 'yes',
      'logall'         => 'no',
    },
    'cluster' => {
      'disabled'  => 'yes',
      'name'      => 'wazuh-cluster',
      'node_name' => 'manager-master',
      'node_type' => 'master',
      'key'       => 'MyClusterSecretKey',
    },
    'api' => {
      'bind_addr' => '0.0.0.0',
      'port'      => '55000',
    },
  },
  ossec_manager_authd => {
    'enabled'      => 'yes',
    'use_password' => 'no',
    'purge'        => 'no',
  },
}

Manager cluster configuration

For the master node:

node 'manager-master.example.com' {
  class { 'wazuh::manager':
    ossec_manager_config => {
      'cluster' => {
        'disabled'  => 'no',
        'name'      => 'wazuh-cluster',
        'node_name' => 'manager-master',
        'node_type' => 'master',
        'key'       => 'MyClusterSecretKey',
        'port'      => '1516',
        'bind_addr' => '0.0.0.0',
        'nodes'     => ['manager-master.example.com'],
      },
    },
  }
}

For a worker node:

node 'manager-worker.example.com' {
  class { 'wazuh::manager':
    ossec_manager_config => {
      'cluster' => {
        'disabled'  => 'no',
        'name'      => 'wazuh-cluster',
        'node_name' => 'manager-worker',
        'node_type' => 'worker',
        'key'       => 'MyClusterSecretKey',
        'port'      => '1516',
        'bind_addr' => '0.0.0.0',
        'nodes'     => ['manager-master.example.com'],
      },
    },
  }
}

Agent deployment

Basic deployment

class { 'wazuh::agent':
  wazuh_manager_address => '192.168.1.20',
  agent_name            => $facts['hostname'],
  agent_group           => 'default',
  manage_repo           => true,
}

Deployment with password-based enrollment

class { 'wazuh::agent':
  wazuh_manager_address       => '192.168.1.20',
  agent_name                  => $facts['hostname'],
  agent_group                 => 'linux-servers',
  ossec_agent_enrollment      => {
    'enabled'         => 'yes',
    'manager_address' => '192.168.1.20',
    'auth_password'   => 'AgentEnrollmentPassword',
  },
}

Bulk deployment via site.pp

node /^web-server-\d+\.example\.com$/ {
  class { 'wazuh::agent':
    wazuh_manager_address => '192.168.1.20',
    agent_group           => 'web-servers',
  }
}

node /^db-server-\d+\.example\.com$/ {
  class { 'wazuh::agent':
    wazuh_manager_address => '192.168.1.20',
    agent_group           => 'database-servers',
  }
}

Class parameters

wazuh::manager parameters

ParameterTypeDescriptionDefault
ossec_manager_configHashCore ossec.conf configurationSee module
ossec_manager_authdHashAuthd settings{'enabled' => 'yes'}
manage_repoBooleanManage the package repositorytrue
manage_serviceBooleanManage the systemd servicetrue
service_ensureStringService staterunning
service_enableBooleanEnable service at boottrue
manage_firewallBooleanManage firewall rulesfalse

wazuh::agent parameters

ParameterTypeDescriptionDefault
wazuh_manager_addressStringManager address-
agent_nameStringAgent name$facts['hostname']
agent_groupStringAgent groupdefault
manage_repoBooleanManage the repositorytrue
manage_serviceBooleanManage the servicetrue
ossec_agent_enrollmentHashAuto-enrollment settings{}
ossec_agent_configHashAgent ossec.conf configurationSee module

wazuh::indexer parameters

ParameterTypeDescriptionDefault
indexer_cluster_nameStringCluster namewazuh-cluster
indexer_node_nameStringNode namewazuh-indexer-1
indexer_node_masterBooleanMaster-eligible roletrue
indexer_node_dataBooleanData roletrue
indexer_network_hostStringBind address0.0.0.0
indexer_admin_passwordStringAdmin passwordSecretPassword
indexer_jvm_xmsStringJVM Heap min1g
indexer_jvm_xmxStringJVM Heap max1g

Hiera integration

Hiera data structure

File data/common.yaml:

wazuh::manager::ossec_manager_config:
  global:
    jsonout_output: 'yes'
    logall: 'no'
  cluster:
    disabled: 'yes'
  api:
    bind_addr: '0.0.0.0'
    port: '55000'

wazuh::manager::ossec_manager_authd:
  enabled: 'yes'
  use_password: 'no'

wazuh::agent::wazuh_manager_address: '192.168.1.20'
wazuh::agent::agent_group: 'default'
wazuh::agent::manage_repo: true

Per-environment overrides

File data/environments/production.yaml:

wazuh::manager::ossec_manager_config:
  cluster:
    disabled: 'no'
    name: 'prod-wazuh-cluster'
    key: '%{lookup("wazuh_cluster_key")}'

wazuh::indexer::indexer_admin_password: '%{lookup("wazuh_indexer_password")}'

Per-role overrides

File data/roles/web-server.yaml:

wazuh::agent::agent_group: 'web-servers'
wazuh::agent::ossec_agent_config:
  syscheck:
    frequency: '43200'
    directories:
      - path: '/var/www'
        check_all: 'yes'
        realtime: 'yes'

Secrets via Hiera eyaml

Protect passwords using hiera-eyaml:

wazuh_cluster_key: >
  ENC[PKCS7,MIIBiQYJKoZIhvcNAQcDoIIBejCCAXYCAQAx...]
wazuh_indexer_password: >
  ENC[PKCS7,MIIBiQYJKoZIhvcNAQcDoIIBejCCAXYCAQAx...]

Troubleshooting

Module not found

Symptoms: error Could not find class wazuh::manager.

Solution:

  1. Verify the module installation:
puppet module list | grep wazuh
  1. Confirm that modulepath in puppet.conf includes the directory containing the module

  2. When using r10k, redeploy:

r10k deploy environment production -pv

Agent service does not start after catalog application

Symptoms: Puppet reports a successful run, but the wazuh-agent service is not running.

Solution:

  1. Check the service status:
systemctl status wazuh-agent
  1. Review agent logs:
tail -50 /var/ossec/logs/ossec.log
  1. Verify that wazuh_manager_address points to a reachable manager

Module version conflicts

Symptoms: dependency errors during module installation.

Solution:

  1. Force-update dependencies:
puppet module install wazuh-wazuh --force
  1. Check version compatibility in the module’s metadata.json

  2. When using a Puppetfile, pin specific versions for all dependencies

Hiera data not applied

Symptoms: parameters from Hiera are ignored; defaults are used instead.

Solution:

  1. Inspect the Hiera hierarchy:
puppet lookup --explain wazuh::agent::wazuh_manager_address
  1. Verify that hiera.yaml contains correct data file paths

  2. Validate YAML syntax in data files

Additional resources

Last updated on