aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tasks/lineinfile.yml
blob: c90e82307968b9a4d8aac0ce4f5caec0ab98c965 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
---
- 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