summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Krizek <martin.krizek@gmail.com>2018-02-12 20:04:27 +0100
committerMatt Davis <mrd@redhat.com>2018-02-15 23:31:25 -0800
commitb546dde48ce02ec50036bbb610f31d65559bce66 (patch)
tree0dbf640f995ce66509e7f69400e7a41bf0677cde
parenteec79452226826836bc4a156074146d8fde44d96 (diff)
downloadansible-b546dde48ce02ec50036bbb610f31d65559bce66.tar.gz
add_host: check if name or hostname arg is provided
(cherry picked from commit 39d9496282cbe4f13679ef6e556f7fe72eac2c0f)
-rw-r--r--lib/ansible/plugins/action/add_host.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/ansible/plugins/action/add_host.py b/lib/ansible/plugins/action/add_host.py
index cd4bb40e78..f92588fe7d 100644
--- a/lib/ansible/plugins/action/add_host.py
+++ b/lib/ansible/plugins/action/add_host.py
@@ -48,6 +48,12 @@ class ActionModule(ActionBase):
# Parse out any hostname:port patterns
new_name = self._task.args.get('name', self._task.args.get('hostname', self._task.args.get('host', None)))
+
+ if new_name is None:
+ result['failed'] = True
+ result['msg'] = 'name or hostname arg needs to be provided'
+ return result
+
display.vv("creating host via 'add_host': hostname=%s" % new_name)
try: