Skip to content

Commit 054248c

Browse files
author
Toby McLaughlin
committed
Remove file_concat logic
1 parent 2ea7121 commit 054248c

11 files changed

+84
-60
lines changed

.fixtures.yml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ fixtures:
33
stdlib:
44
repo: "git://github.com/puppetlabs/puppetlabs-stdlib"
55
ref: "3.2.0"
6-
file_concat: git://github.com/electrical/puppet-lib-file_concat.git
76
apt: git://github.com/puppetlabs/puppetlabs-apt.git
87
zypprepo: https://github.com/deadpoint/puppet-zypprepo.git
98
symlinks:

.projectfile .projectile

File renamed without changes.

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ bundle-install:
1818
bundle install --path .vendor
1919

2020
puppet-module-deps:
21-
for m in puppetlabs/apt puppetlabs/stdlib electrical/file_concat darin/zypprepo ; do \
21+
for m in puppetlabs/apt puppetlabs/stdlib darin/zypprepo ; do \
2222
bundle exec puppet module install --target-dir spec/fixtures/modules --force $$m ; \
2323
done
2424
touch spec/fixtures/manifests/site.pp

README.md

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ This overview shows you which Puppet module and Logstash version work together.
2828

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

3332
Optional:
3433
* The [apt](https://forge.puppetlabs.com/puppetlabs/apt) (>= 2.0.0) Puppet library when using repo management on Debian/Ubuntu.

Vagrantfile.d/server.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ service puppetserver start
1919
echo '127.0.0.1 localhost puppet' > /etc/hosts
2020

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

files/null-output.conf

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Test output configuration with null output.
2+
output {
3+
null {}
4+
}

manifests/config.pp

-11
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,6 @@
4747
require => File[$logstash::configdir],
4848
}
4949

50-
file_concat { 'ls-config':
51-
ensure => 'present',
52-
tag => "LS_CONFIG_${::fqdn}",
53-
path => "${logstash::configdir}/conf.d/logstash.conf",
54-
owner => $logstash::logstash_user,
55-
group => $logstash::logstash_group,
56-
mode => '0644',
57-
notify => $notify_service,
58-
require => File[ "${logstash::configdir}/conf.d" ],
59-
}
60-
6150
$directories = [
6251
$logstash::patterndir,
6352
$logstash::plugindir,

manifests/configfile.pp

+35-37
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,62 @@
11
# == define: logstash::configfile
22
#
3-
# This define is to manage the config files for Logstah
3+
# This define is to manage the pipeline config files for Logstash
44
#
55
# === Parameters
66
#
77
# [*content*]
8-
# Supply content to be used for the config file. This can also be a template.
8+
# Supply content to be used for the config file, possibly rendered with
9+
# template().
910
#
1011
# [*source*]
11-
# Supply a puppet file resource to be used for the config file.
12-
#
13-
# [*order*]
14-
# The order number controls in which sequence the config file fragments are concatenated.
12+
# Supply a file resource to be used for the config file.
1513
#
1614
# === Examples
1715
#
1816
# Set config file content with a literal value:
1917
#
20-
# logstash::configfile { 'apache':
21-
# content => "",
22-
# order => 10
18+
# logstash::configfile { 'heartbeat':
19+
# content => 'input { heartbeat {} }',
2320
# }
2421
#
25-
# or with a puppet file source:
22+
# or with a file source:
2623
#
2724
# logstash::configfile { 'apache':
2825
# source => 'puppet://path/to/apache.conf',
29-
# order => 10
30-
# }
31-
#
32-
# or with template (useful with Hiera):
33-
#
34-
# logstash::configfile { 'apache':
35-
# template => "${module_name}/path/to/apache.conf.erb",
36-
# order => 10
3726
# }
3827
#
3928
# === Authors
4029
#
41-
# * Richard Pijnenburg <mailto:richard.pijnenburg@elasticsearch.com>
30+
# https://github.com/elastic/puppet-logstash/graphs/contributors
4231
#
43-
define logstash::configfile(
44-
$content = undef,
45-
$source = undef,
46-
$order = 10,
47-
$template = undef,
48-
) {
32+
define logstash::configfile($content = undef, $source = undef) {
33+
include logstash
4934

50-
if ($template != undef ) {
51-
$config_content = template($template)
52-
}
53-
else {
54-
$config_content = $content
55-
}
35+
$path = "/etc/logstash/conf.d/${name}.conf"
36+
$owner = $logstash::logstash_user
37+
$group = $logstash::logstash_group
38+
$mode ='0440'
39+
$require = Package['logstash'] # So that we have '/etc/logstash/conf.d'.
40+
$tag = [ 'logstash_config' ] # So that we notify the service.
5641

57-
file_fragment { $name:
58-
tag => "LS_CONFIG_${::fqdn}",
59-
content => $config_content,
60-
source => $source,
61-
order => $order,
62-
before => [ File_concat['ls-config'] ],
42+
if($content){
43+
file { $path:
44+
content => $content,
45+
owner => $owner,
46+
group => $group,
47+
mode => $mode,
48+
require => $require,
49+
tag => $tag,
50+
}
51+
}
52+
elsif($source){
53+
file { $path:
54+
source => $source,
55+
owner => $owner,
56+
group => $group,
57+
mode => $mode,
58+
require => $require,
59+
tag => $tag,
60+
}
6361
}
6462
}

metadata.json

+4-7
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111
{
1212
"name": "puppetlabs/stdlib",
1313
"version_requirement": ">= 3.2.0 <5.0.0"
14-
},
15-
{
16-
"name": "electrical/file_concat",
17-
"version_requirement": ">= 0.1.0 <2.0.0"
1814
}
1915
],
2016
"operatingsystem_support": [
@@ -57,7 +53,8 @@
5753
"operatingsystem": "Ubuntu",
5854
"operatingsystemrelease": [
5955
"12.04",
60-
"14.04"
56+
"14.04",
57+
"16.04"
6158
]
6259
},
6360
{
@@ -70,11 +67,11 @@
7067
"requirements": [
7168
{
7269
"name": "pe",
73-
"version_requirement": ">= 3.2.0 <5.0.0"
70+
"version_requirement": ">= 3.8.6 <5.0.0"
7471
},
7572
{
7673
"name": "puppet",
77-
"version_requirement": ">=3.2.0 <5.0.0"
74+
"version_requirement": ">=3.8.6 <5.0.0"
7875
}
7976
]
8077
}
+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
require 'spec_helper_acceptance'
2+
3+
describe 'define logstash::configfile' do
4+
context 'with explicit content' do
5+
logstash_config = 'input { heartbeat {} }'
6+
7+
manifest = <<-END
8+
logstash::configfile { 'heartbeat-input':
9+
content => '#{logstash_config}'
10+
}
11+
END
12+
13+
before(:context) do
14+
apply_manifest(manifest, catch_failures: true)
15+
end
16+
17+
it 'creates a file with the given content' do
18+
result = shell('cat /etc/logstash/conf.d/heartbeat-input.conf').stdout
19+
expect(result).to eq(logstash_config)
20+
end
21+
end
22+
23+
context 'with a puppet:// url as source parameter' do
24+
manifest = <<-END
25+
logstash::configfile { 'null-output':
26+
source => 'puppet:///modules/logstash/null-output.conf'
27+
}
28+
END
29+
30+
before(:context) do
31+
apply_manifest(manifest, catch_failures: true)
32+
end
33+
34+
it 'places the config file' do
35+
result = shell('cat /etc/logstash/conf.d/null-output.conf').stdout
36+
expect(result).to include('Test output configuration with null output.')
37+
end
38+
end
39+
end

spec/spec_helper_acceptance.rb

-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,6 @@ def puppet_enterprise?
242242
# Also install any other modules we need on the test system.
243243
install_puppet_module_via_pmt_on(host, module_name: 'puppetlabs-stdlib')
244244
install_puppet_module_via_pmt_on(host, module_name: 'puppetlabs-apt')
245-
install_puppet_module_via_pmt_on(host, module_name: 'electrical-file_concat')
246245
install_puppet_module_via_pmt_on(host, module_name: 'darin-zypprepo')
247246
end
248247

0 commit comments

Comments
 (0)