diff options
author | Michael DeHaan <michael.dehaan@gmail.com> | 2012-10-24 16:57:33 -0700 |
---|---|---|
committer | Michael DeHaan <michael.dehaan@gmail.com> | 2012-10-24 16:57:33 -0700 |
commit | 2bdad2c393afabb8670c3a2162938414caec3019 (patch) | |
tree | d1dc4da885dece147256c2c6bc99fbb2d86903cb | |
parent | e07227194bc67882f694d4ecefca6efe2beaee1b (diff) | |
parent | 905538f7558c57ebcd94f903f1cf9b3eb0611b1e (diff) | |
download | ansible-release-0.8.tar.gz |
Merge pull request #1443 from dhozac/set-delegate-for-alias-0.8release-0.8
Fix ansible_ssh_host again
-rw-r--r-- | lib/ansible/runner/__init__.py | 2 | ||||
-rw-r--r-- | test/TestPlayBook.py | 19 | ||||
-rw-r--r-- | test/alias_hosts | 2 | ||||
-rw-r--r-- | test/alias_playbook.yml | 9 |
4 files changed, 29 insertions, 3 deletions
diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index a6d03d1281..385c3fdfa8 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -405,7 +405,7 @@ class Runner(object): if actual_port is not None: actual_port = int(actual_port) conn = self.connector.connect(actual_host, actual_port, transport=transport) - if delegate_to: + if delegate_to or host != actual_host: conn.delegate = host diff --git a/test/TestPlayBook.py b/test/TestPlayBook.py index fd57f328bb..55d552da95 100644 --- a/test/TestPlayBook.py +++ b/test/TestPlayBook.py @@ -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( diff --git a/test/alias_hosts b/test/alias_hosts new file mode 100644 index 0000000000..1b8081a2bb --- /dev/null +++ b/test/alias_hosts @@ -0,0 +1,2 @@ +[aliasgroup] +alias-node.example.com ansible_ssh_host=localhost ansible_ssh_port=22 diff --git a/test/alias_playbook.yml b/test/alias_playbook.yml new file mode 100644 index 0000000000..c3a5e448cf --- /dev/null +++ b/test/alias_playbook.yml @@ -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 |