From dfd4fa82882c00b5fe180734c5e636d0f556cd7a Mon Sep 17 00:00:00 2001 From: Liberty Young Date: Mon, 31 Aug 2015 13:26:46 -0700 Subject: [PATCH] manage script_sources, too --- pillar.example | 7 +++++++ sumologic/files/sources.json | 28 ++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/pillar.example b/pillar.example index d6baeec..e2b8815 100644 --- a/pillar.example +++ b/pillar.example @@ -14,3 +14,10 @@ sumologic: name: syslog path: "/var/log/syslog" category: linux_apps_logs + script_sources: + - script1: + name: script1 + description: some description + commands: ["/bin/foo", "/bin/bar"] + cronExpression: "* * * * * " + category: scripts diff --git a/sumologic/files/sources.json b/sumologic/files/sources.json index dcb6ec6..7fe7d33 100644 --- a/sumologic/files/sources.json +++ b/sumologic/files/sources.json @@ -1,9 +1,11 @@ {% set sumo_tz = salt['pillar.get']('sumologic:timezone', "America/Los_Angeles") %} -{% set sources = salt['pillar.get']('sumologic:file_sources', {}) %} +{% set f_sources = salt['pillar.get']('sumologic:file_sources', {}) %} +{% set s_sources = salt['pillar.get']('sumologic:script_sources') %} + { "api.version": "v1", "sources": [ - {% for source in sources %} + {% for source in f_sources %} { "sourceType" : "LocalFile", "name": "{{ source["name"]}}", @@ -20,5 +22,27 @@ "blacklist": [] }{% if not loop.last %},{% endif %} {% endfor %} + {% if s_sources %} + , + {% for source in s_sources %} + { + "sourceType" : "Script", + "commands": {{ source.commands}}, + "cronExpression": "{{ source.cronExpression}}", + "workingDir": "/tmp", + "timeout": 60, + "name" : "{{ source.name }}", + "description" : "{{ source.description }}", + "category" : "{{ source.category}}", + "timeZone": "{{ sumo_tz }}", + "automaticDateParsing": true, + "multilineProcessingEnabled": true, + "useAutolineMatching": true, + "manualPrefixRegexp": "", + "forceTimeZone": false, + "defaultDateFormat": "dd/MMM/yyyy HH:mm:ss" + }{% if not loop.last %},{% endif %} + {% endfor %} + {% endif %} ] }