From 48fe7ac19d22ba49508eca022d8452a46bb211fa Mon Sep 17 00:00:00 2001 From: Gilles Cornu Date: Tue, 18 Jun 2013 17:53:52 +0200 Subject: [PATCH] Enlarge scope of 'ansible_ssh_user' magic variable Allow to use ansible_ssh_user variable in `sudo_user` or `when` clauses --- lib/ansible/runner/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 6adf5512f78..9b204b9d578 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -378,6 +378,7 @@ class Runner(object): inject = utils.combine_vars(inject, host_variables) inject = utils.combine_vars(inject, self.module_vars) inject = utils.combine_vars(inject, self.setup_cache[host]) + inject.setdefault('ansible_ssh_user', self.remote_user) inject['hostvars'] = HostVars(self.setup_cache, self.inventory) inject['group_names'] = host_variables.get('group_names', []) inject['groups'] = self.inventory.groups_list()