From 68a3e8163e03e70a341fc5da69ead40820cb5b4d Mon Sep 17 00:00:00 2001 From: Niku Toivola Date: Thu, 16 Jan 2014 15:14:40 +0200 Subject: [PATCH 1/3] allow ansible_ssh_private_key_file to be templated (thanks to benno) --- lib/ansible/runner/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 189bcb3b927..d430c90ccda 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -708,6 +708,8 @@ class Runner(object): actual_pass = inject.get('ansible_ssh_pass', self.remote_pass) actual_transport = inject.get('ansible_connection', self.transport) actual_private_key_file = inject.get('ansible_ssh_private_key_file', self.private_key_file) + # allow ansible_ssh_private_key_file to be templated + actual_private_key_file = template.template(self.basedir, actual_private_key_file, inject, fail_on_undefined=True) self.sudo_pass = inject.get('ansible_sudo_pass', self.sudo_pass) self.su = inject.get('ansible_su', self.su) self.su_pass = inject.get('ansible_su_pass', self.su_pass) From 2faaff78eeb1b5e503eec2873ea42c53d6c17c86 Mon Sep 17 00:00:00 2001 From: Niku Toivola Date: Thu, 16 Jan 2014 21:43:01 +0200 Subject: [PATCH 2/3] removed comment --- lib/ansible/runner/__init__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index d430c90ccda..7c38f686a1a 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -708,7 +708,6 @@ class Runner(object): actual_pass = inject.get('ansible_ssh_pass', self.remote_pass) actual_transport = inject.get('ansible_connection', self.transport) actual_private_key_file = inject.get('ansible_ssh_private_key_file', self.private_key_file) - # allow ansible_ssh_private_key_file to be templated actual_private_key_file = template.template(self.basedir, actual_private_key_file, inject, fail_on_undefined=True) self.sudo_pass = inject.get('ansible_sudo_pass', self.sudo_pass) self.su = inject.get('ansible_su', self.su) From 6cc9b16f06e44f9f24cb4d499fd07980b441e5ab Mon Sep 17 00:00:00 2001 From: Niku Toivola Date: Mon, 20 Jan 2014 19:06:42 +0200 Subject: [PATCH 3/3] allow templating of ansible_ssh_private_key_file also in the synchronize module --- lib/ansible/runner/action_plugins/synchronize.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ansible/runner/action_plugins/synchronize.py b/lib/ansible/runner/action_plugins/synchronize.py index 2af14206b8c..e7dd54127b1 100644 --- a/lib/ansible/runner/action_plugins/synchronize.py +++ b/lib/ansible/runner/action_plugins/synchronize.py @@ -135,6 +135,8 @@ class ActionModule(object): else: private_key = inject.get('ansible_ssh_private_key_file', self.runner.private_key_file) + private_key = template.template(self.runner.basedir, private_key, inject, fail_on_undefined=True) + if not private_key is None: private_key = os.path.expanduser(private_key) options['private_key'] = private_key