state with example conf
diff --git a/README.md b/README.md
old mode 100644
new mode 100755
diff --git a/conf/td-agent.conf b/conf/td-agent.conf
new file mode 100755
index 0000000..11ab2c7
--- /dev/null
+++ b/conf/td-agent.conf
@@ -0,0 +1,44 @@
+<source>
+ type syslog
+ port 42185
+ tag syslog
+</source>
+
+<source>
+ type forward
+</source>
+
+<source>
+ type tail
+ format apache2
+ path /var/log/httpd/access_log
+ pos_file /var/log/td-agent/apache2.access_log.pos
+ tag mongo.apache.access
+</source>
+ <source>
+ type forward
+ </source>
+<match mongo.*.*>
+ # plugin type
+ type mongo
+
+ # mongodb db + collection
+ database apache
+ collection access
+
+ # mongodb host + port
+ host localhost
+ port 27017
+
+ # interval
+ flush_interval 10s
+</match>
+
+<match mongo.*.*>
+ host 10.10.10.180
+ port 9200
+
+ type elasticsearch
+ logstash_format true
+ flush_interval 10s # for testing
+</match>
\ No newline at end of file
diff --git a/conf/treasure-data.gpg b/conf/treasure-data.gpg
new file mode 100755
index 0000000..2ce022d
--- /dev/null
+++ b/conf/treasure-data.gpg
@@ -0,0 +1,18 @@
+-----BEGIN PGP PUBLIC KEY BLOCK-----
+Version: GnuPG v1.4.5 (GNU/Linux)
+
+mQGiBFKuy6MRBACJccrkWHfYSKSbchD4ywYLGkIKITSLzEXrlpy4Sp6Mr9G1OGIv
+buIUIxksnev6h6wlFgbFYTLngpod+Jn4DpcGgXqzZ3lhOY1fvAaQ4SJ4RUELm1JJ
+SEWE0uYHuoI4+TrLtod3U02ETD+Lf6LWO3IfU1AYsA467tDYpVXR0GHeAwCgqU/V
+M+ypNOYFHVs1/aX83wdg0K8D+wf+tcvTHb/i2lND5DVfTWtC54WYNIG6QO8DgGdu
+EYregcMKRRNM4nSfUISzCgrjnpLGjvB9NKONCrimDiuz4TH7KDcEsKGA+zTzJLCy
+mcE6tKEHV5yS7cK0inim4nxAKFB70306CkhHyL2TrB42ppNFJwG1igO4BJ+55b9X
+Dd03A/9o6ONFle6khG+UE82WYTayy2pAshKTSLnOlB7CIxwt3SrzFXTuNosajVgZ
+S0EIB8c6SjFN6P1jHjd7PYOmBxd2xptERTg8CJMoTUI+P7LypWuvmagIdEwe571d
+ZMQ26HNuHg7/IMg+FQxhl/DFU6Aq+2CBJ3q8gO8Us4/UYc1PhrRUVHJlYXN1cmUg
+RGF0YSwgSW5jIChUcmVhc3VyZSBBZ2VudCBPZmZpY2lhbCBTaWduaW5nIGtleSkg
+PHN1cHBvcnRAdHJlYXN1cmUtZGF0YS5jb20+iGAEExECACAFAlKuy6MCGwMGCwkI
+BwMCBBUCCAMEFgIDAQIeAQIXgAAKCRAQk9tFoS4gb3HgAKCBCDNT/cWzkKRQxvnL
+LiGvPetVSACeLLKnt2twfiPc9ZEA/X8MKkPjWqc=
+=e5Fe
+-----END PGP PUBLIC KEY BLOCK-----
\ No newline at end of file
diff --git a/init.sls b/init.sls
new file mode 100755
index 0000000..a6ebabe
--- /dev/null
+++ b/init.sls
@@ -0,0 +1,4 @@
+include:
+{%- if pillar.fluentd.get("server", {'enabled':False}).enabled %}
+- fluentd.server
+{%- endif %}
\ No newline at end of file
diff --git a/map.jinja b/map.jinja
new file mode 100755
index 0000000..703c55c
--- /dev/null
+++ b/map.jinja
@@ -0,0 +1,13 @@
+
+{% set server = salt['grains.filter_by']({
+ 'Debian': {
+ 'pkgs': ['td-agent'],
+ 'service': 'td-agent',
+ 'config': '/etc/td-agent/td-agent.conf',
+ },
+ 'RedHat': {
+ 'pkgs': ['td-agent'],
+ 'service': 'td-agent',
+ 'config': '/etc/td-agent/td-agent.conf',
+ },
+}, merge=salt['pillar.get']('fluentd:server')) %}
\ No newline at end of file
diff --git a/server.sls b/server.sls
new file mode 100755
index 0000000..7f07b7d
--- /dev/null
+++ b/server.sls
@@ -0,0 +1,59 @@
+{% from "fluentd/map.jinja" import server with context %}
+
+fluentd_packages:
+ pkg.installed:
+ - names:
+ - curl
+ - libcurl-devel
+
+fluentd_install:
+ cmd.run:
+ - names:
+ - curl -L http://toolbelt.treasuredata.com/sh/install-redhat.sh | sh
+ - touch /root/fluentd_installed
+ - cwd: /root
+ - unless: "[ -f /root/fluentd_installed ]"
+ require:
+ - pkg: fluentd_packages
+
+{%- for plugin in server.get("plugins", []) %}
+fluentd_install_plugin:
+ cmd.run:
+ - names:
+ - /usr/lib64/fluent/ruby/bin/fluent-gem install plugin {{ plugin }}
+ - touch /root/{{ plugin }}_installed
+ - cwd: /root
+ - unless: "[ -f /root/{{ plugin }}_installed ]"
+ require:
+ - pkg: fluentd_packages
+{% endfor %}
+
+{{ server.config }}:
+ file.managed:
+ - source: salt://fluentd/conf/td-agent.conf
+ - template: jinja
+ - require:
+ - cmd: fluentd_install
+
+fluentd_service:
+ service.running:
+ - name: {{ server.service }}
+ - enable: True
+ - watch:
+ - file: {{ server.config }}
+
+{#
+fluentd_repo:
+ pkgrepo.managed:
+ - human_name: TreasureData
+ - comments:
+ - '#http://packages.treasure-data.com/debian/RPM-GPG-KEY-td-agent'
+ - name: TreasureData
+ - baseurl: http://packages.treasure-data.com/redhat/\$basearch
+ - file: /etc/apt/sources.list.d/fluentd.list
+ - key_url: salt://fluentd/conf/treasure-data.gpg
+ - gpgcheck: 1
+
+
+ - deb http://packages.treasure-data.com/{{ grains.oscodename }}/ {{ grains.oscodename }} contrib
+#}
\ No newline at end of file