Fix ansible_ssh_host again

This time with unit tests to ensure it keeps working.
pull/1648/head
Daniel Hokka Zakrisson 12 years ago
parent 572c66b7f6
commit 1449c8ac67

@ -393,7 +393,7 @@ class Runner(object):
if actual_port is not None:
actual_port = int(actual_port)
conn = self.connector.connect(actual_host, actual_port)
if delegate_to:
if delegate_to or host != actual_host:
conn.delegate = host

@ -111,12 +111,12 @@ class TestPlaybook(unittest.TestCase):
filename = os.path.join(self.stage_dir, filename)
return filename
def _run(self, test_playbook):
def _run(self, test_playbook, host_list='test/ansible_hosts'):
''' run a module and get the localhost results '''
self.test_callbacks = TestCallbacks()
self.playbook = ansible.playbook.PlayBook(
playbook = test_playbook,
host_list = 'test/ansible_hosts',
host_list = host_list,
module_path = 'library/',
forks = 1,
timeout = 5,
@ -155,6 +155,21 @@ class TestPlaybook(unittest.TestCase):
print data
assert data.find("ears") != -1, "template success"
def test_aliased_node(self):
pb = os.path.join(self.test_dir, 'alias_playbook.yml')
actual = self._run(pb, 'test/alias_hosts')
expected = {
"alias-node.example.com": {
"changed": 3,
"failures": 0,
"ok": 4,
"skipped": 1,
"unreachable": 0,
}
}
assert utils.jsonify(expected, format=True) == utils.jsonify(actual, format=True)
def test_playbook_vars(self):
test_callbacks = TestCallbacks()
playbook = ansible.playbook.PlayBook(

@ -0,0 +1,2 @@
[aliasgroup]
alias-node.example.com ansible_ssh_host=localhost ansible_ssh_port=22

@ -0,0 +1,9 @@
---
- hosts: all
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
Loading…
Cancel
Save