From 1465f70eb5c88f1a7fcbbe51dca464ef3e3c06a5 Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Mon, 12 Nov 2018 17:18:49 +0100 Subject: [PATCH] Add ansible_play_name magic var (#48562) --- changelogs/fragments/11349-add-ansible_play_name-var.yaml | 2 ++ docs/docsite/rst/reference_appendices/special_variables.rst | 6 ++++++ lib/ansible/vars/manager.py | 1 + 3 files changed, 9 insertions(+) create mode 100644 changelogs/fragments/11349-add-ansible_play_name-var.yaml diff --git a/changelogs/fragments/11349-add-ansible_play_name-var.yaml b/changelogs/fragments/11349-add-ansible_play_name-var.yaml new file mode 100644 index 0000000000..c42bcddacb --- /dev/null +++ b/changelogs/fragments/11349-add-ansible_play_name-var.yaml @@ -0,0 +1,2 @@ +minor_changes: + - Add ``ansible_play_name`` magic var (https://github.com/ansible/ansible/issues/11349) diff --git a/docs/docsite/rst/reference_appendices/special_variables.rst b/docs/docsite/rst/reference_appendices/special_variables.rst index cfe525c740..3d729e35ef 100644 --- a/docs/docsite/rst/reference_appendices/special_variables.rst +++ b/docs/docsite/rst/reference_appendices/special_variables.rst @@ -76,9 +76,15 @@ omit play_hosts Deprecated, the same as ansbile_play_batch +ansible_play_name + The name of the currently executed play. Added in ``2.8``. + playbook_dir The path to the directory of the playbook that was passed to the ``ansible-playbook`` command line. +role_name: + The name of the currently executed role + role_names The names of the rules currently imported into the current play. diff --git a/lib/ansible/vars/manager.py b/lib/ansible/vars/manager.py index 4043681268..a783076a3b 100644 --- a/lib/ansible/vars/manager.py +++ b/lib/ansible/vars/manager.py @@ -452,6 +452,7 @@ class VariableManager: if play: variables['role_names'] = [r._role_name for r in play.roles] + variables['ansible_play_name'] = play.get_name() if task: if task._role: