Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
c12f9d8
add: initial support for supporting separately bucketed certificates
griggi-ws Jul 23, 2025
ceb00f1
change: make filebeat_oss `$certfiles` behavior consistent with the rest
griggi-ws Jul 23, 2025
14251d1
add: initial support for the exported resource workflow in indexer
griggi-ws Jul 25, 2025
85e5a27
add: initial support for the exported resource workflow in certificates
griggi-ws Jul 25, 2025
702daab
fix: critical formatting preventing proper catalog evaluation
griggi-ws Jul 25, 2025
9d43dff
fix: resource collector for openssl certs
griggi-ws Aug 1, 2025
bf4f21d
fix: properly map certificate arrays to hash
griggi-ws Aug 6, 2025
ce54bcd
update: include vendor path in gitignore for voxpupuli testing
griggi-ws Aug 6, 2025
eed7a2d
add: flags to certificates to allow use of mountpoint on compilers wi…
griggi-ws Aug 7, 2025
ca42f4b
fix: path for filebucket conf
griggi-ws Aug 7, 2025
9ca37eb
add: defined type wrapper for openssl::certificate::x509 to allow for…
griggi-ws Aug 7, 2025
d3c9406
update: use new keyUsage param for certificates
griggi-ws Aug 7, 2025
044385f
fix: added the missing `keyusage` param, updated the indexer template…
griggi-ws Aug 7, 2025
6ac4e1c
change: enforce indent width for puppet fileserver ini setting
griggi-ws Aug 7, 2025
1025b19
change: certificate mountpoint - use indent width of 4
griggi-ws Aug 7, 2025
47a9ef3
add: relationship between generated certs and indexer service
griggi-ws Aug 7, 2025
8d66d74
fix: use ` ` as a separator rather than ` = ` for ini setting
griggi-ws Aug 7, 2025
e6fd811
add: custom admin cert CN; change: fixed certificate names on disk - …
griggi-ws Aug 8, 2025
82c64e6
update: various adjustments to new cert workflow for filebeat
griggi-ws Aug 8, 2025
1424778
remove: obsolete $wazuh_app_version variable from filebeat_oss class
griggi-ws Aug 8, 2025
1db2f79
fix: update service dependency for filebeat and remove unused puppet …
griggi-ws Aug 8, 2025
4fd0523
change: certificate ownership as `puppet` in new workflow
griggi-ws Aug 8, 2025
90e847d
add: cert generation workflow support to dashboard
griggi-ws Aug 8, 2025
7df59db
add: REFERENCE.md, and `@summary` tags to make it more readable
griggi-ws Aug 8, 2025
fa7e182
add: support for puppet node certs for agent/manager validation
griggi-ws Aug 8, 2025
1d82e52
add: types for parameters that I removed legacy validators for
griggi-ws Aug 8, 2025
a509675
fix: use optional for type enforcement of default undef values
griggi-ws Aug 11, 2025
7287e9e
fix: use optional for type enforcement of default undef values
griggi-ws Aug 11, 2025
399b527
change: ensure the apt-update exec name is distinct from the apt modu…
griggi-ws Aug 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,15 @@ fixtures:
stdlib:
repo: "puppetlabs/stdlib"
ref: "5.0.0"
inifile:
repo: "puppetlabs/inifile"
ref: "6.1.1"
concat:
repo: "puppetlabs/concat"
ref: "7.0.0"
apt:
repo: "puppetlabs/apt"
ref: "8.0.0"
openssl:
repo: "puppet/openssl"
ref: "4.2.0"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.yardoc
.yardwarns
*.iml
.vendor/
/.bundle/
/.idea/
/.vagrant/
Expand Down
5,496 changes: 5,496 additions & 0 deletions REFERENCE.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions manifests/activeresponse.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (C) 2015, Wazuh Inc.
#Define for a specific ossec active-response
define wazuh::activeresponse(
# @summary Define for a specific ossec active-response
define wazuh::activeresponse (
$active_response_name = 'Rendering active-response template',
$active_response_disabled = undef,
$active_response_linux_ca_store = undef,
Expand All @@ -21,6 +21,6 @@
target => $target_arg,
order => $order_arg,
before => $before_arg,
content => template($content_arg)
content => template($content_arg),
}
}
5 changes: 2 additions & 3 deletions manifests/addlog.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (C) 2015, Wazuh Inc.
#Define a log-file to add to ossec
define wazuh::addlog(
# @summary Define a log-file to add to ossec
define wazuh::addlog (
$logfile = undef,
$logtype = 'syslog',
$logcommand = undef,
Expand All @@ -15,5 +15,4 @@
content => template('wazuh/fragments/_localfile_generation.erb'),
order => 21,
}

}
172 changes: 96 additions & 76 deletions manifests/agent.pp

Large diffs are not rendered by default.

15 changes: 7 additions & 8 deletions manifests/audit.pp
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
# Copyright (C) 2015, Wazuh Inc.
# Define an ossec command
# @summary Define an ossec command
class wazuh::audit (
$audit_manage_rules = false,
$audit_buffer_bytes = '8192',
$audit_backlog_wait_time = '0',
$audit_rules = [],
$audit_package_title = 'Installing Audit..',
) {

case $::kernel {
case $facts['kernel'] {
'Linux': {
case $::operatingsystem {
case $facts['os']['name'] {
'Debian', 'debian', 'Ubuntu', 'ubuntu': {
package { $audit_package_title:
name => 'auditd',
}
}
default: {
package { $audit_package_title:
name => 'audit'
name => 'audit',
}
}
}
Expand All @@ -31,21 +30,21 @@

if $audit_manage_rules == true {
file { '/etc/audit/rules.d/audit.rules':
ensure => present,
ensure => file,
require => Service['auditd'],
}

$audit_rules.each |String $rule| {
file_line { "Append rule ${rule} to /etc/audit/rules.d/audit.rules":
path => '/etc/audit/rules.d/audit.rules',
line => $rule,
require => File['/etc/audit/rules.d/audit.rules']
require => File['/etc/audit/rules.d/audit.rules'],
}
}
}
}
default: {
fail("Module Audit not supported on ${::operatingsystem}")
fail("Module Audit not supported on ${facts['os']['name']}")
}
}
}
102 changes: 68 additions & 34 deletions manifests/certificates.pp
Original file line number Diff line number Diff line change
@@ -1,46 +1,80 @@
# Copyright (C) 2015, Wazuh Inc.
# Wazuh repository installation
# @summary Wazuh certificate generation
# If using legacy workflow, this generates all certificates using the
# `wazuh-certs-tool.sh` script and dumps them into Puppet server's code directory.
# (This is less than ideal.)
# If `$use_legacy_workflow` is false, it will use the openssl module and the Puppet CA
# to generate certificates.
# @param use_legacy_workflow
# If true, use the legacy workflow to generate certificates. Use Puppet CA otherwise.

class wazuh::certificates (
$wazuh_repository = 'packages.wazuh.com',
$wazuh_version = '5.0',
Boolean $use_legacy_workflow = true,
String $puppet_code_path = "/etc/puppetlabs/code/environments/${server_facts['environment']}/modules/archive/files",
String $wazuh_repository = 'packages.wazuh.com',
String $wazuh_version = '5.0',
$indexer_certs = [],
$manager_certs = [],
$manager_master_certs = [],
$manager_worker_certs = [],
$dashboard_certs = []
$dashboard_certs = [],
Boolean $manage_certs = true,
Optional[Stdlib::Absolutepath] $ca_cert_path = $settings::cacert,
Optional[Stdlib::Absolutepath] $ca_key_path = $settings::cakey,
String $bucket_name = 'wazuh',
Optional[Stdlib::Absolutepath] $filebucket_path = "${settings::confdir}/filebucket",
Optional[Stdlib::Absolutepath] $fileserver_conf = "${settings::confdir}/fileserver.conf",
) {
file { 'Configure Wazuh Certificates config.yml':
owner => 'root',
path => '/tmp/config.yml',
group => 'root',
mode => '0640',
content => template('wazuh/wazuh_config_yml.erb'),
}
if $use_legacy_workflow {
file { 'Configure Wazuh Certificates config.yml':
owner => 'root',
path => '/tmp/config.yml',
group => 'root',
mode => '0640',
content => template('wazuh/wazuh_config_yml.erb'),
}

file { '/tmp/wazuh-certs-tool.sh':
ensure => file,
source => "https://${wazuh_repository}/${wazuh_version}/wazuh-certs-tool.sh",
owner => 'root',
group => 'root',
mode => '0740',
}
file { '/tmp/wazuh-certs-tool.sh':
ensure => file,
source => "https://${wazuh_repository}/${wazuh_version}/wazuh-certs-tool.sh",
owner => 'root',
group => 'root',
mode => '0740',
}

exec { 'Create Wazuh Certificates':
path => '/usr/bin:/bin',
command => 'bash /tmp/wazuh-certs-tool.sh --all',
creates => '/tmp/wazuh-certificates',
require => [
File['/tmp/wazuh-certs-tool.sh'],
File['/tmp/config.yml'],
],
exec { 'Create Wazuh Certificates':
path => '/usr/bin:/bin',
command => 'bash /tmp/wazuh-certs-tool.sh --all',
creates => '/tmp/wazuh-certificates',
require => [
File['/tmp/wazuh-certs-tool.sh'],
File['/tmp/config.yml'],
],
}
file { 'Copy all certificates into module':
ensure => 'directory',
source => '/tmp/wazuh-certificates/',
recurse => 'remote',
path => $puppet_code_path,
owner => 'root',
group => 'root',
mode => '0755',
}
}
file { 'Copy all certificates into module':
ensure => 'directory',
source => '/tmp/wazuh-certificates/',
recurse => 'remote',
path => '/etc/puppetlabs/code/environments/production/modules/archive/files/',
owner => 'root',
group => 'root',
mode => '0755',
else {
contain wazuh::certificates::mountpoint
if $manage_certs {
Wazuh::Certificates::Certificate <<| tag == 'wazuh' |>> {
ensure => present,
country => 'US',
locality => 'California',
organization => 'Wazuh',
unit => 'Wazuh',
keyusage => ['digitalSignature', 'nonRepudiation', 'keyEncipherment', 'dataEncipherment'],
base_dir => "${filebucket_path}/${bucket_name}",
ca => $ca_cert_path,
cakey => $ca_key_path,
}
}
}
}
104 changes: 104 additions & 0 deletions manifests/certificates/certificate.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# @summary Wraps openssl::certificate::x509 to additionally convert to pkcs8 key (necessary for OpenSearch admin)
#
# @param export_pkcs8
# Whether to export the private key in PKCS8 format, necessary for OpenSearch admin
# @param pkcs8_extension
# The file extension for the PKCS8 key
# @param algo
# The encryption algorithm to use for the PKCS8 key, for use in Java
#
define wazuh::certificates::certificate (
# All necessary params for openssl::certificate::x509
Enum['present', 'absent'] $ensure = present,
Optional[String] $country = undef,
Optional[String] $organization = undef,
Optional[String] $unit = undef,
Optional[String] $state = undef,
Optional[String] $commonname = undef,
Optional[String] $locality = undef,
Array $altnames = [],
Array $keyusage = [],
Array $extkeyusage = [],
Optional[String] $email = undef,
Integer $days = 365,
Stdlib::Absolutepath $base_dir = '/etc/ssl/certs',
Stdlib::Absolutepath $cnf_dir = $base_dir,
Stdlib::Absolutepath $crt_dir = $base_dir,
Stdlib::Absolutepath $csr_dir = $base_dir,
Stdlib::Absolutepath $key_dir = $base_dir,
Stdlib::Absolutepath $cnf = "${cnf_dir}/${name}.cnf",
Stdlib::Absolutepath $crt = "${crt_dir}/${name}.crt",
Stdlib::Absolutepath $csr = "${csr_dir}/${name}.csr",
Stdlib::Absolutepath $key = "${key_dir}/${name}.key",
Integer $key_size = 3072,
Variant[String, Integer] $owner = 'puppet',
Variant[String, Integer] $group = 'puppet',
Variant[String, Integer] $key_owner = $owner,
Variant[String, Integer] $key_group = $group,
Stdlib::Filemode $key_mode = '0600',
Optional[String] $password = undef,
Boolean $force = true,
Boolean $encrypted = true,
Optional[Stdlib::Absolutepath] $ca = undef,
Optional[Stdlib::Absolutepath] $cakey = undef,
Optional[Variant[Sensitive[String[1]], String[1]]] $cakey_password = undef,
# Params specific to this module
Boolean $export_pkcs8 = false,
String $pkcs8_extension = 'pk8',
String $algo = 'PBE-SHA1-3DES',

) {
openssl::certificate::x509 { $name:
ensure => $ensure,
country => $country,
organization => $organization,
unit => $unit,
state => $state,
commonname => $commonname,
locality => $locality,
altnames => $altnames,
keyusage => $keyusage,
extkeyusage => $extkeyusage,
email => $email,
days => $days,
base_dir => $base_dir,
cnf_dir => $cnf_dir,
crt_dir => $crt_dir,
csr_dir => $csr_dir,
key_dir => $key_dir,
cnf => $cnf,
crt => $crt,
csr => $csr,
key => $key,
key_size => $key_size,
owner => $owner,
group => $group,
key_owner => $key_owner,
key_group => $key_group,
key_mode => $key_mode,
password => $password,
force => $force,
encrypted => $encrypted,
ca => $ca,
cakey => $cakey,
cakey_password => $cakey_password,
}
if $export_pkcs8 {
$_cmd = [
'openssl', 'pkcs8', '-topk8',
'-inform', 'PEM',
'-outform', 'PEM',
'-in', $key,
'-out', "${key}.${pkcs8_extension}",
'-v1', $algo,
'-nocrypt',
]
exec { "export ${name} key to pkcs8":
command => $_cmd,
user => $owner,
path => $facts['path'],
subscribe => OpenSSL::Certificate::X509[$name],
refreshonly => true,
}
}
}
55 changes: 55 additions & 0 deletions manifests/certificates/mountpoint.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# @summary Creates a puppet file mountpoint for generated certificates
# on the Puppet server. If you have separate CAs and compilers, you'll
# need to implement syncing of some sort (a network share, rsync, etc)
# and include this class on all compilers as well as the CA.
# Potential improvements:
# - Restrict access to the mountpoint with entries in auth.conf
class wazuh::certificates::mountpoint (
Stdlib::Absolutepath $filebucket_path = $wazuh::certificates::filebucket_path,
Stdlib::Absolutepath $fileserver_conf = $wazuh::certificates::fileserver_conf,
Boolean $manage_fileserver_conf = true,
Boolean $manage_bucket_dir = true,
String $bucket_name = $wazuh::certificates::bucket_name,
String $owner = 'puppet',
String $group = 'puppet',
) {
assert_private()
$_dirs = $manage_bucket_dir ? {
true => [
$filebucket_path,
"${filebucket_path}/${bucket_name}",
],
default => ["${filebucket_path}/${bucket_name}"],
}
file { $_dirs:
ensure => directory,
owner => $owner,
group => $group,
mode => '0750',
}

if $manage_fileserver_conf {
file { $fileserver_conf:
ensure => file,
owner => $owner,
group => $group,
mode => '0640',
}
}

$_tonotify = defined(Service['puppetserver']) ? {
true => Service['puppetserver'],
default => undef,
}

ini_setting { 'wazuh certificates mountpoint':
ensure => present,
path => $fileserver_conf,
section => $bucket_name,
setting => 'path',
value => "${filebucket_path}/${bucket_name}",
indent_width => 4,
key_val_separator => ' ',
notify => $_tonotify,
}
}
4 changes: 2 additions & 2 deletions manifests/command.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Copyright (C) 2015, Wazuh Inc.
# Define an ossec command
define wazuh::command(
# @summary Define an ossec command
define wazuh::command (
$command_name,
$command_executable,
$command_expect = 'srcip',
Expand Down
Loading