diff --git a/README.md b/README.md
index 1400e4d..9dcbe1d 100644
--- a/README.md
+++ b/README.md
@@ -14,6 +14,7 @@
* [Source](#source)
* [Filter](#filter)
* [Match](#match)
+ * [Match Store](#match-store)
* [Plugin Installation](#plugin-installation)
* [Requirements](#requirements)
1. [Limitations - OS compatibility, etc.](#limitations)
@@ -97,9 +98,9 @@ include '::fluentd'
'shared_key' => 'my_shared_key',
'self_hostname' => 'instance.test.com',
'ca_cert_path' => '/path/to/ca.cert',
- 'servers' => {
- 'host' => 'test.server.com'
- }
+ 'server' => [{
+ 'host' => 'test.server.com',
+ }]
}
}
```
@@ -113,9 +114,48 @@ include '::fluentd'
shared_key my_shared_key
self_hostname instance.test.com
ca_cert_path /path/to/ca.cert
-
+
host test.server.com
-
+
+
+```
+### Match Store
+```puppet
+::fluentd::match { 'test':
+ priority => 30,
+ pattern => '*.test',
+ config: {
+ 'type' => 'copy',
+ 'store' => [
+ {
+ 'type' => 'elasticsearch',
+ 'logstashformat' => true,
+ 'hosts' => '172.20.10.17:9200',
+ 'flush_interval' => '30s',
+ },
+ {
+ 'type' => 'file',
+ 'path' => '/tmp/td-agent-debug.log',
+ }
+ ]
+ }
+}
+```
+**creates:**
+```
+/etc/td-agent/conf.d/30-match-test.conf
+
+ type copy
+
+ type elasticsearch
+ logstash_format true
+ hosts 172.20.10.17:9200
+ flush_interval 30s
+
+
+ type file
+ path /tmp/crs
+
```
diff --git a/examples/match.pp b/examples/match.pp
index cafad04..1c78a15 100644
--- a/examples/match.pp
+++ b/examples/match.pp
@@ -9,8 +9,27 @@
'shared_key' => 'my_shared_key',
'self_hostname' => 'instance.test.com',
'ca_cert_path' => '/path/to/ca.cert',
- 'servers' => {
- 'host' => 'test.server.com'
- }
+ 'server' => [{
+ 'host' => 'test.server.com',
+ }]
+ }
+}
+
+::fluentd::match { 'test':
+ priority => 30,
+ pattern => '*.test',
+ config => {
+ 'type' => 'copy',
+ 'store' => [{
+ 'type' => 'elasticsearch',
+ 'logstashformat' => true,
+ 'hosts' => '172.20.10.17:9200',
+ 'flush_interval' => '30s',
+ },
+ {
+ 'type' => 'file',
+ 'path' => '/tmp/td-agent-debug.log',
+ }
+ ]
}
}
diff --git a/manifests/match.pp b/manifests/match.pp
index 98d74e1..2e6a768 100644
--- a/manifests/match.pp
+++ b/manifests/match.pp
@@ -31,9 +31,9 @@
# 'shared_key' => 'my_shared_key',
# 'self_hostname' => 'instance.test.com',
# 'ca_cert_path' => '/path/to/ca.cert',
-# 'servers' => {
+# 'server' => [{
# 'host' => 'test.server.com'
-# }
+# }]
# }
# }
#
diff --git a/spec/defines/match_spec.rb b/spec/defines/match_spec.rb
index a438162..f662b3e 100644
--- a/spec/defines/match_spec.rb
+++ b/spec/defines/match_spec.rb
@@ -24,9 +24,11 @@ describe 'fluentd::match' do
'shared_key' => 'my_shared_key',
'self_hostname' => 'instance.test.com',
'ca_cert_path' => '/path/to/ca.cert',
- 'servers' => {
- 'host' => 'test.server.com'
- }
+ 'server' => [
+ {
+ 'host' => 'test.server.com',
+ }
+ ]
}
}
end
@@ -40,10 +42,52 @@ describe 'fluentd::match' do
with_content(/shared_key my_shared_key/).
with_content(/self_hostname instance.test.com/).
with_content(/ca_cert_path \/path\/to\/ca.cert/).
- with_content(//).
+ with_content(//).
with_content(/host test.server.com/).
- with_content(/<\/servers>/).
+ with_content(/<\/server>/).
with_content(/<\/match>/)
end
end
-end
\ No newline at end of file
+
+ context 'multiple store' do
+ let(:title) { 'test' }
+ let(:params) do
+ {
+ priority: '30',
+ pattern: '*.test',
+ config: {
+ 'type' => 'copy',
+ 'store' => [
+ {
+ 'type' => 'elasticsearch',
+ 'logstashformat' => true,
+ 'hosts' => '172.20.10.17:9200',
+ 'flush_interval' => '30s',
+ },
+ {
+ 'type' => 'file',
+ 'path' => '/tmp/td-agent-debug.log',
+ }
+ ]
+ }
+ }
+ end
+
+ it do
+ is_expected.to contain_file('/etc/td-agent/conf.d/30-match-test.conf').
+ with_content(//).
+ with_content(/type copy/).
+ with_content(//).
+ with_content(/type elasticsearch/).
+ with_content(/logstashformat true/).
+ with_content(/hosts 172.20.10.17:9200/).
+ with_content(/flush_interval 30s/).
+ with_content(/<\/store>/).
+ with_content(//).
+ with_content(/type file/).
+ with_content(/path \/tmp\/td-agent-debug.log/).
+ with_content(/<\/store>/).
+ with_content(/<\/match>/)
+ end
+ end
+end
diff --git a/templates/match.erb b/templates/match.erb
index 6521242..25e1a0c 100644
--- a/templates/match.erb
+++ b/templates/match.erb
@@ -6,6 +6,32 @@
<%= key -%> <%= val %>
<%- end -%>
<%= key %>>
+ <%- elsif val.is_a?( Array ) -%>
+ <%- val.each do |k, v| -%>
+ <<%= key -%>>
+ <%- if k.is_a?( Hash ) -%>
+ <%- k.each do |x, y| -%>
+ <%- if y.is_a?( Array ) -%>
+ <%- y.each do |a, b| -%>
+ <<%= x -%>>
+ <%- if a.is_a?( Hash ) -%>
+ <%- a.each do |c, d| -%>
+ <%= c -%> <%= d %>
+ <%- end -%>
+ <%- else -%>
+ <%= a -%> <%= b %>
+ <%- end -%>
+ <%= x %>>
+ <%- end -%>
+ <%- else -%>
+ <%= x -%> <%= y %>
+ <%- end -%>
+ <%- end -%>
+ <%- else -%>
+ <%= k -%> <%= v %>
+ <%- end -%>
+ <%= key %>>
+ <%- end -%>
<%- else -%>
<%= key -%> <%= val %>
<%- end -%>