When using delegation, local_action should always use the local connection type.

This commit is contained in:
Michael DeHaan 2012-10-18 20:14:15 -04:00
parent d58bc4da4e
commit 31b45479e8
3 changed files with 12 additions and 8 deletions

View file

@ -18,7 +18,7 @@ The following is an opt-in list of just some of the folks using Ansible -- to ge
* `Scientific Computing Center, Aristotle Univ. of Thessaloniki <http://www.grid.auth.gr/en/>`_ - Grid/Cloud-Based Scientific Computing * `Scientific Computing Center, Aristotle Univ. of Thessaloniki <http://www.grid.auth.gr/en/>`_ - Grid/Cloud-Based Scientific Computing
* `Skylines.io <http://skylines.io>`_ - Real time photo search engine * `Skylines.io <http://skylines.io>`_ - Real time photo search engine
* `Steelhouse <http://steelhouse.com>`_ - Behavioral commerce * `Steelhouse <http://steelhouse.com>`_ - Behavioral commerce
* `Tommorrow Focus Technologies GmbH <http://www.t-f-t.net/>`_ - Running some of the biggest web sites in Europe * `Tomorrow Focus Technologies GmbH <http://www.t-f-t.net/>`_ - Running some of the biggest web sites in Europe
* `123i.com.br <http://123i.com.br>`_ - Find real estate in Brazil * `123i.com.br <http://123i.com.br>`_ - Find real estate in Brazil
* `Ginsys <http://ginsys.eu/>`_ - Linux infrastructure consulting from Belgium * `Ginsys <http://ginsys.eu/>`_ - Linux infrastructure consulting from Belgium

View file

@ -399,11 +399,14 @@ class Runner(object):
actual_host = delegate_to actual_host = delegate_to
try: try:
# connect transport = None # use Runner setting
conn = self.connector.connect(actual_host, int(actual_port)) if delegate_to and actual_host in [ '127.0.0.1', 'localhost' ]:
transport = 'local'
conn = self.connector.connect(actual_host, int(actual_port), transport=transport)
if delegate_to: if delegate_to:
conn.delegate = host conn.delegate = host
except errors.AnsibleConnectionFailed, e: except errors.AnsibleConnectionFailed, e:
result = dict(failed=True, msg="FAILED: %s" % str(e)) result = dict(failed=True, msg="FAILED: %s" % str(e))
return ReturnData(host=host, comm_ok=False, result=result) return ReturnData(host=host, comm_ok=False, result=result)

View file

@ -40,11 +40,12 @@ class Connection(object):
self.runner = runner self.runner = runner
self.modules = None self.modules = None
def connect(self, host, port): def connect(self, host, port, transport=None):
if self.modules is None: if self.modules is None:
self.modules = modules.copy() self.modules = modules.copy()
self.modules.update(utils.import_plugins(os.path.join(self.runner.basedir, 'connection_plugins'))) self.modules.update(utils.import_plugins(os.path.join(self.runner.basedir, 'connection_plugins')))
conn = None conn = None
if transport is None:
transport = self.runner.transport transport = self.runner.transport
module = self.modules.get(transport, None) module = self.modules.get(transport, None)
if module is None: if module is None: