import fluentd_node role from openshift-ansible

This commit is contained in:
Adam Miller 2015-08-05 16:41:39 +00:00
parent d99fb7dd5c
commit e79a7aab80
4 changed files with 112 additions and 0 deletions

View file

@ -21,6 +21,8 @@ To re-import/update the OpenShift Ansible roles:
etcd
etcd_ca
etcd_certificates
fluentd_master
fluentd_node
openshift_common
openshift_examples
openshift_facts

View file

@ -0,0 +1,55 @@
---
# TODO: Update fluentd install and configuration when packaging is complete
- name: download and install td-agent
yum:
name: 'http://packages.treasuredata.com/2/redhat/7/x86_64/td-agent-2.2.0-0.x86_64.rpm'
state: present
- name: Verify fluentd plugin installed
command: '/opt/td-agent/embedded/bin/gem query -i fluent-plugin-kubernetes'
register: _fluent_plugin_check
failed_when: false
changed_when: false
- name: install Kubernetes fluentd plugin
command: '/opt/td-agent/embedded/bin/gem install fluent-plugin-kubernetes'
when: _fluent_plugin_check.rc == 1
- name: Override td-agent configuration file
template:
src: td-agent.j2
dest: /etc/sysconfig/td-agent
group: 'td-agent'
owner: 'td-agent'
mode: 0444
- name: Creates directories
file:
path: "{{ item }}"
state: directory
group: 'td-agent'
owner: 'td-agent'
mode: 0755
with_items: ['/etc/td-agent/config.d', '/var/log/td-agent/tmp']
- name: Add include to td-agent configuration
lineinfile:
dest: '/etc/td-agent/td-agent.conf'
regexp: '^@include config.d'
line: '@include config.d/*.conf'
state: present
- name: install Kubernetes fluentd configuration file
template:
src: kubernetes.conf.j2
dest: /etc/td-agent/config.d/kubernetes.conf
group: 'td-agent'
owner: 'td-agent'
mode: 0444
- name: ensure td-agent is running
service:
name: 'td-agent'
state: started
enabled: yes

View file

@ -0,0 +1,53 @@
<source>
type tail
path /var/lib/docker/containers/*/*-json.log
pos_file /var/log/td-agent/tmp/fluentd-docker.pos
time_format %Y-%m-%dT%H:%M:%S
tag docker.*
format json
read_from_head true
</source>
<match docker.var.lib.docker.containers.*.*.log>
type kubernetes
container_id ${tag_parts[5]}
tag docker.${name}
</match>
<match kubernetes>
type copy
<store>
type forward
send_timeout 60s
recover_wait 10s
heartbeat_interval 1s
phi_threshold 16
hard_timeout 60s
log_level trace
require_ack_response true
heartbeat_type tcp
<server>
name {{groups['oo_first_master'][0]}}
host {{hostvars[groups['oo_first_master'][0]].openshift.common.hostname}}
port 24224
weight 60
</server>
<secondary>
type file
path /var/log/td-agent/forward-failed
</secondary>
</store>
<store>
type file
path /var/log/td-agent/containers.log
time_slice_format %Y%m%d
time_slice_wait 10m
time_format %Y%m%dT%H%M%S%z
compress gzip
utc
</store>
</match>

View file

@ -0,0 +1,2 @@
DAEMON_ARGS=
TD_AGENT_ARGS="/usr/sbin/td-agent --log /var/log/td-agent/td-agent.log --use-v1-config"