how to run perticular dependency role for specific host group

28 views
Skip to first unread message

Sameer Modak

unread,
Apr 18, 2024, 7:18:18 AM4/18/24
to Ansible Project
Hello Team,

We have below grafana agent play.yaml  and inside dependency we have mentioned below content now issue is kafka_exporter role runs on all hosts.  We want only to run on broker host how to achieve it??

grafana-agent-play.yaml 

 - name: "GRAgent Play"

  hosts: all:!localhost

  strategy: linear

  order: sorted

  become: no

  gather_facts: True

# See bug https://github.com/grafana/grafana-ansible-collection/issues/153 for parallel runs.

  serial:

    - 3

    - 25%

    - 50%

    - 100%

  vars:

    ansible_remote_tmp: /tmp


  tasks:

    - name: Run roles under dependencies

      ansible.builtin.include_role:

        name: "{{ dependent_role }}"

      with_items: "{{ dependencies }}"

      loop_control:

        loop_var: dependent_role

      tags: ['always', 'install']


dependencies.yaml

---

dependencies:

- grafana.grafana.grafana_agent

- kafka_gra_config

- kafka_exporter

Brian Coca

unread,
Apr 18, 2024, 11:25:49 AM4/18/24
to ansible...@googlegroups.com
Don't use dependencies, use include_role and make it conditional

--
----------
Brian Coca (he/him/yo)

Sameer Modak

unread,
Apr 19, 2024, 8:30:44 AM4/19/24
to Ansible Project
Thanks Brian.
so there is no possibility to achieve with dependencies ryt??

Reply all
Reply to author
Forward
0 new messages