--- - name: Make sure targets are deployed ansible.builtin.lineinfile: path: '{{ item.0.path if item.0.path is defined else prometheus_target_exporter_defaults[item.0.id].path }}' line: '{{ prometheus_target_strategy_lineinfile_prefix ~ (item.1 if item.1 != "" else prometheus_target_exporter_defaults[item.0.id].host) ~ prometheus_target_strategy_lineinfile_suffix }}' state: present become: true delegate_to: '{{ prometheus_target_host }}' loop: '{{ (prometheus_target_exporter | selectattr("hosts", "defined") | subelements("hosts")) + (prometheus_target_exporter | selectattr("hosts", "undefined") | product([""])) }}' notify: - Run command hook - Run shell hook