How to get current role name in an ansible task

前端 未结 4 1438
刺人心
刺人心 2021-02-01 16:05

How can I get the current role name in an ansible task yaml file?

I would like to do something like this

---
# role/some-role-name/tasks/main.yml

- name         


        
4条回答
  •  攒了一身酷
    2021-02-01 16:55

    See this post:

    To get the role directory:

    role_dir: "{{ lookup('pipe', 'pwd') | dirname }}"
    

    To get the role name:

    role_name: "{{ lookup('pipe', 'pwd') | dirname | basename }}"
    

提交回复
热议问题