From 39d9496282cbe4f13679ef6e556f7fe72eac2c0f Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Mon, 12 Feb 2018 20:04:27 +0100 Subject: [PATCH] add_host: check if name or hostname arg is provided --- lib/ansible/plugins/action/add_host.py | 6 ++++++ 1 file changed, 6 insertions(+) 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: