Skip to content

Commit

Permalink
Remove file_concat logic
Browse files Browse the repository at this point in the history
  • Loading branch information
ninaspitfire committed Dec 7, 2016
1 parent 2ea7121 commit 054248c
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 60 deletions.
1 change: 0 additions & 1 deletion .fixtures.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ fixtures:
stdlib:
repo: "git://github.com/puppetlabs/puppetlabs-stdlib"
ref: "3.2.0"
file_concat: git://github.com/electrical/puppet-lib-file_concat.git
apt: git://github.com/puppetlabs/puppetlabs-apt.git
zypprepo: https://github.com/deadpoint/puppet-zypprepo.git
symlinks:
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ bundle-install:
bundle install --path .vendor

puppet-module-deps:
for m in puppetlabs/apt puppetlabs/stdlib electrical/file_concat darin/zypprepo ; do \
for m in puppetlabs/apt puppetlabs/stdlib darin/zypprepo ; do \
bundle exec puppet module install --target-dir spec/fixtures/modules --force $$m ; \
done
touch spec/fixtures/manifests/site.pp
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ This overview shows you which Puppet module and Logstash version work together.

* Puppet 3.8.6 or better.
* The [stdlib](https://forge.puppetlabs.com/puppetlabs/stdlib) Puppet library.
* The [electrical/file_concat](https://forge.puppetlabs.com/electrical/file_concat) Puppet library.

Optional:
* The [apt](https://forge.puppetlabs.com/puppetlabs/apt) (>= 2.0.0) Puppet library when using repo management on Debian/Ubuntu.
Expand Down
2 changes: 1 addition & 1 deletion Vagrantfile.d/server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ service puppetserver start
echo '127.0.0.1 localhost puppet' > /etc/hosts

# Install puppet-logstash dependencies.
for mod in puppetlabs-apt puppetlabs-stdlib electrical-file_concat; do
for mod in puppetlabs-apt puppetlabs-stdlib; do
puppet module install --target-dir=/etc/puppetlabs/code/environments/production/modules $mod
done

Expand Down
4 changes: 4 additions & 0 deletions files/null-output.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Test output configuration with null output.
output {
null {}
}
11 changes: 0 additions & 11 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,6 @@
require => File[$logstash::configdir],
}

file_concat { 'ls-config':
ensure => 'present',
tag => "LS_CONFIG_${::fqdn}",
path => "${logstash::configdir}/conf.d/logstash.conf",
owner => $logstash::logstash_user,
group => $logstash::logstash_group,
mode => '0644',
notify => $notify_service,
require => File[ "${logstash::configdir}/conf.d" ],
}

$directories = [
$logstash::patterndir,
$logstash::plugindir,
Expand Down
72 changes: 35 additions & 37 deletions manifests/configfile.pp
Original file line number Diff line number Diff line change
@@ -1,64 +1,62 @@
# == define: logstash::configfile
#
# This define is to manage the config files for Logstah
# This define is to manage the pipeline config files for Logstash
#
# === Parameters
#
# [*content*]
# Supply content to be used for the config file. This can also be a template.
# Supply content to be used for the config file, possibly rendered with
# template().
#
# [*source*]
# Supply a puppet file resource to be used for the config file.
#
# [*order*]
# The order number controls in which sequence the config file fragments are concatenated.
# Supply a file resource to be used for the config file.
#
# === Examples
#
# Set config file content with a literal value:
#
# logstash::configfile { 'apache':
# content => "",
# order => 10
# logstash::configfile { 'heartbeat':
# content => 'input { heartbeat {} }',
# }
#
# or with a puppet file source:
# or with a file source:
#
# logstash::configfile { 'apache':
# source => 'puppet://path/to/apache.conf',
# order => 10
# }
#
# or with template (useful with Hiera):
#
# logstash::configfile { 'apache':
# template => "${module_name}/path/to/apache.conf.erb",
# order => 10
# }
#
# === Authors
#
# * Richard Pijnenburg <mailto:richard.pijnenburg@elasticsearch.com>
# https://github.com/elastic/puppet-logstash/graphs/contributors
#
define logstash::configfile(
$content = undef,
$source = undef,
$order = 10,
$template = undef,
) {
define logstash::configfile($content = undef, $source = undef) {
include logstash

if ($template != undef ) {
$config_content = template($template)
}
else {
$config_content = $content
}
$path = "/etc/logstash/conf.d/${name}.conf"
$owner = $logstash::logstash_user
$group = $logstash::logstash_group
$mode ='0440'
$require = Package['logstash'] # So that we have '/etc/logstash/conf.d'.
$tag = [ 'logstash_config' ] # So that we notify the service.

file_fragment { $name:
tag => "LS_CONFIG_${::fqdn}",
content => $config_content,
source => $source,
order => $order,
before => [ File_concat['ls-config'] ],
if($content){
file { $path:
content => $content,
owner => $owner,
group => $group,
mode => $mode,
require => $require,
tag => $tag,
}
}
elsif($source){
file { $path:
source => $source,
owner => $owner,
group => $group,
mode => $mode,
require => $require,
tag => $tag,
}
}
}
11 changes: 4 additions & 7 deletions metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
{
"name": "puppetlabs/stdlib",
"version_requirement": ">= 3.2.0 <5.0.0"
},
{
"name": "electrical/file_concat",
"version_requirement": ">= 0.1.0 <2.0.0"
}
],
"operatingsystem_support": [
Expand Down Expand Up @@ -57,7 +53,8 @@
"operatingsystem": "Ubuntu",
"operatingsystemrelease": [
"12.04",
"14.04"
"14.04",
"16.04"
]
},
{
Expand All @@ -70,11 +67,11 @@
"requirements": [
{
"name": "pe",
"version_requirement": ">= 3.2.0 <5.0.0"
"version_requirement": ">= 3.8.6 <5.0.0"
},
{
"name": "puppet",
"version_requirement": ">=3.2.0 <5.0.0"
"version_requirement": ">=3.8.6 <5.0.0"
}
]
}
39 changes: 39 additions & 0 deletions spec/acceptance/define_configfile_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
require 'spec_helper_acceptance'

describe 'define logstash::configfile' do
context 'with explicit content' do
logstash_config = 'input { heartbeat {} }'

manifest = <<-END
logstash::configfile { 'heartbeat-input':
content => '#{logstash_config}'
}
END

before(:context) do
apply_manifest(manifest, catch_failures: true)
end

it 'creates a file with the given content' do
result = shell('cat /etc/logstash/conf.d/heartbeat-input.conf').stdout
expect(result).to eq(logstash_config)
end
end

context 'with a puppet:// url as source parameter' do
manifest = <<-END
logstash::configfile { 'null-output':
source => 'puppet:///modules/logstash/null-output.conf'
}
END

before(:context) do
apply_manifest(manifest, catch_failures: true)
end

it 'places the config file' do
result = shell('cat /etc/logstash/conf.d/null-output.conf').stdout
expect(result).to include('Test output configuration with null output.')
end
end
end
1 change: 0 additions & 1 deletion spec/spec_helper_acceptance.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ def puppet_enterprise?
# Also install any other modules we need on the test system.
install_puppet_module_via_pmt_on(host, module_name: 'puppetlabs-stdlib')
install_puppet_module_via_pmt_on(host, module_name: 'puppetlabs-apt')
install_puppet_module_via_pmt_on(host, module_name: 'electrical-file_concat')
install_puppet_module_via_pmt_on(host, module_name: 'darin-zypprepo')
end

Expand Down

0 comments on commit 054248c

Please sign in to comment.