From 45b7f188626cecd38fdac66dd7c63cf93f1a180b Mon Sep 17 00:00:00 2001 From: Liberty Young Date: Thu, 27 Aug 2015 10:44:41 -0700 Subject: [PATCH] Support managing localFile sources with Salt Pillars --- pillar.example | 11 +++++++++++ sumologic/files/sources.json | 26 +++++++++++++++++++++----- sumologic/install.sls | 1 + 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/pillar.example b/pillar.example index cd92b2e..d6baeec 100644 --- a/pillar.example +++ b/pillar.example @@ -3,3 +3,14 @@ sumologic_install: accessid: 'access_id' accesskey: 'accesskey' + +sumologic: + file_sources: + - auth: + name: auth_log + path: "/var/log/auth*" + category: linux_apps_logs + - local_syslog: + name: syslog + path: "/var/log/syslog" + category: linux_apps_logs diff --git a/sumologic/files/sources.json b/sumologic/files/sources.json index f12a853..dcb6ec6 100644 --- a/sumologic/files/sources.json +++ b/sumologic/files/sources.json @@ -1,8 +1,24 @@ +{% set sumo_tz = salt['pillar.get']('sumologic:timezone', "America/Los_Angeles") %} +{% set sources = salt['pillar.get']('sumologic:file_sources', {}) %} { "api.version": "v1", - "installer": { - "name": "None", - "order": 1000, - "description": "Do not install sources" + "sources": [ + {% for source in sources %} + { + "sourceType" : "LocalFile", + "name": "{{ source["name"]}}", + "pathExpression": "{{ source["path"]}}", + "category": "{{source["category"]}}", + "hostName": "{{salt['grains.get']('id')}}", + "useAutolineMatching": false, + "multilineProcessingEnabled": false, + "automaticDateParsing": true, + "timeZone": "{{ sumo_tz }}", + "forceTimeZone": false, + "defaultDateFormat": "dd/MMM/yyyy HH:mm:ss", + "filters": [], + "blacklist": [] + }{% if not loop.last %},{% endif %} + {% endfor %} + ] } -} diff --git a/sumologic/install.sls b/sumologic/install.sls index be42f56..0472bd3 100644 --- a/sumologic/install.sls +++ b/sumologic/install.sls @@ -15,6 +15,7 @@ - user: root - group: root - mode: 400 + - template: jinja - source: salt://sumologic/files/sources.json /etc/sumo.conf: