Use fluentd image labels
In order to orchestrate smooth transition to fluentd 0.14.x aka 1.0 stable branch aka td-agent 3 from td-agent repository - use image labels (fluentd_version and fluentd_binary). Depends-On: https://review.opendev.org/676411 Change-Id: Iab8518c34ef876056c6abcdb5f2e9fc9f1f7dbdd
This commit is contained in:
parent
b93e33e78e
commit
4180bee020
@ -51,6 +51,7 @@ options:
|
|||||||
- compare_container
|
- compare_container
|
||||||
- compare_image
|
- compare_image
|
||||||
- create_volume
|
- create_volume
|
||||||
|
- ensure_image
|
||||||
- get_container_env
|
- get_container_env
|
||||||
- get_container_state
|
- get_container_state
|
||||||
- pull_image
|
- pull_image
|
||||||
@ -886,6 +887,10 @@ class DockerWorker(object):
|
|||||||
)
|
)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
def ensure_image(self):
|
||||||
|
if not self.check_image():
|
||||||
|
self.pull_image()
|
||||||
|
|
||||||
|
|
||||||
def generate_module():
|
def generate_module():
|
||||||
# NOTE(jeffrey4l): add empty string '' to choices let us use
|
# NOTE(jeffrey4l): add empty string '' to choices let us use
|
||||||
@ -893,13 +898,20 @@ def generate_module():
|
|||||||
argument_spec = dict(
|
argument_spec = dict(
|
||||||
common_options=dict(required=False, type='dict', default=dict()),
|
common_options=dict(required=False, type='dict', default=dict()),
|
||||||
action=dict(required=True, type='str',
|
action=dict(required=True, type='str',
|
||||||
choices=['compare_container', 'compare_image',
|
choices=['compare_container',
|
||||||
'create_volume', 'get_container_env',
|
'compare_image',
|
||||||
'get_container_state', 'pull_image',
|
'create_volume',
|
||||||
|
'ensure_image',
|
||||||
|
'get_container_env',
|
||||||
|
'get_container_state',
|
||||||
|
'pull_image',
|
||||||
'recreate_or_restart_container',
|
'recreate_or_restart_container',
|
||||||
'remove_container', 'remove_image',
|
'remove_container',
|
||||||
'remove_volume', 'restart_container',
|
'remove_image',
|
||||||
'start_container', 'stop_container',
|
'remove_volume',
|
||||||
|
'restart_container',
|
||||||
|
'start_container',
|
||||||
|
'stop_container',
|
||||||
'stop_and_remove_container']),
|
'stop_and_remove_container']),
|
||||||
api_version=dict(required=False, type='str', default='auto'),
|
api_version=dict(required=False, type='str', default='auto'),
|
||||||
auth_email=dict(required=False, type='str'),
|
auth_email=dict(required=False, type='str'),
|
||||||
@ -947,6 +959,7 @@ def generate_module():
|
|||||||
['action', 'compare_container', ['name']],
|
['action', 'compare_container', ['name']],
|
||||||
['action', 'compare_image', ['name']],
|
['action', 'compare_image', ['name']],
|
||||||
['action', 'create_volume', ['name']],
|
['action', 'create_volume', ['name']],
|
||||||
|
['action', 'ensure_image', ['image']],
|
||||||
['action', 'get_container_env', ['name']],
|
['action', 'get_container_env', ['name']],
|
||||||
['action', 'get_container_state', ['name']],
|
['action', 'get_container_state', ['name']],
|
||||||
['action', 'recreate_or_restart_container', ['name']],
|
['action', 'recreate_or_restart_container', ['name']],
|
||||||
|
@ -26,6 +26,32 @@
|
|||||||
- "fluentd/filter"
|
- "fluentd/filter"
|
||||||
when: enable_fluentd | bool
|
when: enable_fluentd | bool
|
||||||
|
|
||||||
|
- name: Ensure fluentd image is present for label check
|
||||||
|
vars:
|
||||||
|
service_name: "fluentd"
|
||||||
|
service: "{{ common_services[service_name] }}"
|
||||||
|
become: true
|
||||||
|
kolla_docker:
|
||||||
|
action: "ensure_image"
|
||||||
|
common_options: "{{ docker_common_options }}"
|
||||||
|
image: "{{ service.image }}"
|
||||||
|
when: enable_fluentd | bool
|
||||||
|
|
||||||
|
- name: Fetch fluentd image labels
|
||||||
|
vars:
|
||||||
|
service_name: "fluentd"
|
||||||
|
service: "{{ common_services[service_name] }}"
|
||||||
|
become: true
|
||||||
|
docker_image_facts:
|
||||||
|
name: "{{ service.image }}"
|
||||||
|
register: fluentd_labels
|
||||||
|
when: enable_fluentd | bool
|
||||||
|
|
||||||
|
- name: Set fluentd facts
|
||||||
|
set_fact:
|
||||||
|
fluentd_binary: "{% if fluentd_labels.images.0.ContainerConfig.Labels.fluentd_binary is not defined %}{% if kolla_base_distro in 'ubuntu' and ansible_architecture == 'x86_64' %}td-agent{% else %}fluentd{% endif %}{% else %}{{ fluentd_labels.images.0.ContainerConfig.Labels.fluentd_binary }}{% endif %}"
|
||||||
|
when: enable_fluentd | bool
|
||||||
|
|
||||||
- name: Copying over config.json files for services
|
- name: Copying over config.json files for services
|
||||||
template:
|
template:
|
||||||
src: "{{ item.key }}.json.j2"
|
src: "{{ item.key }}.json.j2"
|
||||||
@ -199,6 +225,7 @@
|
|||||||
- name: Copying over fluentd filter config files
|
- name: Copying over fluentd filter config files
|
||||||
vars:
|
vars:
|
||||||
customised_filter_files: "{{ find_custom_fluentd_filters.files | map(attribute='path') | map('basename') | list }}"
|
customised_filter_files: "{{ find_custom_fluentd_filters.files | map(attribute='path') | map('basename') | list }}"
|
||||||
|
fluentd_version: "{{ fluentd_labels.images.0.ContainerConfig.Labels.fluentd_version | default('0.12') }}"
|
||||||
template:
|
template:
|
||||||
src: "conf/filter/{{ item.src }}.conf.j2"
|
src: "conf/filter/{{ item.src }}.conf.j2"
|
||||||
dest: "{{ node_config_directory }}/fluentd/filter/{{ item.dest }}.conf"
|
dest: "{{ node_config_directory }}/fluentd/filter/{{ item.dest }}.conf"
|
||||||
@ -207,7 +234,7 @@
|
|||||||
with_items:
|
with_items:
|
||||||
- src: 00-record_transformer
|
- src: 00-record_transformer
|
||||||
dest: 00-record_transformer
|
dest: 00-record_transformer
|
||||||
- src: "{{ '01-rewrite-0.14' if kolla_base_distro in ['debian', 'ubuntu'] else '01-rewrite-0.12' }}"
|
- src: "{{ '01-rewrite-0.14' if fluentd_version == '0.14' else '01-rewrite-0.12' }}"
|
||||||
dest: 01-rewrite
|
dest: 01-rewrite
|
||||||
when:
|
when:
|
||||||
- enable_fluentd | bool
|
- enable_fluentd | bool
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#jinja2: trim_blocks: False
|
#jinja2: trim_blocks: False
|
||||||
{% set fluentd_dir = 'td-agent' if (kolla_base_distro in ['ubuntu', 'debian'] and ansible_architecture == 'x86_64') else 'fluentd' %}
|
|
||||||
{% set services = [
|
{% set services = [
|
||||||
( 'aodh', enable_aodh ),
|
( 'aodh', enable_aodh ),
|
||||||
( 'barbican', enable_barbican ),
|
( 'barbican', enable_barbican ),
|
||||||
@ -51,7 +50,7 @@
|
|||||||
"/var/log/kolla/neutron/dnsmasq.log",
|
"/var/log/kolla/neutron/dnsmasq.log",
|
||||||
"/var/log/kolla/*/*-access.log",
|
"/var/log/kolla/*/*-access.log",
|
||||||
"/var/log/kolla/*/*-error.log"]
|
"/var/log/kolla/*/*-error.log"]
|
||||||
pos_file /var/run/{{ fluentd_dir }}/kolla-openstack.pos
|
pos_file /var/run/{{ fluentd_binary }}/kolla-openstack.pos
|
||||||
tag kolla.*
|
tag kolla.*
|
||||||
format multiline
|
format multiline
|
||||||
format_firstline /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{3} \d+ \S+ \S+ \[(req-\S+ \S+ \S+ \S+ \S+ \S+|-)\]/
|
format_firstline /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{3} \d+ \S+ \S+ \[(req-\S+ \S+ \S+ \S+ \S+ \S+|-)\]/
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
{% set fluentd_dir = 'td-agent' if (kolla_base_distro in ['ubuntu', 'debian'] and ansible_architecture == 'x86_64') else 'fluentd' %}
|
|
||||||
<source>
|
<source>
|
||||||
@type tail
|
@type tail
|
||||||
path /var/log/kolla/mariadb/mariadb.log
|
path /var/log/kolla/mariadb/mariadb.log
|
||||||
pos_file /var/run/{{ fluentd_dir }}/mariadb.pos
|
pos_file /var/run/{{ fluentd_binary }}/mariadb.pos
|
||||||
tag infra.mariadb
|
tag infra.mariadb
|
||||||
format multiline
|
format multiline
|
||||||
format_firstline /^\d{6}/
|
format_firstline /^\d{6}/
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
{% set fluentd_dir = 'td-agent' if (kolla_base_distro in ['ubuntu', 'debian'] and ansible_architecture == 'x86_64') else 'fluentd' %}
|
|
||||||
<source>
|
<source>
|
||||||
@type tail
|
@type tail
|
||||||
path /var/log/kolla/rabbitmq/rabbit.log
|
path /var/log/kolla/rabbitmq/rabbit.log
|
||||||
pos_file /var/run/{{ fluentd_dir }}/rabbit.pos
|
pos_file /var/run/{{ fluentd_binary }}/rabbit.pos
|
||||||
tag infra.rabbit
|
tag infra.rabbit
|
||||||
format multiline
|
format multiline
|
||||||
format_firstline /^\s*$/
|
format_firstline /^\s*$/
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
# Note (blallau): to manage Apache and WSGI log files
|
# Note (blallau): to manage Apache and WSGI log files
|
||||||
{% set fluentd_dir = 'td-agent' if (kolla_base_distro in ['ubuntu', 'debian'] and ansible_architecture == 'x86_64') else 'fluentd' %}
|
|
||||||
<source>
|
<source>
|
||||||
@type tail
|
@type tail
|
||||||
path /var/log/kolla/*/*-access.log,/var/log/kolla/*/*-error.log
|
path /var/log/kolla/*/*-access.log,/var/log/kolla/*/*-error.log
|
||||||
pos_file /var/run/{{ fluentd_dir }}/kolla-openstack-wsgi.pos
|
pos_file /var/run/{{ fluentd_binary }}/kolla-openstack-wsgi.pos
|
||||||
tag kolla.*
|
tag kolla.*
|
||||||
format /^(?<Payload>.*)$/
|
format /^(?<Payload>.*)$/
|
||||||
enable_watch_timer false
|
enable_watch_timer false
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
{% set fluentd_dir = 'td-agent' if (kolla_base_distro in ['ubuntu', 'debian'] and ansible_architecture == 'x86_64') else 'fluentd' %}
|
|
||||||
<source>
|
<source>
|
||||||
@type tail
|
@type tail
|
||||||
path /var/log/kolla/libvirt/libvirtd.log
|
path /var/log/kolla/libvirt/libvirtd.log
|
||||||
pos_file /var/run/{{ fluentd_dir }}/libvirt.pos
|
pos_file /var/run/{{ fluentd_binary }}/libvirt.pos
|
||||||
tag infra.libvirt
|
tag infra.libvirt
|
||||||
format /^(?<Timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{3}\+\d{4}): (?<Pid>\d+): (?<log_level>\S+) : (?<Payload>.*)?$/
|
format /^(?<Timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{3}\+\d{4}): (?<Pid>\d+): (?<log_level>\S+) : (?<Payload>.*)?$/
|
||||||
time_key Timestamp
|
time_key Timestamp
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
{% set fluentd_dir = 'td-agent' if (kolla_base_distro in ['ubuntu', 'debian'] and ansible_architecture == 'x86_64') else 'fluentd' %}
|
|
||||||
<source>
|
<source>
|
||||||
@type tail
|
@type tail
|
||||||
path /var/log/kolla/zookeeper/zookeeper.log
|
path /var/log/kolla/zookeeper/zookeeper.log
|
||||||
pos_file /var/run/{{ fluentd_dir }}/zookeeper.pos
|
pos_file /var/run/{{ fluentd_binary }}/zookeeper.pos
|
||||||
tag infra.*
|
tag infra.*
|
||||||
format multiline
|
format multiline
|
||||||
format_firstline /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3} \S+ \S+ \S+ .*$/
|
format_firstline /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3} \S+ \S+ \S+ .*$/
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
{% set fluentd_dir = 'td-agent' if (kolla_base_distro in ['ubuntu', 'debian'] and ansible_architecture == 'x86_64') else 'fluentd' %}
|
|
||||||
<source>
|
<source>
|
||||||
@type tail
|
@type tail
|
||||||
path /var/log/kolla/kafka/controller.log, /var/log/kolla/kafka/server.log, /var/log/kolla/kafka/state-change.log
|
path /var/log/kolla/kafka/controller.log, /var/log/kolla/kafka/server.log, /var/log/kolla/kafka/state-change.log
|
||||||
pos_file /var/run/{{ fluentd_dir }}/kafka.pos
|
pos_file /var/run/{{ fluentd_binary }}/kafka.pos
|
||||||
tag infra.*
|
tag infra.*
|
||||||
format multiline
|
format multiline
|
||||||
format_firstline /^\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3}\] \S+ .*$/
|
format_firstline /^\[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3}\] \S+ .*$/
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
{% set fluentd_dir = 'td-agent' if (kolla_base_distro in ['ubuntu', 'debian'] and ansible_architecture == 'x86_64') else 'fluentd' %}
|
|
||||||
<source>
|
<source>
|
||||||
@type tail
|
@type tail
|
||||||
path /var/log/kolla/opendaylight/karaf.log
|
path /var/log/kolla/opendaylight/karaf.log
|
||||||
pos_file /var/run/{{ fluentd_dir }}/opendaylight.pos
|
pos_file /var/run/{{ fluentd_binary }}/opendaylight.pos
|
||||||
tag infra.opendaylight
|
tag infra.opendaylight
|
||||||
format multiline
|
format multiline
|
||||||
format_firstline /\d{4}-\d{2}-\d{2}/
|
format_firstline /\d{4}-\d{2}-\d{2}/
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
{% set fluentd_dir = 'td-agent' if (kolla_base_distro in ['ubuntu', 'debian'] and ansible_architecture == 'x86_64') else 'fluentd' %}
|
|
||||||
<source>
|
<source>
|
||||||
@type tail
|
@type tail
|
||||||
path /var/log/kolla/monasca/agent*.log
|
path /var/log/kolla/monasca/agent*.log
|
||||||
pos_file /var/run/{{ fluentd_dir }}/monasca-agent.pos
|
pos_file /var/run/{{ fluentd_binary }}/monasca-agent.pos
|
||||||
tag kolla.*
|
tag kolla.*
|
||||||
format multiline
|
format multiline
|
||||||
format_firstline /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} \S+ \| \S+ \| \S+ \| .*$/
|
format_firstline /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} \S+ \| \S+ \| \S+ \| .*$/
|
||||||
@ -13,7 +12,7 @@
|
|||||||
<source>
|
<source>
|
||||||
@type tail
|
@type tail
|
||||||
path /var/log/kolla/monasca/grafana.log
|
path /var/log/kolla/monasca/grafana.log
|
||||||
pos_file /var/run/{{ fluentd_dir }}/monasca-grafana.pos
|
pos_file /var/run/{{ fluentd_binary }}/monasca-grafana.pos
|
||||||
tag infra.*
|
tag infra.*
|
||||||
format multiline
|
format multiline
|
||||||
format_firstline /^t=\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{4} lvl=\S+ msg=.*$/
|
format_firstline /^t=\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{4} lvl=\S+ msg=.*$/
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
{% if kolla_base_distro in ['ubuntu', 'debian'] and ansible_architecture == 'x86_64' %}
|
{% set fluentd_user = fluentd_binary %}
|
||||||
{% set fluentd_cmd = '/usr/sbin/td-agent' %}
|
{% set fluentd_dir = '/etc/' ~ fluentd_binary %}
|
||||||
{% set fluentd_dir = '/etc/td-agent' %}
|
|
||||||
{% set fluentd_conf = 'td-agent.conf' %}
|
{% if fluentd_binary == 'fluentd' %}
|
||||||
{% set fluentd_user = 'td-agent' %}
|
|
||||||
{% else %}
|
|
||||||
{% if kolla_base_distro in ['ubuntu', 'debian'] %}
|
|
||||||
{% set fluentd_cmd = '/usr/local/bin/fluentd -c /etc/fluentd/fluent.conf' %}
|
|
||||||
{% else %}
|
|
||||||
{% set fluentd_cmd = '/usr/bin/fluentd -c /etc/fluentd/fluent.conf' %}
|
|
||||||
{% endif %}
|
|
||||||
{% set fluentd_dir = '/etc/fluentd' %}
|
|
||||||
{% set fluentd_conf = 'fluent.conf' %}
|
{% set fluentd_conf = 'fluent.conf' %}
|
||||||
{% set fluentd_user = 'fluentd' %}
|
{% 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 %}
|
{% endif %}
|
||||||
|
|
||||||
{
|
{
|
||||||
"command": "{{ fluentd_cmd }}",
|
"command": "{{ fluentd_cmd }}",
|
||||||
"config_files": [
|
"config_files": [
|
||||||
|
@ -44,12 +44,21 @@ class ModuleArgsTest(base.BaseTestCase):
|
|||||||
common_options=dict(required=False, type='dict', default=dict()),
|
common_options=dict(required=False, type='dict', default=dict()),
|
||||||
action=dict(
|
action=dict(
|
||||||
required=True, type='str',
|
required=True, type='str',
|
||||||
choices=['compare_container', 'compare_image', 'create_volume',
|
choices=['compare_container',
|
||||||
'get_container_env', 'get_container_state',
|
'compare_image',
|
||||||
'pull_image', 'recreate_or_restart_container',
|
'create_volume',
|
||||||
'remove_container', 'remove_image', 'remove_volume',
|
'ensure_image',
|
||||||
'restart_container', 'start_container',
|
'get_container_env',
|
||||||
'stop_container', 'stop_and_remove_container']),
|
'get_container_state',
|
||||||
|
'pull_image',
|
||||||
|
'recreate_or_restart_container',
|
||||||
|
'remove_container',
|
||||||
|
'remove_image',
|
||||||
|
'remove_volume',
|
||||||
|
'restart_container',
|
||||||
|
'start_container',
|
||||||
|
'stop_container',
|
||||||
|
'stop_and_remove_container']),
|
||||||
api_version=dict(required=False, type='str', default='auto'),
|
api_version=dict(required=False, type='str', default='auto'),
|
||||||
auth_email=dict(required=False, type='str'),
|
auth_email=dict(required=False, type='str'),
|
||||||
auth_password=dict(required=False, type='str', no_log=True),
|
auth_password=dict(required=False, type='str', no_log=True),
|
||||||
@ -96,6 +105,7 @@ class ModuleArgsTest(base.BaseTestCase):
|
|||||||
['action', 'compare_container', ['name']],
|
['action', 'compare_container', ['name']],
|
||||||
['action', 'compare_image', ['name']],
|
['action', 'compare_image', ['name']],
|
||||||
['action', 'create_volume', ['name']],
|
['action', 'create_volume', ['name']],
|
||||||
|
['action', 'ensure_image', ['image']],
|
||||||
['action', 'get_container_env', ['name']],
|
['action', 'get_container_env', ['name']],
|
||||||
['action', 'get_container_state', ['name']],
|
['action', 'get_container_state', ['name']],
|
||||||
['action', 'recreate_or_restart_container', ['name']],
|
['action', 'recreate_or_restart_container', ['name']],
|
||||||
|
Loading…
Reference in New Issue
Block a user