This is the yml file:
- name: Update Prometheus Configuration
blockinfile:
path: "/u01/grafana/prometheus/prometheus-2.28.1/prometheus.yml"
insertafter: "# {{ item }} BEGIN ANSIBLE MANAGED BLOCK"
block: |
# {{ hostn }} entry by Ansible
- targets: ['{{ fullhost }}:9162']
labels:
instance: {{ targetdb }}
become: yes
with_items:
- "DBCRITICAL"
- "DB6H"
- "DB1H"
But looping is happening for only - "DBCRITICAL"
output:
TASK [Update Prometheus Configuration] *****************************************18:20:49
83
changed: [hostname] => (item=DBCRITICAL)
84
ok: [hostname] => (item=DB6H)
85
ok: [hostname] => (item=DB1H)