Fix idempotency of fluentd customisations

Fix fluentd config from overwriting custom config with the same filename

Closes-Bug: #1840166
Change-Id: I42c5446381033015f590901b2120950d602f847f
This commit is contained in:
Scott Solkhon 2019-08-13 15:22:37 +00:00
parent 5c70e0a615
commit dcaa5f0b3d
1 changed files with 59 additions and 44 deletions

View File

@ -37,13 +37,27 @@
notify:
- "Restart {{ item.key }} container"
- name: Find custom fluentd input config files
local_action:
module: find
path: "{{ node_custom_config }}/fluentd/input"
pattern: "*.conf"
run_once: True
register: find_custom_fluentd_inputs
when:
- enable_fluentd | bool
- name: Copying over fluentd input config files
vars:
customised_input_files: "{{ find_custom_fluentd_inputs.files | map(attribute='path') | map('basename') | list }}"
template:
src: "conf/input/{{ item }}.conf.j2"
dest: "{{ node_config_directory }}/fluentd/input/{{ item }}.conf"
mode: "0660"
become: true
when: enable_fluentd | bool
when:
- enable_fluentd | bool
- item ~ '.conf' not in customised_input_files
with_items:
- "00-global"
- "01-syslog"
@ -58,16 +72,6 @@
notify:
- Restart fluentd container
- name: Find custom fluentd input config files
local_action:
module: find
path: "{{ node_custom_config }}/fluentd/input"
pattern: "*.conf"
run_once: True
register: find_custom_fluentd_inputs
when:
- enable_fluentd | bool
- name: Copying over custom fluentd input config files
template:
src: "{{ item.path }}"
@ -85,7 +89,19 @@
( elasticsearch_address != kolla_internal_vip_address )) and
not enable_monasca | bool }}"
- name: Find custom fluentd output config files
local_action:
module: find
path: "{{ node_custom_config }}/fluentd/output"
pattern: "*.conf"
run_once: True
register: find_custom_fluentd_outputs
when:
- enable_fluentd | bool
- name: Copying over fluentd output config files
vars:
customised_output_files: "{{ find_custom_fluentd_outputs.files | map(attribute='path') | map('basename') | list }}"
template:
src: "conf/output/{{ item.name }}.conf.j2"
dest: "{{ node_config_directory }}/fluentd/output/{{ item.name }}.conf"
@ -94,6 +110,7 @@
when:
- enable_fluentd | bool
- item.enabled | bool
- item.name ~ '.conf' not in customised_output_files
with_items:
- name: "00-local"
enabled: true
@ -120,16 +137,6 @@
notify:
- Restart fluentd container
- name: Find custom fluentd output config files
local_action:
module: find
path: "{{ node_custom_config }}/fluentd/output"
pattern: "*.conf"
run_once: True
register: find_custom_fluentd_outputs
when:
- enable_fluentd | bool
- name: Copying over custom fluentd output config files
template:
src: "{{ item.path }}"
@ -142,19 +149,6 @@
notify:
- Restart fluentd container
- name: Copying over fluentd format config files
template:
src: "conf/format/{{ item }}.conf.j2"
dest: "{{ node_config_directory }}/fluentd/format/{{ item }}.conf"
mode: "0660"
become: true
with_items:
- "apache_access"
- "wsgi_access"
when: enable_fluentd | bool
notify:
- Restart fluentd container
- name: Find custom fluentd format config files
local_action:
module: find
@ -165,6 +159,23 @@
when:
- enable_fluentd | bool
- name: Copying over fluentd format config files
vars:
customised_format_files: "{{ find_custom_fluentd_format.files | map(attribute='path') | map('basename') | list }}"
template:
src: "conf/format/{{ item }}.conf.j2"
dest: "{{ node_config_directory }}/fluentd/format/{{ item }}.conf"
mode: "0660"
become: true
with_items:
- "apache_access"
- "wsgi_access"
when:
- enable_fluentd | bool
- item ~ '.conf' not in customised_format_files
notify:
- Restart fluentd container
- name: Copying over custom fluentd format config files
template:
src: "{{ item.path }}"
@ -176,7 +187,18 @@
notify:
- Restart fluentd container
- name: Find custom fluentd filter config files
local_action:
module: find
path: "{{ node_custom_config }}/fluentd/filter"
pattern: "*.conf"
run_once: True
register: find_custom_fluentd_filters
when: enable_fluentd | bool
- name: Copying over fluentd filter config files
vars:
customised_filter_files: "{{ find_custom_fluentd_filters.files | map(attribute='path') | map('basename') | list }}"
template:
src: "conf/filter/{{ item.src }}.conf.j2"
dest: "{{ node_config_directory }}/fluentd/filter/{{ item.dest }}.conf"
@ -187,19 +209,12 @@
dest: 00-record_transformer
- src: "{{ '01-rewrite-0.14' if kolla_base_distro in ['debian', 'ubuntu'] else '01-rewrite-0.12' }}"
dest: 01-rewrite
when: enable_fluentd | bool
when:
- enable_fluentd | bool
- item.src ~ '.conf' not in customised_filter_files
notify:
- Restart fluentd container
- name: Find custom fluentd filter config files
local_action:
module: find
path: "{{ node_custom_config }}/fluentd/filter"
pattern: "*.conf"
run_once: True
register: find_custom_fluentd_filters
when: enable_fluentd | bool
- name: Copying over custom fluentd filter config files
template:
src: "{{ item.path }}"