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

Feature file permissions #430

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
22 changes: 20 additions & 2 deletions REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ The following parameters are available in the `logstash` class:
* [`home_dir`](#-logstash--home_dir)
* [`logstash_user`](#-logstash--logstash_user)
* [`logstash_group`](#-logstash--logstash_group)
* [`config_user`](#-logstash--config_user)
* [`config_group`](#-logstash--config_group)
* [`purge_config`](#-logstash--purge_config)
* [`service_provider`](#-logstash--service_provider)
* [`settings`](#-logstash--settings)
Expand Down Expand Up @@ -220,18 +222,34 @@ Default value: `'/usr/share/logstash'`

Data type: `String`

The user that Logstash should run as. This also controls file ownership.
The user that Logstash should run as.

Default value: `'logstash'`

##### <a name="-logstash--logstash_group"></a>`logstash_group`

Data type: `String`

The group that Logstash should run as. This also controls file group ownership.
The group that Logstash should run as.

Default value: `'logstash'`

##### <a name="-logstash--config_user"></a>`config_user`

Data type: `String`

The user that owns Logstash control files.

Default value: `'root'`

##### <a name="-logstash--config_group"></a>`config_group`

Data type: `String`

The group that owns Logstash control files.

Default value: `'root'`

##### <a name="-logstash--purge_config"></a>`purge_config`

Data type: `Boolean`
Expand Down
10 changes: 5 additions & 5 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
require logstash::package

File {
owner => 'root',
group => 'root',
owner => $logstash::config_user,
group => $logstash::config_group,
}

# Configuration "fragment" directories for pipeline config and pattern files.
Expand All @@ -21,22 +21,22 @@
if($logstash::ensure == 'present') {
file { $logstash::config_dir:
ensure => directory,
mode => '0755',
mode => '0750',
}

file { "${logstash::config_dir}/conf.d":
ensure => directory,
purge => $logstash::purge_config,
recurse => $logstash::purge_config,
mode => '0775',
mode => '0770',
notify => Service['logstash'],
}

file { "${logstash::config_dir}/patterns":
ensure => directory,
purge => $logstash::purge_config,
recurse => $logstash::purge_config,
mode => '0755',
mode => '0750',
}
}
elsif($logstash::ensure == 'absent') {
Expand Down
4 changes: 2 additions & 2 deletions manifests/configfile.pp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
) {
include logstash

$owner = 'root'
$group = $logstash::logstash_group
$owner = $logstash::config_user
$group = $logstash::config_group
$mode = '0640'
$require = Package['logstash'] # So that we have '/etc/logstash/conf.d'.
$tag = ['logstash_config'] # So that we notify the service.
Expand Down
12 changes: 10 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,16 @@
# The home directory for logstash.
#
# @param [String] logstash_user
# The user that Logstash should run as. This also controls file ownership.
# The user that Logstash should run as.
#
# @param [String] logstash_group
# The group that Logstash should run as. This also controls file group ownership.
# The group that Logstash should run as.
#
# @param [String] config_user
# The user that owns Logstash control files.
#
# @param [String] config_group
# The group that owns Logstash control files.
#
# @param [Boolean] purge_config
# Purge the config directory of any unmanaged files,
Expand Down Expand Up @@ -152,6 +158,8 @@
Stdlib::Absolutepath $home_dir = '/usr/share/logstash',
$logstash_user = 'logstash',
$logstash_group = 'logstash',
$config_user = 'root',
$config_group = 'root',
$config_dir = '/etc/logstash',
Boolean $purge_config = true,
$service_provider = undef,
Expand Down
8 changes: 4 additions & 4 deletions manifests/patternfile.pp
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# This type represents a Grok pattern file for Logstash.
#
# @param [String] source
# @param source
# File source for the pattern file. eg. `puppet://[...]` or `file://[...]`
#
# @param [String] filename
# @param filename
# Optionally set the destination filename.
#
# @example Define a pattern file.
Expand All @@ -30,8 +30,8 @@
file { "${logstash::config_dir}/patterns/${destination}":
ensure => file,
source => $source,
owner => 'root',
group => $logstash::logstash_group,
owner => $logstash::config_user,
group => $logstash::config_group,
mode => '0640',
tag => ['logstash_config'],
}
Expand Down
6 changes: 3 additions & 3 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
$pipelines = $logstash::pipelines

File {
owner => 'root',
group => 'root',
mode => '0644',
owner => $logstash::config_user,
group => $logstash::config_group,
mode => '0640',
notify => Exec['logstash-system-install'],
}

Expand Down
Loading