fluentd: Use labels for transition to v5

Depends-On: https://review.opendev.org/c/openstack/kolla/+/901508
Change-Id: I8c7d3de95d0f1f8e57a993b8c3417d90459e19be
This commit is contained in:
Michal Nasiadka 2023-11-20 22:13:29 +00:00
parent db79eb0a55
commit 06baa8f63f
9 changed files with 68 additions and 13 deletions

View File

@ -39,6 +39,57 @@
command: systemd-tmpfiles --create command: systemd-tmpfiles --create
when: kolla_container_engine == 'podman' when: kolla_container_engine == 'podman'
- name: Ensure fluentd image is present for label check
vars:
service_name: "fluentd"
service: "{{ common_services[service_name] }}"
become: true
kolla_container:
action: "ensure_image"
common_options: "{{ docker_common_options }}"
image: "{{ service.image }}"
when: enable_fluentd | bool
- name: Fetch fluentd Docker image labels
vars:
service_name: "fluentd"
service: "{{ common_services[service_name] }}"
become: true
docker_image_info:
name: "{{ service.image }}"
register: fluentd_labels_docker
when:
- kolla_container_engine == "docker"
- enable_fluentd | bool
- name: Set fluentd facts
set_fact:
fluentd_cmd: "{{ fluentd_labels_docker.images[0].ContainerConfig.Labels.fluentd_binary | default('td-agent') }}"
fluentd_user: "{{ fluentd_labels_docker.images[0].ContainerConfig.Labels.fluentd_user | default('td-agent') }}"
when:
- kolla_container_engine == "docker"
- enable_fluentd | bool
- name: Fetch fluentd Podman image labels
vars:
service_name: "fluentd"
service: "{{ common_services[service_name] }}"
become: true
podman_image_info:
name: "{{ service.image }}"
register: fluentd_labels_podman
when:
- kolla_container_engine == "podman"
- enable_fluentd | bool
- name: Set fluentd facts
set_fact:
fluentd_cmd: "{{ fluentd_labels_podman.images[0].ContainerConfig.Labels.fluentd_binary | default('td-agent') }}"
fluentd_user: "{{ fluentd_labels_podman.images[0].ContainerConfig.Labels.fluentd_user | default('td-agent') }}"
when:
- kolla_container_engine == "podman"
- 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"

View File

@ -9,7 +9,7 @@
"/var/log/kolla/*/*-error.log", "/var/log/kolla/*/*-error.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/td-agent/kolla-openstack.pos pos_file /var/run/{{ fluentd_user }}/kolla-openstack.pos
tag kolla.* tag kolla.*
ignore_repeated_permission_error true ignore_repeated_permission_error true
enable_watch_timer false enable_watch_timer false

View File

@ -3,7 +3,7 @@
<source> <source>
@type tail @type tail
path /var/log/kolla/mariadb/mariadb.log path /var/log/kolla/mariadb/mariadb.log
pos_file /var/run/td-agent/mariadb.pos pos_file /var/run/{{ fluentd_user }}/mariadb.pos
tag infra.mariadb tag infra.mariadb
enable_watch_timer false enable_watch_timer false
<parse> <parse>
@ -15,7 +15,7 @@
<source> <source>
@type tail @type tail
path /var/log/kolla/mariadb/xinetd.log path /var/log/kolla/mariadb/xinetd.log
pos_file /var/run/td-agent/mariadb-xinetd.pos pos_file /var/run/{{ fluentd_user }}/mariadb-xinetd.pos
tag infra.mariadb-xinetd tag infra.mariadb-xinetd
ignore_repeated_permission_error true ignore_repeated_permission_error true
enable_watch_timer false enable_watch_timer false

View File

@ -1,7 +1,7 @@
<source> <source>
@type tail @type tail
path /var/log/kolla/rabbitmq/rabbit@{{ ansible_facts.hostname }}.log path /var/log/kolla/rabbitmq/rabbit@{{ ansible_facts.hostname }}.log
pos_file /var/run/td-agent/rabbit.pos pos_file /var/run/{{ fluentd_user }}/rabbit.pos
tag infra.rabbit tag infra.rabbit
enable_watch_timer false enable_watch_timer false
<parse> <parse>

View File

@ -2,7 +2,7 @@
<source> <source>
@type tail @type tail
path /var/log/kolla/*/*-access.log,/var/log/kolla/*/*-error.log,/var/log/kolla/*/*_access.log,/var/log/kolla/*/*_error.log path /var/log/kolla/*/*-access.log,/var/log/kolla/*/*-error.log,/var/log/kolla/*/*_access.log,/var/log/kolla/*/*_error.log
pos_file /var/run/td-agent/kolla-openstack-wsgi.pos pos_file /var/run/{{ fluentd_user }}/kolla-openstack-wsgi.pos
tag kolla.* tag kolla.*
enable_watch_timer false enable_watch_timer false
<parse> <parse>

View File

@ -1,7 +1,7 @@
<source> <source>
@type tail @type tail
path /var/log/kolla/libvirt/libvirtd.log path /var/log/kolla/libvirt/libvirtd.log
pos_file /var/run/td-agent/libvirt.pos pos_file /var/run/{{ fluentd_user }}/libvirt.pos
tag infra.libvirt tag infra.libvirt
enable_watch_timer false enable_watch_timer false
<parse> <parse>

View File

@ -1,7 +1,7 @@
<source> <source>
@type tail @type tail
path /var/log/kolla/openvswitch/ovs-vswitchd.log path /var/log/kolla/openvswitch/ovs-vswitchd.log
pos_file /var/run/td-agent/openvswitch.pos pos_file /var/run/{{ fluentd_user }}/openvswitch.pos
tag infra.openvswitch tag infra.openvswitch
enable_watch_timer false enable_watch_timer false
<parse> <parse>
@ -16,7 +16,7 @@
<source> <source>
@type tail @type tail
path /var/log/kolla/openvswitch/ovsdb-server.log path /var/log/kolla/openvswitch/ovsdb-server.log
pos_file /var/run/td-agent/openvswitchdb.pos pos_file /var/run/{{ fluentd_user }}/openvswitchdb.pos
tag infra.openvswitchdb tag infra.openvswitchdb
enable_watch_timer false enable_watch_timer false
<parse> <parse>

View File

@ -1,10 +1,8 @@
{% set fluentd_user = 'td-agent' %} {% set fluentd_dir = '/etc/' + (fluentd_cmd | default('td-agent')) %}
{% set fluentd_dir = '/etc/td-agent' %} {% set fluentd_conf = (fluentd_cmd | default('td-agent')) + '.conf' %}
{% set fluentd_conf = 'td-agent.conf' %}
{% set fluentd_cmd = '/usr/sbin/td-agent' %}
{ {
"command": "{{ fluentd_cmd }} -o /var/log/kolla/fluentd/fluentd.log", "command": "{{ fluentd_cmd }} -c {{ fluentd_dir }}/{{ fluentd_conf }} -o /var/log/kolla/fluentd/fluentd.log",
"config_files": [ "config_files": [
{ {
"source": "{{ container_config_directory }}/td-agent.conf", "source": "{{ container_config_directory }}/td-agent.conf",

View File

@ -12,3 +12,9 @@ collections:
- name: community.general - name: community.general
source: https://galaxy.ansible.com source: https://galaxy.ansible.com
version: <7 version: <7
- name: community.docker
source: https://galaxy.ansible.com
version: <4
- name: containers.podman
source: https://galaxy.ansible.com
version: <2