Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.4 branch update with changes applied in 4.3 #581

Merged
merged 10 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
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
55 changes: 29 additions & 26 deletions manifests/dashboard.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
$dashboard_package = 'wazuh-dashboard',
$dashboard_service = 'wazuh-dashboard',
$dashboard_version = '4.4.0',
$dashboard_user = 'admin',
$dashboard_password = 'admin',
$indexer_server_ip = 'localhost',
$indexer_server_port = '9200',
$dashboard_path_certs = '/etc/wazuh-dashboard/certs',
Expand All @@ -14,27 +12,24 @@

$dashboard_server_port = '443',
$dashboard_server_host = '0.0.0.0',
$dashboard_server_hosts = "https://${indexer_server_ip}:${indexer_server_port}",
$indexer_server_host = "https://${indexer_server_ip}:${indexer_server_port}",
$dashboard_wazuh_api_credentials = [
{
'id' => 'default',
'url' => 'https://localhost',
'port' => '55000',
'user' => 'foo',
'password' => 'bar',
'user' => 'wazuh-wui',
'password' => 'wazuh-wui',
},
],

$manage_repos = false, # Change to true when manager is not present.
) {
if $manage_repos {
include wazuh::repo

if $::osfamily == 'Debian' {
Class['wazuh::repo'] -> Class['apt::update'] -> Package['wazuh-dashboard']
} else {
Class['wazuh::repo'] -> Package['wazuh-dashboard']
}
include wazuh::repo

if $::osfamily == 'Debian' {
Class['wazuh::repo'] -> Class['apt::update'] -> Package['wazuh-dashboard']
} else {
Class['wazuh::repo'] -> Package['wazuh-dashboard']
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not remove the possibility to disable the repo management. This feature is requested by the community for the case where they want to use there own repo mirror instead of the default repo.
When you want and need you can set the default of manage_repos to true.

It was set to false to be backward compatible with the state before the PR #529.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done: dd7060b


# assign version according to the package manager
Expand Down Expand Up @@ -84,19 +79,13 @@
}

# TODO: Fully manage the opensearch_dashboards.yml and a template file resource
file_line { 'Setting host for wazuh-dashboard':
path => '/etc/wazuh-dashboard/opensearch_dashboards.yml',
line => "server.host: ${dashboard_server_host}",
match => "^server.host:\s",
require => Package['wazuh-dashboard'],
notify => Service['wazuh-dashboard'],
}
file_line { 'Setting port for wazuh-dashboard':
path => '/etc/wazuh-dashboard/opensearch_dashboards.yml',
line => "server.port: ${dashboard_server_port}",
match => "^server.port:\s",
file { '/etc/wazuh-dashboard/opensearch_dashboards.yml':
owner => 'wazuh-dashboard',
group => 'wazuh-dashboard',
mode => '0640',
content => template('wazuh/opensearch_dashboards_yml.erb'),
require => Package['wazuh-dashboard'],
notify => Service['wazuh-dashboard'],
notify => Service['wazuh-dashboard']
}

service { 'wazuh-dashboard':
Expand All @@ -105,4 +94,18 @@
hasrestart => true,
name => $dashboard_service,
}

exec {'Waiting for Wazuh dashboard...':
require => Service[$dashboard_service],
command => "sleep 15 ",
path => "/usr/bin:/bin",
}

file { '/usr/share/wazuh-dashboard/data/wazuh/config/wazuh.yml':
owner => 'wazuh-dashboard',
group => 'wazuh-dashboard',
mode => '0600',
content => template('wazuh/wazuh_yml.erb'),
require => Package['wazuh-dashboard']
}
Copy link
Contributor

@cruelsmith cruelsmith Sep 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
exec {'Waiting for Wazuh dashboard...':
require => Service[$dashboard_service],
command => "sleep 15 ",
path => "/usr/bin:/bin",
}
file { '/usr/share/wazuh-dashboard/data/wazuh/config/wazuh.yml':
owner => 'wazuh-dashboard',
group => 'wazuh-dashboard',
mode => '0600',
content => template('wazuh/wazuh_yml.erb'),
require => Package['wazuh-dashboard']
}
file { '/usr/share/wazuh-dashboard/data/wazuh/config/wazuh.yml':
owner => 'wazuh-dashboard',
group => 'wazuh-dashboard',
mode => '0600',
content => template('wazuh/wazuh_yml.erb'),
require => Package['wazuh-dashboard'],
notify => Service['wazuh-dashboard'],
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not possible to apply this suggestion because this file is not created with the installation of the package, for this reason, the first solution was to apply a delay to give time for this file to be created.

Now we have taken a new approach, first we create the directories and then the file, in this way the file is maintained and works correctly, without the need to wait for a delay:

file { ['/usr/share/wazuh-dashboard/data/wazuh/',
'/usr/share/wazuh-dashboard/data/wazuh/config/']:
ensure => 'directory',
owner => 'wazuh-dashboard',
group => 'wazuh-dashboard',
mode => '0600',
require => Package['wazuh-dashboard'],
notify => Service['wazuh-dashboard'],
}
file { '/usr/share/wazuh-dashboard/data/wazuh/config/wazuh.yml':
owner => 'wazuh-dashboard',
group => 'wazuh-dashboard',
mode => '0600',
content => template('wazuh/wazuh_yml.erb'),
require => Package['wazuh-dashboard'],
notify => Service['wazuh-dashboard'],
}

}
5 changes: 3 additions & 2 deletions manifests/filebeat_oss.pp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
# TODO: Include file into the wazuh/wazuh-puppet project or use file { checksum => '..' } for this instead of the exec construct.
exec { 'cleanup /etc/filebeat/wazuh-template.json':
command => '/bin/rm /etc/filebeat/wazuh-template.json',
unless => "/bin/cmp -s '/etc/filebeat/wazuh-template.json' <(curl -s https://raw.githubusercontent.com/wazuh/wazuh/${wazuh_extensions_version}/extensions/elasticsearch/7.x/wazuh-template.json)",
onlyif => '/bin/test -f /etc/filebeat/wazuh-template.json',
unless => "/bin/curl -s 'https://raw.githubusercontent.com/wazuh/wazuh/${wazuh_extensions_version}/extensions/elasticsearch/7.x/wazuh-template.json' | /bin/cmp -s '/etc/filebeat/wazuh-template.json'",
}
-> file { '/etc/filebeat/wazuh-template.json':
owner => 'root',
Expand Down Expand Up @@ -113,4 +114,4 @@
name => $filebeat_oss_service,
require => Package['filebeat'],
}
}
}
15 changes: 6 additions & 9 deletions manifests/indexer.pp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Setup for Wazuh Indexer
class wazuh::indexer (
# opensearch.yml configuration
$indexer_network_host = '0.0.0.0',
$indexer_cluster_name = 'wazuh-cluster',
$indexer_node_name = 'node-1',
$indexer_node_max_local_storage_nodes = '1',
Expand All @@ -20,18 +21,14 @@
$indexer_discovery_hosts = [], # Empty array for single-node configuration
$indexer_cluster_initial_master_nodes = ['node-1'],

$manage_repos = false, # Change to true when manager is not present.

# JVM options
$jvm_options_memory = '1g',
) {
if $manage_repos {
include wazuh::repo
if $facts['os']['family'] == 'Debian' {
Class['wazuh::repo'] -> Class['apt::update'] -> Package['wazuh-indexer']
} else {
Class['wazuh::repo'] -> Package['wazuh-indexer']
}
include wazuh::repo
if $facts['os']['family'] == 'Debian' {
Class['wazuh::repo'] -> Class['apt::update'] -> Package['wazuh-indexer']
} else {
Class['wazuh::repo'] -> Package['wazuh-indexer']
}

# install package
Expand Down
14 changes: 14 additions & 0 deletions templates/opensearch_dashboards_yml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
server.host: <%= @dashboard_server_host %>
server.port: <%= @dashboard_server_port %>
opensearch.hosts: <%= @indexer_server_host %>
opensearch.ssl.verificationMode: certificate
#opensearch.username:
#opensearch.password:
opensearch.requestHeadersWhitelist: ["securitytenant","Authorization"]
opensearch_security.multitenancy.enabled: false
opensearch_security.readonly_mode.roles: ["kibana_read_only"]
server.ssl.enabled: true
server.ssl.key: "/etc/wazuh-dashboard/certs/dashboard-key.pem"
server.ssl.certificate: "/etc/wazuh-dashboard/certs/dashboard.pem"
opensearch.ssl.certificateAuthorities: ["/etc/wazuh-dashboard/certs/root-ca.pem"]
uiSettings.overrides.defaultRoute: /app/wazuh
19 changes: 7 additions & 12 deletions templates/wazuh_api_yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ https:
# Values for API log level: disabled, info, warning, error, debug, debug2 (each level includes the previous level).
logs:
level: <%= @wazuh_api_logs_level %>
format: <%= @wazuh_api_logs_format %>
# Cross-origin resource sharing: https://github.com/aio-libs/aiohttp-cors#usage
cors:
enabled: <%= @wazuh_api_cors_enabled %>
Expand All @@ -39,14 +38,10 @@ drop_privileges: <%= @wazuh_api_drop_privileges %>
# Enable features under development
experimental_features: <%= @wazuh_api_experimental_features %>
# Enable remote commands
upload_configuration:
remote_commands:
localfile:
allow: <%= @remote_commands_localfile %>
exceptions: <%= @remote_commands_localfile_exceptions %>
wodle_command:
allow: <%= @remote_commands_wodle %>
exceptions: <%= @remote_commands_wodle_exceptions %>
limits:
eps:
allow: <%= @limits_eps %>
remote_commands:
localfile:
enabled: <%= @remote_commands_localfile %>
exceptions: <%= @remote_commands_localfile_exceptions %>
wodle_command:
enabled: <%= @remote_commands_wodle %>
exceptions: <%= @remote_commands_wodle_exceptions %>
2 changes: 1 addition & 1 deletion templates/wazuh_indexer_yml.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
network.host: "0.0.0.0"
network.host: "<%= @indexer_network_host %>"
node.name: "<%= @indexer_node_name %>"
cluster.initial_master_nodes:
<% @indexer_cluster_initial_master_nodes.each do |node| -%>
Expand Down
2 changes: 1 addition & 1 deletion templates/wazuh_yml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
# user: <user>
# password: <password>
hosts:
<% @kibana_wazuh_api_credentials.each do |api_profile| -%>
<% @dashboard_wazuh_api_credentials.each do |api_profile| -%>
- <%= api_profile['id'] %>:
url: <%= api_profile['url'] %>
port: <%= api_profile['port'] %>
Expand Down