Skip to content

Commit

Permalink
Merge pull request #409 from bastelfreak/lint
Browse files Browse the repository at this point in the history
puppet-lint: autofix
  • Loading branch information
bastelfreak authored Feb 3, 2022
2 parents 66ea87f + 8a2d711 commit 3bc653e
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Vagrantfile.d/manifests/site.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
}

logstash::plugin { 'logstash-input-mysql':
environment => ['LS_JAVA_OPTS=-Xms1g -Xmx1g']
environment => ['LS_JAVA_OPTS=-Xms1g -Xmx1g'],
}
2 changes: 1 addition & 1 deletion manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
notify => Service['logstash'],
}

file { "${logstash::config_dir}/patterns":
file { "${logstash::config_dir}/patterns":
ensure => directory,
purge => $logstash::purge_config,
recurse => $logstash::purge_config,
Expand Down
13 changes: 6 additions & 7 deletions manifests/configfile.pp
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,26 @@
#
# @author https://github.com/elastic/puppet-logstash/graphs/contributors
#
define logstash::configfile(
define logstash::configfile (
$content = undef,
$source = undef,
$template = undef,
$path = undef,
)
{
) {
include logstash

$owner = 'root'
$group = $logstash::logstash_group
$mode = '0640'
$require = Package['logstash'] # So that we have '/etc/logstash/conf.d'.
$tag = [ 'logstash_config' ] # So that we notify the service.
$tag = ['logstash_config'] # So that we notify the service.

if($template) { $config = template($template) }
if($template) { $config = template($template) }
elsif($content) { $config = $content }
else { $config = undef }
else { $config = undef }

if($path) { $config_file = $path }
else { $config_file = "${logstash::config_dir}/conf.d/${name}" }
else { $config_file = "${logstash::config_dir}/conf.d/${name}" }

if($config) {
file { $config_file:
Expand Down
9 changes: 4 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
#
# @author https://github.com/elastic/puppet-logstash/graphs/contributors
#
class logstash(
class logstash (
$ensure = 'present',
$status = 'enabled',
Boolean $restart_on_change = true,
Expand All @@ -153,15 +153,14 @@
$jvm_options = [],
Array $pipelines = [],
Boolean $manage_repo = true,
)
{
) {
$home_dir = '/usr/share/logstash'

if ! ($ensure in [ 'present', 'absent' ]) {
if ! ($ensure in ['present', 'absent']) {
fail("\"${ensure}\" is not a valid ensure parameter value")
}

if ! ($status in [ 'enabled', 'disabled', 'running', 'unmanaged' ]) {
if ! ($status in ['enabled', 'disabled', 'running', 'unmanaged']) {
fail("\"${status}\" is not a valid status parameter value")
}

Expand Down
17 changes: 8 additions & 9 deletions manifests/package.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
#
# @author https://github.com/elastic/puppet-logstash/graphs/contributors
#
class logstash::package(
class logstash::package (
$package_url = $logstash::package_url,
$version = $logstash::version,
$package_name = $logstash::package_name,
)
{
) {
Exec {
path => [ '/bin', '/usr/bin', '/usr/local/bin' ],
path => ['/bin', '/usr/bin', '/usr/local/bin'],
cwd => '/',
tries => 3,
try_sleep => 10,
Expand All @@ -38,7 +37,7 @@
if $logstash::ensure == 'present' {
# Check if we want to install a specific version.
if $version {
if $::osfamily == 'redhat' {
if $facts['os']['family'] == 'redhat' {
# Prerelease RPM packages have tildes ("~") in their version strings,
# which can be quite surprising to the user. Let them say:
# 6.0.0-rc2
Expand Down Expand Up @@ -88,8 +87,8 @@
}

case $extension {
'deb': { $package_provider = 'dpkg' }
'rpm': { $package_provider = 'rpm' }
'deb': { $package_provider = 'dpkg' }
'rpm': { $package_provider = 'rpm' }
default: { fail("Unknown file extension '${extension}'.") }
}

Expand All @@ -99,7 +98,7 @@
# Use the OS packaging system to locate the package.
$package_local_file = undef
$package_provider = undef
if $::osfamily == 'Debian' {
if $facts['os']['family'] == 'Debian' {
$package_require = $logstash::manage_repo ? {
true => Class['apt::update'],
false => undef,
Expand All @@ -112,7 +111,7 @@
else { # Package removal
$package_local_file = undef
$package_require = undef
if ($::osfamily == 'Suse') {
if ($facts['os']['family'] == 'Suse') {
$package_provider = 'rpm'
$package_ensure = 'absent' # "purged" not supported by provider
}
Expand Down
3 changes: 1 addition & 2 deletions manifests/plugin.pp
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@
$source = undef,
$ensure = present,
$environment = [],
)
{
) {
require logstash::package
$exe = "${logstash::home_dir}/bin/logstash-plugin"

Expand Down
18 changes: 9 additions & 9 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -81,38 +81,38 @@

if $service_ensure == 'running' {
# Then make sure the Logstash startup options are up to date.
file {'/etc/logstash/startup.options':
file { '/etc/logstash/startup.options':
content => template('logstash/startup.options.erb'),
}

# ..and make sure the JVM options are up to date.
file {'/etc/logstash/jvm.options':
file { '/etc/logstash/jvm.options':
content => template('logstash/jvm.options.erb'),
}

# ..and pipelines.yml, if the user provided such. If they didn't, zero out
# the file, which will default Logstash to traditional single-pipeline
# behaviour.
if(empty($pipelines)) {
file {'/etc/logstash/pipelines.yml':
file { '/etc/logstash/pipelines.yml':
content => '',
}
}
else {
file {'/etc/logstash/pipelines.yml':
file { '/etc/logstash/pipelines.yml':
content => template('logstash/pipelines.yml.erb'),
}
}

# ..and the Logstash internal settings too.
file {'/etc/logstash/logstash.yml':
file { '/etc/logstash/logstash.yml':
content => template('logstash/logstash.yml.erb'),
}

# Invoke 'system-install', which generates startup scripts based on the
# contents of the 'startup.options' file.
# Only if restart_on_change is not false
if $::logstash::restart_on_change {
if $logstash::restart_on_change {
exec { 'logstash-system-install':
command => "${logstash::home_dir}/bin/system-install",
refreshonly => true,
Expand All @@ -128,8 +128,8 @@

# Figure out which service provider (init system) we should be using.
# In general, we'll try to guess based on the operating system.
$os = downcase($::operatingsystem)
$release = $::operatingsystemmajrelease
$os = downcase($facts['os']['name'])
$release = $facts['os']['release']['major']
# However, the operator may have explicitly defined the service provider.
if($logstash::service_provider) {
$service_provider = $logstash::service_provider
Expand Down Expand Up @@ -174,7 +174,7 @@

# If any files tagged as config files for the service are changed, notify
# the service so it restarts.
if $::logstash::restart_on_change {
if $logstash::restart_on_change {
File<| tag == 'logstash_config' |> ~> Service['logstash']
Logstash::Plugin<| |> ~> Service['logstash']
}
Expand Down

0 comments on commit 3bc653e

Please sign in to comment.