From d23ab261e181cdfef8bfa71597d40c6e9cb01972 Mon Sep 17 00:00:00 2001 From: Gerard Lynch Date: Thu, 16 Jul 2015 23:00:17 +0100 Subject: [PATCH] fixes 11607, allows ansible_ssh_port to be overridden from group or host_vars --- lib/ansible/inventory/host.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/ansible/inventory/host.py b/lib/ansible/inventory/host.py index c14a6f4a25e..c8083edb928 100644 --- a/lib/ansible/inventory/host.py +++ b/lib/ansible/inventory/host.py @@ -78,8 +78,6 @@ class Host: if port and port != C.DEFAULT_REMOTE_PORT: self.set_variable('ansible_ssh_port', int(port)) - else: - self.set_variable('ansible_ssh_port', C.DEFAULT_REMOTE_PORT) self._gathered_facts = False @@ -124,6 +122,10 @@ class Host: results['inventory_hostname'] = self.name results['inventory_hostname_short'] = self.name.split('.')[0] results['ansible_ssh_host'] = self.ipv4_address + + if 'ansible_ssh_port' not in results: + results['ansible_ssh_port'] = C.DEFAULT_REMOTE_PORT + results['group_names'] = sorted([ g.name for g in groups if g.name != 'all']) return results