playbookをrole毎に分けた際、roleの中でfilesのpath指定をするために実行中の/path/to/role/{current}を知りたくなった。

ref: Accessiing information about other hosts with magic variables

1
2
3
4
# roles/anyenv/tasks/main.yml
- name: test
  debug:
    var: role_path
1
2
3
4
5
# 実行結果
TASK [anyenv : test] ***************************************
ok: [192.168.33.11] => {
    "role_path": "/vagrant/roles/anyenv"
}