1

I want to include a task from a different role.

I would not want to hardcode it like

- name : Set topology based on Jenkins job name
  include: ../../pre-req/tasks/set-topo.yml
  tags: core

Is there a way to do this with dependency? I tried creating a meta directory with files and tasks, somehow it' s not getting triggered.

something like this

vim roles/pre-req/meta/main.yml

---
allow_duplicates: yes
dependencies:
  - { role: topo, tags: ['core'] }
Yogesh D
  • 1,558
  • 14
  • 29
Bhavik Bhavsar
  • 301
  • 3
  • 9

1 Answers1

2

I would not want to hardcode it like

Why not? You want to include a task, and that's how you include a task.

If what you want to do is include the entire other role, Ansible 2.2 (released yesterday) added include_role.

4wk_
  • 2,458
  • 3
  • 34
  • 46
Xiong Chiamiov
  • 13,076
  • 9
  • 63
  • 101