-
Notifications
You must be signed in to change notification settings - Fork 178
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
Multiple outputs #277
base: master
Are you sure you want to change the base?
Multiple outputs #277
Changes from all commits
94dc545
224c9f0
554cef6
83a5239
0572213
b17e826
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,22 @@ | |
# | ||
# @summary Manage the filebeat service | ||
class filebeat::service { | ||
service { 'filebeat': | ||
ensure => $filebeat::real_service_ensure, | ||
enable => $filebeat::real_service_enable, | ||
provider => $filebeat::service_provider, | ||
if keys($filebeat::outputs).length <= 1 { | ||
service { 'filebeat': | ||
ensure => $filebeat::real_service_ensure, | ||
enable => $filebeat::real_service_enable, | ||
provider => $filebeat::service_provider, | ||
} | ||
} | ||
else { | ||
systemd::unit_file { "filebeat.service": | ||
content => template($filebeat::systemd_composite_service_template), | ||
} | ||
~> service {'filebeat': | ||
enable => $filebeat::real_service_enable, | ||
ensure => $filebeat::real_service_ensure, | ||
provider => $filebeat::service_provider, | ||
} | ||
} | ||
|
||
$major_version = $filebeat::major_version | ||
|
@@ -65,5 +77,40 @@ | |
} | ||
} | ||
} | ||
} | ||
define filebeat::service::add { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we split the defined type in to its own file. We might want to think about titling this one a little different too since we're not creating a new "add". I don't have another idea yet though. |
||
if $::service_provider == 'systemd' { | ||
if $name == $filebeat::module_name { | ||
$service_name = $name | ||
} | ||
else { | ||
$service_name = "${filebeat::module_name}.${name}" | ||
file { "/var/lib/filebeat/${name}": | ||
ensure => directory, | ||
mode => '0750', | ||
owner => $filebeat::config_file_owner, | ||
group => $filebeat::config_file_group, | ||
before => Systemd::Unit_file["${filebeat::module_name}.${name}.service"], | ||
} | ||
file { "/var/log/filebeat/${name}": | ||
ensure => directory, | ||
mode => '0700', | ||
owner => $filebeat::config_file_owner, | ||
group => $filebeat::config_file_group, | ||
before => Systemd::Unit_file["${filebeat::module_name}.${name}.service"], | ||
} | ||
} | ||
systemd::unit_file { "${service_name}.service": | ||
content => template($filebeat::systemd_service_template), | ||
} | ||
~> service {"${service_name}": | ||
enable => $filebeat::real_service_enable, | ||
ensure => $filebeat::real_service_ensure, | ||
provider => $filebeat::service_provider, | ||
} | ||
|
||
} | ||
else { | ||
warning("You\'re trying to add service to systemd for the additional output '${name}', but the system is using '${::service_provider}' instead of systemd.") | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[Unit] | ||
Description=Filebeat composite service to start multiple outputs. | ||
Documentation=https://www.elastic.co/products/beats/filebeat | ||
Wants=network-online.target | ||
After=network-online.target | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/bin/true | ||
RemainAfterExit=yes | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
[Unit] | ||
Description=Filebeat sends log files to <%= @name %>. | ||
Documentation=https://www.elastic.co/products/beats/filebeat | ||
Wants=network-online.target | ||
After=network-online.target | ||
|
||
[Service] | ||
Environment="BEAT_LOG_OPTS=" | ||
Environment="BEAT_CONFIG_OPTS=-c /etc/filebeat/filebeat.<%= @name %>.yml" | ||
Environment="BEAT_PATH_OPTS=--path.home /usr/share/filebeat --path.config /etc/filebeat --path.data /var/lib/filebeat/<%= @name %> --path.logs /var/log/filebeat/<%= @name %>" | ||
ExecStart=/usr/share/filebeat/bin/filebeat --environment systemd $BEAT_LOG_OPTS $BEAT_CONFIG_OPTS $BEAT_PATH_OPTS | ||
Restart=always | ||
|
||
[Install] | ||
WantedBy=filebeat.service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love the idea of using the upstream elastic repo as suggested in #189, but we customize a few things in the setup. I think it's reasonable to ask users that need those customizations to set
manage_repo
to false and manage it themselves, but we should probably remove references to the parameters too (README, params.pp, init.pp).