From 7cfd02097cfd6e2f966b8bd8dbc1e94194df4fc5 Mon Sep 17 00:00:00 2001 From: giovannisciortino <30353557+giovannisciortino@users.noreply.github.com> Date: Fri, 28 Jul 2017 23:35:20 +0200 Subject: [PATCH] add_hosts.py: Fix add_host does not recognise 'host' alias (#27418) * add_hosts.py: Fix add_host does not recognise 'host' alias * add_hosts.py: add note in documentation that 'hosts' alias of name parameter is only available on >=2.4 --- lib/ansible/modules/inventory/add_host.py | 1 + lib/ansible/plugins/action/add_host.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ansible/modules/inventory/add_host.py b/lib/ansible/modules/inventory/add_host.py index 1e2c8398c9..236b8875b6 100644 --- a/lib/ansible/modules/inventory/add_host.py +++ b/lib/ansible/modules/inventory/add_host.py @@ -44,6 +44,7 @@ notes: - This module bypasses the play host loop and only runs once for all the hosts in the play, if you need it to iterate use a with\_ directive. - This module is also supported for Windows targets. + - The alias 'host' of the parameter 'name' is only available on >=2.4 author: - "Ansible Core Team" - "Seth Vidal" diff --git a/lib/ansible/plugins/action/add_host.py b/lib/ansible/plugins/action/add_host.py index 99c33ef1dc..cb4f2a0317 100644 --- a/lib/ansible/plugins/action/add_host.py +++ b/lib/ansible/plugins/action/add_host.py @@ -46,7 +46,7 @@ class ActionModule(ActionBase): result = super(ActionModule, self).run(tmp, task_vars) # Parse out any hostname:port patterns - new_name = self._task.args.get('name', self._task.args.get('hostname', None)) + new_name = self._task.args.get('name', self._task.args.get('hostname', self._task.args.get('host', None))) display.vv("creating host via 'add_host': hostname=%s" % new_name) try: