diff --git a/ansible/roles/common/tasks/config.yml b/ansible/roles/common/tasks/config.yml index a2c03ad0cb..f53464f84b 100644 --- a/ansible/roles/common/tasks/config.yml +++ b/ansible/roles/common/tasks/config.yml @@ -39,6 +39,57 @@ command: systemd-tmpfiles --create 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 template: src: "{{ item.key }}.json.j2" diff --git a/ansible/roles/common/templates/conf/input/00-global.conf.j2 b/ansible/roles/common/templates/conf/input/00-global.conf.j2 index d3bdb2dec7..1c0a3d25b1 100644 --- a/ansible/roles/common/templates/conf/input/00-global.conf.j2 +++ b/ansible/roles/common/templates/conf/input/00-global.conf.j2 @@ -9,7 +9,7 @@ "/var/log/kolla/*/*-error.log", "/var/log/kolla/*/*_access.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.* ignore_repeated_permission_error true enable_watch_timer false diff --git a/ansible/roles/common/templates/conf/input/02-mariadb.conf.j2 b/ansible/roles/common/templates/conf/input/02-mariadb.conf.j2 index f4ed045f81..cafbe03015 100644 --- a/ansible/roles/common/templates/conf/input/02-mariadb.conf.j2 +++ b/ansible/roles/common/templates/conf/input/02-mariadb.conf.j2 @@ -3,7 +3,7 @@ @type tail 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 enable_watch_timer false @@ -15,7 +15,7 @@ @type tail 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 ignore_repeated_permission_error true enable_watch_timer false diff --git a/ansible/roles/common/templates/conf/input/03-rabbitmq.conf.j2 b/ansible/roles/common/templates/conf/input/03-rabbitmq.conf.j2 index 9fb1b3dc3e..e7b3099c77 100644 --- a/ansible/roles/common/templates/conf/input/03-rabbitmq.conf.j2 +++ b/ansible/roles/common/templates/conf/input/03-rabbitmq.conf.j2 @@ -1,7 +1,7 @@ @type tail 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 enable_watch_timer false diff --git a/ansible/roles/common/templates/conf/input/04-openstack-wsgi.conf.j2 b/ansible/roles/common/templates/conf/input/04-openstack-wsgi.conf.j2 index f94edf8a6a..cf41b25275 100644 --- a/ansible/roles/common/templates/conf/input/04-openstack-wsgi.conf.j2 +++ b/ansible/roles/common/templates/conf/input/04-openstack-wsgi.conf.j2 @@ -2,7 +2,7 @@ @type tail 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.* enable_watch_timer false diff --git a/ansible/roles/common/templates/conf/input/05-libvirt.conf.j2 b/ansible/roles/common/templates/conf/input/05-libvirt.conf.j2 index 249e52b214..de8c650547 100644 --- a/ansible/roles/common/templates/conf/input/05-libvirt.conf.j2 +++ b/ansible/roles/common/templates/conf/input/05-libvirt.conf.j2 @@ -1,7 +1,7 @@ @type tail 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 enable_watch_timer false diff --git a/ansible/roles/common/templates/conf/input/10-openvswitch.conf.j2 b/ansible/roles/common/templates/conf/input/10-openvswitch.conf.j2 index f08272bdf9..edde2872a6 100644 --- a/ansible/roles/common/templates/conf/input/10-openvswitch.conf.j2 +++ b/ansible/roles/common/templates/conf/input/10-openvswitch.conf.j2 @@ -1,7 +1,7 @@ @type tail 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 enable_watch_timer false @@ -16,7 +16,7 @@ @type tail 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 enable_watch_timer false diff --git a/ansible/roles/common/templates/fluentd.json.j2 b/ansible/roles/common/templates/fluentd.json.j2 index 712182c14a..82302aa0c1 100644 --- a/ansible/roles/common/templates/fluentd.json.j2 +++ b/ansible/roles/common/templates/fluentd.json.j2 @@ -1,10 +1,8 @@ -{% set fluentd_user = 'td-agent' %} -{% set fluentd_dir = '/etc/td-agent' %} -{% set fluentd_conf = 'td-agent.conf' %} -{% set fluentd_cmd = '/usr/sbin/td-agent' %} +{% set fluentd_dir = '/etc/' + (fluentd_cmd | default('td-agent')) %} +{% set fluentd_conf = (fluentd_cmd | default('td-agent')) + '.conf' %} { - "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": [ { "source": "{{ container_config_directory }}/td-agent.conf", diff --git a/requirements-core.yml b/requirements-core.yml index 9f118a3f42..d5016a62f8 100644 --- a/requirements-core.yml +++ b/requirements-core.yml @@ -12,3 +12,9 @@ collections: - name: community.general source: https://galaxy.ansible.com version: <7 + - name: community.docker + source: https://galaxy.ansible.com + version: <4 + - name: containers.podman + source: https://galaxy.ansible.com + version: <2