- name: setup fluent-bit addon configs for metrics and logs gather_facts: yes hosts: debian_host become: true tasks: # https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_tests.html#type-tests - name: assert variables assert: that: ( addons is defined ) and ( addons is not string ) and ( addons is not mapping ) and ( addons is iterable ) and ( addons is sequence ) # https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_loops.html#iterating-over-a-simple-list - name: addon config template ansible.builtin.template: src: "flb-addons/flb_{{item}}.conf.j2" dest: "/etc/fluent-bit/flb_{{item}}.conf" loop: "{{addons}}" notify: restart fluentbit #no_log: true - name: addon config file ansible.builtin.copy: src: "flb-addons/custom_parsers_{{item}}.conf" dest: /etc/fluent-bit/ loop: "{{addons}}" notify: restart fluentbit failed_when: false # TODO try to use fileglob + loop without include_tasks - don't want yet another yaml file handlers: - name: restart fluentbit ansible.builtin.shell: executable: /bin/bash cmd: "[[ -x /lib/systemd/systemd ]] && systemctl restart fluent-bit.service || /etc/fluent-bit/RESTART-FLUENTBIT"