Skip to content

Commit 02bcf5e

Browse files
authored
Merge pull request #582 from wazuh/4.3-merge-4-4
Merge 4.3 into 4.4
2 parents 836347c + eb8288e commit 02bcf5e

14 files changed

+363
-146
lines changed

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,36 @@ All notable changes to this project will be documented in this file.
77

88
- Support to 4.4.0 Wazuh release.
99

10+
## Wazuh Puppet v4.3.8
11+
12+
### Added
13+
14+
- Support to 4.3.8 Wazuh release.
15+
16+
## Wazuh Puppet v4.3.7
17+
18+
### Added
19+
20+
- Support to 4.3.7 Wazuh release.
21+
22+
## Wazuh Puppet v4.3.6
23+
24+
### Added
25+
26+
- Support to 4.3.6 Wazuh release.
27+
28+
## Wazuh Puppet v4.3.5
29+
30+
### Added
31+
32+
- Support to 4.3.5 Wazuh release.
33+
34+
## Wazuh Puppet v4.3.4
35+
36+
### Added
37+
38+
- Support to 4.3.4 Wazuh release.
39+
1040
## Wazuh Puppet v4.3.3
1141

1242
### Added

manifests/activeresponse.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
$active_response_timeout = undef,
1414
$active_response_repeated_offenders = [],
1515
$target_arg = 'manager_ossec.conf',
16-
$order_arg = undef,
16+
$order_arg = 80,
1717
$before_arg = undef,
1818
$content_arg = 'wazuh/fragments/_activeresponse.erb'
1919
) {

manifests/agent.pp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,9 @@
320320
case $::operatingsystem {
321321
'RedHat', 'OracleLinux':{
322322
$apply_template_os = 'rhel'
323-
if ( $::operatingsystemrelease =~ /^7.*/ ){
323+
if ( $::operatingsystemrelease =~ /^8.*/ ){
324+
$rhel_version = '8'
325+
}elsif ( $::operatingsystemrelease =~ /^7.*/ ){
324326
$rhel_version = '7'
325327
}elsif ( $::operatingsystemrelease =~ /^6.*/ ){
326328
$rhel_version = '6'
@@ -657,7 +659,7 @@
657659
owner => 'root',
658660
group => 'wazuh',
659661
mode => '0640',
660-
content => $wazuh::params_agent::wazuh_enrollment_auth_pass,
662+
content => $wazuh_enrollment_auth_pass,
661663
require => Package[$wazuh::params_agent::agent_package_name],
662664
}
663665
}

manifests/certificates.pp

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,29 @@
44
$wazuh_repository = 'packages.wazuh.com',
55
$wazuh_version = '4.4',
66
) {
7+
file { 'Configure Wazuh Certificates config.yml':
8+
owner => 'root',
9+
path => '/tmp/config.yml',
10+
group => 'root',
11+
mode => '0640',
12+
content => template('wazuh/wazuh_config_yml.erb'),
13+
}
714

8-
$certs_path = '/tmp/wazuh-certificates'
9-
10-
$path_exists = find_file($certs_path)
11-
12-
unless $path_exists {
13-
file { 'Configure config.yml':
14-
owner => 'root',
15-
path => '/tmp/config.yml',
16-
group => 'root',
17-
mode => '0644',
18-
content => template('wazuh/wazuh_config_yml.erb'),
19-
}
20-
21-
exec { 'Create Wazuh Certificates':
22-
path => '/usr/bin:/bin',
23-
command => "curl -so /tmp/wazuh-certs-tool.sh 'https://${wazuh_repository}/${wazuh_version}/wazuh-certs-tool.sh'\
24-
&& chmod 744 /tmp/wazuh-certs-tool.sh\
25-
&& bash /tmp/wazuh-certs-tool.sh --all",
26-
27-
}
15+
file { '/tmp/wazuh-certs-tool.sh':
16+
ensure => file,
17+
source => "https://${wazuh_repository}/${wazuh_version}/wazuh-certs-tool.sh",
18+
owner => 'root',
19+
group => 'root',
20+
mode => '0740',
2821
}
2922

23+
exec { 'Create Wazuh Certificates':
24+
path => '/usr/bin:/bin',
25+
command => 'bash /tmp/wazuh-certs-tool.sh --all',
26+
creates => '/tmp/wazuh-certificates',
27+
require => [
28+
File['/tmp/wazuh-certs-tool.sh'],
29+
File['/tmp/config.yml'],
30+
],
31+
}
3032
}
31-

manifests/dashboard.pp

Lines changed: 71 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,61 +9,100 @@
99
$indexer_server_ip = 'localhost',
1010
$indexer_server_port = '9200',
1111
$dashboard_path_certs = '/etc/wazuh-dashboard/certs',
12+
$dashboard_fileuser = 'wazuh-dashboard',
13+
$dashboard_filegroup = 'wazuh-dashboard',
1214

13-
$dashboard_server_port = '5601',
15+
$dashboard_server_port = '443',
1416
$dashboard_server_host = '0.0.0.0',
15-
$dashboard_server_hosts ="https://${indexer_server_ip}:$indexer_server_port}",
16-
$dashboard_wazuh_api_credentials = [ {
17-
'id' => 'default',
18-
'url' => 'http://localhost',
19-
'port' => '55000',
20-
'user' => 'foo',
21-
'password' => 'bar',
22-
},
23-
]
17+
$dashboard_server_hosts = "https://${indexer_server_ip}:${indexer_server_port}",
18+
$dashboard_wazuh_api_credentials = [
19+
{
20+
'id' => 'default',
21+
'url' => 'https://localhost',
22+
'port' => '55000',
23+
'user' => 'foo',
24+
'password' => 'bar',
25+
},
26+
],
27+
28+
$manage_repos = false, # Change to true when manager is not present.
2429
) {
30+
if $manage_repos {
31+
include wazuh::repo
32+
33+
if $::osfamily == 'Debian' {
34+
Class['wazuh::repo'] -> Class['apt::update'] -> Package['wazuh-dashboard']
35+
} else {
36+
Class['wazuh::repo'] -> Package['wazuh-dashboard']
37+
}
38+
}
2539

2640
# assign version according to the package manager
27-
case $::osfamily {
28-
'Debian' : {
41+
case $facts['os']['family'] {
42+
'Debian': {
2943
$dashboard_version_install = "${dashboard_version}-*"
3044
}
31-
'Linux', 'RedHat' : {
32-
$dashboard_version_install = "${dashboard_version}"
45+
'Linux', 'RedHat', default: {
46+
$dashboard_version_install = $dashboard_version
3347
}
3448
}
3549

3650
# install package
37-
package { 'Installing Wazuh Dashboard...':
51+
package { 'wazuh-dashboard':
3852
ensure => $dashboard_version_install,
3953
name => $dashboard_package,
4054
}
4155

42-
include wazuh::certificates
56+
require wazuh::certificates
4357

44-
exec { 'Copy Dashboard Certificates':
58+
exec { "ensure full path of ${dashboard_path_certs}":
4559
path => '/usr/bin:/bin',
46-
command => "mkdir $dashboard_path_certs \
47-
&& cp /tmp/wazuh-certificates/dashboard.pem $dashboard_path_certs\
48-
&& cp /tmp/wazuh-certificates/dashboard-key.pem $dashboard_path_certs\
49-
&& cp /tmp/wazuh-certificates/root-ca.pem $dashboard_path_certs\
50-
&& chown wazuh-dashboard:wazuh-dashboard -R $dashboard_path_certs\
51-
&& chmod 500 $dashboard_path_certs\
52-
&& chmod 400 $dashboard_path_certs/*",
60+
command => "mkdir -p ${dashboard_path_certs}",
61+
creates => $dashboard_path_certs,
62+
require => Package['wazuh-dashboard'],
63+
}
64+
-> file { $dashboard_path_certs:
65+
ensure => directory,
66+
owner => $dashboard_fileuser,
67+
group => $dashboard_filegroup,
68+
mode => '0500',
69+
}
5370

71+
[
72+
'dashboard.pem',
73+
'dashboard-key.pem',
74+
'root-ca.pem',
75+
].each |String $certfile| {
76+
file { "${dashboard_path_certs}/${certfile}":
77+
ensure => file,
78+
owner => $dashboard_fileuser,
79+
group => $dashboard_filegroup,
80+
mode => '0400',
81+
replace => false, # only copy content when file not exist
82+
source => "/tmp/wazuh-certificates/${certfile}",
83+
}
84+
}
85+
86+
# TODO: Fully manage the opensearch_dashboards.yml and a template file resource
87+
file_line { 'Setting host for wazuh-dashboard':
88+
path => '/etc/wazuh-dashboard/opensearch_dashboards.yml',
89+
line => "server.host: ${dashboard_server_host}",
90+
match => "^server.host:\s",
91+
require => Package['wazuh-dashboard'],
92+
notify => Service['wazuh-dashboard'],
93+
}
94+
file_line { 'Setting port for wazuh-dashboard':
95+
path => '/etc/wazuh-dashboard/opensearch_dashboards.yml',
96+
line => "server.port: ${dashboard_server_port}",
97+
match => "^server.port:\s",
98+
require => Package['wazuh-dashboard'],
99+
notify => Service['wazuh-dashboard'],
54100
}
55101

56102
service { 'wazuh-dashboard':
57103
ensure => running,
58104
enable => true,
59105
hasrestart => true,
106+
name => $dashboard_service,
60107
}
61-
62-
exec {'Waiting for Wazuh indexer...':
63-
path => '/usr/bin',
64-
command => "curl -u ${dashboard_user}:${dashboard_password} -k -s -XGET https://${indexer_server_ip}:${indexer_server_port}",
65-
tries => 100,
66-
try_sleep => 3,
67-
}
68-
69108
}

0 commit comments

Comments
 (0)