Add agent role to fluentd meta for gluster
Put variable pos_file
Change-Id: I33cb8b1c3eb763b64eb54ba4e2ee1ecb270e4075
diff --git a/.gitignore b/.gitignore
index aa8e42a..e8540a5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,4 @@
-.kitchen
+.kitchen/
tests/build/
*.swp
*.pyc
diff --git a/.kitchen.yml b/.kitchen.yml
new file mode 100644
index 0000000..f8fb950
--- /dev/null
+++ b/.kitchen.yml
@@ -0,0 +1,49 @@
+---
+driver:
+ name: docker
+ hostname: glusterfs.ci.local
+ use_sudo: false
+
+provisioner:
+ name: salt_solo
+ salt_install: bootstrap
+ salt_bootstrap_url: https://bootstrap.saltstack.com
+ salt_version: latest
+ require_chef: false
+ log_level: error
+ formula: glusterfs
+ grains:
+ noservices: True
+ state_top:
+ base:
+ "*":
+ - glusterfs
+ pillars:
+ top.sls:
+ base:
+ "*":
+ - glusterfs
+
+verifier:
+ name: inspec
+ sudo: true
+
+
+platforms:
+ - name: <%=ENV['PLATFORM'] || 'ubuntu-xenial'%>
+ driver_config:
+ image: <%=ENV['PLATFORM'] || 'trevorj/salty-whales:xenial'%>
+ platform: ubuntu
+
+suites:
+
+ - name: glusterfs_client
+ provisioner:
+ pillars-from-files:
+ glusterfs.sls: tests/pillar/glusterfs_client.sls
+
+ - name: glusterfs_server
+ provisioner:
+ pillars-from-files:
+ glusterfs.sls: tests/pillar/glusterfs_server.sls
+# vim: ft=yaml sw=2 ts=2 sts=2 tw=125
diff --git a/glusterfs/meta/fluentd.yml b/glusterfs/meta/fluentd.yml
index 9bc1aa3..fd30342 100644
--- a/glusterfs/meta/fluentd.yml
+++ b/glusterfs/meta/fluentd.yml
@@ -1,86 +1,89 @@
-{% from "glusterfs/map.jinja" import client with context %}
-{% from "glusterfs/map.jinja" import server with context %}
-{% set server_enabled = server.get('enabled', False) %}
-{% set client_enabled = client.get('enabled', False) %}
-config:
- label:
- glusterfs:
- input:
+{%- if pillar.get('fluentd', {}).get('agent', {}).get('enabled', False) %}
+{%- from "glusterfs/map.jinja" import server, client with context %}
+{%- set server_enabled = server.get('enabled', False) %}
+{%- set client_enabled = client.get('enabled', False) %}
+{%- set positiondb = pillar.fluentd.agent.dir.positiondb %}
+agent:
+ config:
+ label:
+ glusterfs:
+ input:
{%- if server_enabled %}
- tail_glusterd_log_file:
- type: tail
- path: /var/log/glusterfs/etc-glusterfs-glusterd.vol.log
- tag: glusterfs.glusterd
- pos_file: /var/log/td-agent/tmp/glusterfs.glusterd.pos
- parser:
- type: multiline
- time_key: Timestamp
- time_format: '%Y-%m-%d %H:%M:%S.%N'
- keep_time_key: false
- format_firstline: >-
- '/^\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6}\]/'
- format: >-
- '/^(\[(?<Timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6})\] (?<orig_severity_label>[TDINWECA]) (?<Payload>.*))/'
- tail_glustershd_log_file:
- type: tail
- path: /var/log/glusterfs/glustershd.log
- tag: glusterfs.glustershd
- pos_file: /var/log/td-agent/tmp/glusterfs.glustershd.pos
- parser:
- type: multiline
- time_key: Timestamp
- time_format: '%Y-%m-%d %H:%M:%S.%N'
- keep_time_key: false
- format_firstline: >-
- '/^\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6}\]/'
- format: >-
- '/^(\[(?<Timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6})\] (?<orig_severity_label>[TDINWECA]) (?<Payload>.*))/'
- tail_bricks_log_files:
- type: tail
- path: /var/log/glusterfs/bricks/srv-glusterfs-*
- tag: glusterfs.brick
- pos_file: /var/log/td-agent/tmp/glusterfs.brick.pos
- parser:
- type: multiline
- time_key: Timestamp
- time_format: '%Y-%m-%d %H:%M:%S.%N'
- keep_time_key: false
- format_firstline: >-
- '/^\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6}\]/'
- format: >-
- '/^(\[(?<Timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6})\] (?<orig_severity_label>[TDINWECA]) (?<Payload>.*))/'
+ tail_glusterd_log_file:
+ type: tail
+ path: /var/log/glusterfs/etc-glusterfs-glusterd.vol.log
+ tag: glusterfs.glusterd
+ pos_file: {{ positiondb }}/glusterfs.glusterd.pos
+ parser:
+ type: multiline
+ time_key: Timestamp
+ time_format: '%Y-%m-%d %H:%M:%S.%N'
+ keep_time_key: false
+ format_firstline: >-
+ '/^\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6}\]/'
+ format: >-
+ '/^(\[(?<Timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6})\] (?<orig_severity_label>[TDINWECA]) (?<Payload>.*))/'
+ tail_glustershd_log_file:
+ type: tail
+ path: /var/log/glusterfs/glustershd.log
+ tag: glusterfs.glustershd
+ pos_file: {{ positiondb }}/glusterfs.glustershd.pos
+ parser:
+ type: multiline
+ time_key: Timestamp
+ time_format: '%Y-%m-%d %H:%M:%S.%N'
+ keep_time_key: false
+ format_firstline: >-
+ '/^\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6}\]/'
+ format: >-
+ '/^(\[(?<Timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6})\] (?<orig_severity_label>[TDINWECA]) (?<Payload>.*))/'
+ tail_bricks_log_files:
+ type: tail
+ path: /var/log/glusterfs/bricks/srv-glusterfs-*
+ tag: glusterfs.brick
+ pos_file: {{ positiondb }}/glusterfs.brick.pos
+ parser:
+ type: multiline
+ time_key: Timestamp
+ time_format: '%Y-%m-%d %H:%M:%S.%N'
+ keep_time_key: false
+ format_firstline: >-
+ '/^\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6}\]/'
+ format: >-
+ '/^(\[(?<Timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6})\] (?<orig_severity_label>[TDINWECA]) (?<Payload>.*))/'
{%- endif %}
{%- if client_enabled %}
- tail_client_log_files:
- type: tail
- path: /var/log/glusterfs/var-lib-*
- tag: glusterfs.client
- pos_file: /var/log/td-agent/tmp/glusterfs.client.pos
- parser:
- type: multiline
- time_key: Timestamp
- time_format: '%Y-%m-%d %H:%M:%S.%N'
- keep_time_key: false
- format_firstline: >-
- '/^\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6}\]/'
- format: >-
- '/^(\[(?<Timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6})\] (?<orig_severity_label>[TDINWECA]) (?<Payload>.*))/'
+ tail_client_log_files:
+ type: tail
+ path: /var/log/glusterfs/var-lib-*
+ tag: glusterfs.client
+ pos_file: {{ positiondb }}/glusterfs.client.pos
+ parser:
+ type: multiline
+ time_key: Timestamp
+ time_format: '%Y-%m-%d %H:%M:%S.%N'
+ keep_time_key: false
+ format_firstline: >-
+ '/^\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6}\]/'
+ format: >-
+ '/^(\[(?<Timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{6})\] (?<orig_severity_label>[TDINWECA]) (?<Payload>.*))/'
{%- endif %}
- filter:
- add_programname_unify_severity:
- tag: glusterfs.*
- type: record_transformer
- enable_ruby: true
- remove_keys: orig_severity_label
- record:
- - name: severity_label
- value: ${ {'T'=>'TRACE','D'=>'DEBUG','I'=>'INFO','N'=>'NOTICE','W'=>'WARNING','E'=>'ERROR','C'=>'CRITICAL','A'=>'ALERT'}[record['orig_severity_label']] }
- - name: Severity
- value: ${ {'T'=>7,'D'=>7,'I'=>6,'N'=>5,'W'=>4,'E'=>3,'C'=>2,'A'=>1}[record['orig_severity_label']].to_i }
- - name: programname
- value: glusterd
- match:
- push_to_default:
- tag: glusterfs.*
- type: relabel
- label: default_output
\ No newline at end of file
+ filter:
+ add_programname_unify_severity:
+ tag: glusterfs.*
+ type: record_transformer
+ enable_ruby: true
+ remove_keys: orig_severity_label
+ record:
+ - name: severity_label
+ value: ${ {'T'=>'TRACE','D'=>'DEBUG','I'=>'INFO','N'=>'NOTICE','W'=>'WARNING','E'=>'ERROR','C'=>'CRITICAL','A'=>'ALERT'}[record['orig_severity_label']] }
+ - name: Severity
+ value: ${ {'T'=>7,'D'=>7,'I'=>6,'N'=>5,'W'=>4,'E'=>3,'C'=>2,'A'=>1}[record['orig_severity_label']].to_i }
+ - name: programname
+ value: glusterd
+ match:
+ push_to_default:
+ tag: glusterfs.*
+ type: relabel
+ label: default_output
+{%- endif %}
\ No newline at end of file
diff --git a/tests/pillar/glusterfs_client.sls b/tests/pillar/glusterfs_client.sls
index 356d53e..b35a3ef 100644
--- a/tests/pillar/glusterfs_client.sls
+++ b/tests/pillar/glusterfs_client.sls
@@ -7,4 +7,8 @@
user: glance
group: glance
enabled: true
-
+fluentd:
+ agent:
+ enabled: true
+ dir:
+ positiondb: /var/lib/fluentd/positiondb
\ No newline at end of file
diff --git a/tests/pillar/glusterfs_server.sls b/tests/pillar/glusterfs_server.sls
index 97dacf4..dfd6faf 100644
--- a/tests/pillar/glusterfs_server.sls
+++ b/tests/pillar/glusterfs_server.sls
@@ -13,4 +13,8 @@
- 172.168.1.21:/srv/glusterfs/glance
- 172.168.1.21:/srv/glusterfs/glance
enabled: true
-
+fluentd:
+ agent:
+ enabled: true
+ dir:
+ positiondb: /var/lib/fluentd/positiondb
\ No newline at end of file