Merge pull request #1399 from dhozac/set-delegate-for-alias
Fix ansible_ssh_host again
This commit is contained in:
commit
52f2ed5fe1
4 changed files with 29 additions and 3 deletions
|
@ -393,7 +393,7 @@ class Runner(object):
|
||||||
if actual_port is not None:
|
if actual_port is not None:
|
||||||
actual_port = int(actual_port)
|
actual_port = int(actual_port)
|
||||||
conn = self.connector.connect(actual_host, actual_port)
|
conn = self.connector.connect(actual_host, actual_port)
|
||||||
if delegate_to:
|
if delegate_to or host != actual_host:
|
||||||
conn.delegate = host
|
conn.delegate = host
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -111,12 +111,12 @@ class TestPlaybook(unittest.TestCase):
|
||||||
filename = os.path.join(self.stage_dir, filename)
|
filename = os.path.join(self.stage_dir, filename)
|
||||||
return 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 '''
|
''' run a module and get the localhost results '''
|
||||||
self.test_callbacks = TestCallbacks()
|
self.test_callbacks = TestCallbacks()
|
||||||
self.playbook = ansible.playbook.PlayBook(
|
self.playbook = ansible.playbook.PlayBook(
|
||||||
playbook = test_playbook,
|
playbook = test_playbook,
|
||||||
host_list = 'test/ansible_hosts',
|
host_list = host_list,
|
||||||
module_path = 'library/',
|
module_path = 'library/',
|
||||||
forks = 1,
|
forks = 1,
|
||||||
timeout = 5,
|
timeout = 5,
|
||||||
|
@ -155,6 +155,21 @@ class TestPlaybook(unittest.TestCase):
|
||||||
print data
|
print data
|
||||||
assert data.find("ears") != -1, "template success"
|
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):
|
def test_playbook_vars(self):
|
||||||
test_callbacks = TestCallbacks()
|
test_callbacks = TestCallbacks()
|
||||||
playbook = ansible.playbook.PlayBook(
|
playbook = ansible.playbook.PlayBook(
|
||||||
|
|
2
test/alias_hosts
Normal file
2
test/alias_hosts
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[aliasgroup]
|
||||||
|
alias-node.example.com ansible_ssh_host=localhost ansible_ssh_port=22
|
9
test/alias_playbook.yml
Normal file
9
test/alias_playbook.yml
Normal file
|
@ -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…
Reference in a new issue