From 906e59d8a8eb4b5b7f6e6b5580019ae015a34f8b Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Tue, 11 Mar 2014 22:13:29 -0400 Subject: [PATCH] added new role_names variable that exposes current roles list --- lib/ansible/playbook/play.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/ansible/playbook/play.py b/lib/ansible/playbook/play.py index af66ee2574..cd38a54078 100644 --- a/lib/ansible/playbook/play.py +++ b/lib/ansible/playbook/play.py @@ -134,6 +134,7 @@ class Play(object): '("su", "su_user") cannot be used together') load_vars = {} + load_vars['role_names'] = ds.get('role_names',[]) load_vars['playbook_dir'] = self.basedir if self.playbook.inventory.basedir() is not None: load_vars['inventory_dir'] = self.playbook.inventory.basedir() @@ -356,6 +357,7 @@ class Play(object): new_tasks.append(dict(meta='flush_handlers')) roles = self._build_role_dependencies(roles, [], self.vars) + role_names = [] for (role,role_path,role_vars,default_vars) in roles: # special vars must be extracted from the dict to the included tasks @@ -388,6 +390,7 @@ class Play(object): else: role_name = role + role_names.append(role_name) if os.path.isfile(task): nt = dict(include=pipes.quote(task), vars=role_vars, default_vars=default_vars, role_name=role_name) for k in special_keys: @@ -434,6 +437,7 @@ class Play(object): ds['tasks'] = new_tasks ds['handlers'] = new_handlers ds['vars_files'] = new_vars_files + ds['role_names'] = role_names self.default_vars = self._load_role_defaults(defaults_files)