Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use default port if ansible_ssh_port is not set for the delegated node #1505

Merged
merged 1 commit into from
Nov 1, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/ansible/runner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ def _executor_internal_inner(self, host, module_name, module_args, inject, port,
interpreters.append(i)
for i in interpreters:
del inject[i]
port = C.DEFAULT_REMOTE_PORT
try:
delegate_info = inject['hostvars'][delegate_to]
actual_host = delegate_info.get('ansible_ssh_host', delegate_to)
Expand All @@ -393,6 +394,7 @@ def _executor_internal_inner(self, host, module_name, module_args, inject, port,
inject[i] = delegate_info[i]
except errors.AnsibleError:
actual_host = delegate_to
actual_port = port

try:
if actual_port is not None:
Expand Down
13 changes: 10 additions & 3 deletions test/TestPlayBook.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,19 @@ def test_aliased_node(self):
actual = self._run(pb, 'test/alias_hosts')
expected = {
"alias-node.example.com": {
"changed": 3,
"changed": 5,
"failures": 0,
"ok": 4,
"ok": 6,
"skipped": 1,
"unreachable": 0,
}
},
"other-alias-node.example.com": {
"changed": 1,
"failures": 0,
"ok": 1,
"skipped": 0,
"unreachable": 1,
},
}

assert utils.jsonify(expected, format=True) == utils.jsonify(actual, format=True)
Expand Down
4 changes: 3 additions & 1 deletion test/alias_hosts
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
other-alias-node.example.com ansible_ssh_host=localhost ansible_ssh_port=28848

[aliasgroup]
alias-node.example.com ansible_ssh_host=localhost ansible_ssh_port=22
alias-node.example.com ansible_ssh_host=localhost
9 changes: 8 additions & 1 deletion test/alias_playbook.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
---
- hosts: all
- hosts: aliasgroup
vars:
test_file: /tmp/ansible-alias-test
tasks:
- action: command creates=$test_file touch $test_file
- action: command creates=$test_file false
- local_action: command true
- action: command removes=$test_file rm -f $test_file

- hosts: all
gather_facts: False
tasks:
- action: command true
delegate_to: alias-node.example.com
- action: command true