{% set fluentd_user = fluentd_binary %}
{% set fluentd_dir = '/etc/' ~ fluentd_binary %}

{% if fluentd_binary == 'fluentd' %}
    {% set fluentd_conf = 'fluent.conf' %}
    {% if kolla_base_distro in ['ubuntu', 'debian'] %}
        {% set fluentd_cmd = '/usr/local/bin/fluentd -c ' ~ fluentd_dir ~ '/' ~ fluentd_conf %}
    {% else %}
        {% set fluentd_cmd = '/usr/bin/fluentd -c ' ~ fluentd_dir ~ '/' ~ fluentd_conf %}
    {% endif %}
{% elif fluentd_binary == 'td-agent' %}
    {% set fluentd_conf = fluentd_binary ~ '.conf' %}
    {% set fluentd_cmd = '/usr/sbin/td-agent' %}
{% endif %}

{
    "command": "{{ fluentd_cmd }} -o /var/log/kolla/fluentd/fluentd.log",
    "config_files": [
        {
            "source": "{{ container_config_directory }}/td-agent.conf",
            "dest": "{{ fluentd_dir }}/{{ fluentd_conf }}",
            "owner": "{{ fluentd_user }}",
            "perm": "0600"
        }
    ],
    "permissions": [
        {
            "path": "/var/log/kolla/fluentd",
            "owner": "{{ fluentd_user }}:{{ fluentd_user }}",
            "recurse": true
        },
        {
            "path": "/var/log/kolla/haproxy",
            "owner": "{{ fluentd_user }}:{{ fluentd_user }}",
            "recurse": true
        },
        {
            "path": "/var/log/kolla/swift",
            "owner": "{{ fluentd_user }}:{{ fluentd_user }}",
            "recurse": true
        },
        {
            "path": "/var/lib/fluentd/data",
            "owner": "{{ fluentd_user }}:{{ fluentd_user }}",
            "recurse": true
        }
    ]

}
