Makes ports configurable for fireball. Note port defaults really belong in the connection plugins, not runner, which can be refactored later.
This commit is contained in:
parent
612561ad0e
commit
04954dbc1e
3 changed files with 23 additions and 10 deletions
|
@ -100,7 +100,7 @@ class Runner(object):
|
|||
pattern=C.DEFAULT_PATTERN, # which hosts? ex: 'all', 'acme.example.org'
|
||||
remote_user=C.DEFAULT_REMOTE_USER, # ex: 'username'
|
||||
remote_pass=C.DEFAULT_REMOTE_PASS, # ex: 'password123' or None if using key
|
||||
remote_port=C.DEFAULT_REMOTE_PORT, # if SSH on different ports
|
||||
remote_port=None, # if SSH on different ports
|
||||
private_key_file=C.DEFAULT_PRIVATE_KEY_FILE, # if not using keys/passwords
|
||||
sudo_pass=C.DEFAULT_SUDO_PASS, # ex: 'password123' or None
|
||||
background=0, # async poll every X seconds, else 0 for non-async
|
||||
|
@ -208,7 +208,9 @@ class Runner(object):
|
|||
|
||||
# hack to support fireball mode
|
||||
if module_name == 'fireball':
|
||||
args = "%s password=%s port=%s" % (args, base64.b64encode(str(utils.key_for_hostname(conn.host))), C.ZEROMQ_PORT)
|
||||
args = "%s password=%s" % (args, base64.b64encode(str(utils.key_for_hostname(conn.host))))
|
||||
if 'port' not in args:
|
||||
args += " port=%s" % C.ZEROMQ_PORT
|
||||
|
||||
(remote_module_path, is_new_style) = self._copy_module(conn, tmp, module_name, args, inject)
|
||||
cmd = "chmod u+x %s" % remote_module_path
|
||||
|
@ -262,7 +264,13 @@ class Runner(object):
|
|||
''' executes any module one or more times '''
|
||||
|
||||
host_variables = self.inventory.get_variables(host)
|
||||
port = host_variables.get('ansible_ssh_port', self.remote_port)
|
||||
if self.transport in [ 'paramiko', 'ssh' ]:
|
||||
port = host_variables.get('ansible_ssh_port', self.remote_port)
|
||||
if port is None:
|
||||
port = C.DEFAULT_REMOTE_PORT
|
||||
else:
|
||||
# fireball, local, etc
|
||||
port = self.remote_port
|
||||
|
||||
inject = {}
|
||||
inject.update(host_variables)
|
||||
|
|
|
@ -35,12 +35,14 @@ class Connection(object):
|
|||
def __init__(self, runner):
|
||||
self.runner = runner
|
||||
|
||||
def connect(self, host, port=None):
|
||||
def connect(self, host, port):
|
||||
conn = None
|
||||
transport = self.runner.transport
|
||||
module = modules.get(transport, None)
|
||||
if module is None:
|
||||
raise AnsibleError("unsupported connection type: %s" % transport)
|
||||
conn = module.Connection(self.runner, host, port)
|
||||
return conn.connect()
|
||||
self.active = conn.connect()
|
||||
return self.active
|
||||
|
||||
|
||||
|
|
|
@ -31,9 +31,9 @@ except ImportError:
|
|||
pass
|
||||
|
||||
class Connection(object):
|
||||
''' SSH based connections with Paramiko '''
|
||||
''' ZeroMQ accelerated connection '''
|
||||
|
||||
def __init__(self, runner, host, port=None):
|
||||
def __init__(self, runner, host, port):
|
||||
|
||||
self.runner = runner
|
||||
|
||||
|
@ -45,9 +45,12 @@ class Connection(object):
|
|||
self.key = utils.key_for_hostname(host)
|
||||
self.context = None
|
||||
self.socket = None
|
||||
# port passed in is the SSH port, which we ignore
|
||||
self.port = constants.ZEROMQ_PORT
|
||||
|
||||
|
||||
if port is None:
|
||||
self.port = constants.ZEROMQ_PORT
|
||||
else:
|
||||
self.port = port
|
||||
|
||||
def connect(self):
|
||||
''' activates the connection object '''
|
||||
|
||||
|
|
Loading…
Reference in a new issue