1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

now properly uses default port if defined

This commit is contained in:
Brian Coca 2015-07-31 12:01:32 -04:00
parent 496186f5de
commit f16b745f17
3 changed files with 6 additions and 3 deletions

View file

@ -19,7 +19,6 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
from ansible import constants as C
from ansible.inventory.group import Group from ansible.inventory.group import Group
from ansible.utils.vars import combine_vars from ansible.utils.vars import combine_vars
@ -76,7 +75,7 @@ class Host:
self.ipv4_address = name self.ipv4_address = name
self.ipv6_address = name self.ipv6_address = name
if port and port != C.DEFAULT_REMOTE_PORT: if port:
self.set_variable('ansible_ssh_port', int(port)) self.set_variable('ansible_ssh_port', int(port))
self._gathered_facts = False self._gathered_facts = False

View file

@ -108,7 +108,7 @@ class InventoryParser(object):
if len(tokens) == 0: if len(tokens) == 0:
continue continue
hostname = tokens[0] hostname = tokens[0]
port = C.DEFAULT_REMOTE_PORT port = None
# Three cases to check: # Three cases to check:
# 0. A hostname that contains a range pesudo-code and a port # 0. A hostname that contains a range pesudo-code and a port
# 1. A hostname that contains just a port # 1. A hostname that contains just a port

View file

@ -298,6 +298,10 @@ class PlayContext(Base):
if variable_name in variables: if variable_name in variables:
setattr(new_info, attr, variables[variable_name]) setattr(new_info, attr, variables[variable_name])
# make sure we get port defaults if needed
if newinfo.port is None and C.DEFAULT_REMOTE_PORT is not None:
newinfo.port = int(C.DEFAULT_REMOTE_PORT)
# become legacy updates # become legacy updates
if not new_info.become_pass: if not new_info.become_pass:
if new_info.become_method == 'sudo' and new_info.sudo_pass: if new_info.become_method == 'sudo' and new_info.sudo_pass: