Commit cd32597a by Michael DeHaan

Make the file module work as expected in check mode

parent 931b9f41
...@@ -159,6 +159,7 @@ class AnsibleModule(object): ...@@ -159,6 +159,7 @@ class AnsibleModule(object):
if check_invalid_arguments: if check_invalid_arguments:
self._check_invalid_arguments() self._check_invalid_arguments()
self._check_for_check_mode()
self._set_defaults(pre=True) self._set_defaults(pre=True)
...@@ -462,13 +463,18 @@ class AnsibleModule(object): ...@@ -462,13 +463,18 @@ class AnsibleModule(object):
if alias in self.params: if alias in self.params:
self.params[k] = self.params[alias] self.params[k] = self.params[alias]
def _check_invalid_arguments(self): def _check_for_check_mode(self):
for (k,v) in self.params.iteritems(): for (k,v) in self.params.iteritems():
if k == 'CHECKMODE': if k == 'CHECKMODE':
if not self.supports_check_mode: if not self.supports_check_mode:
self.exit_json(skipped=True, msg="remote module does not support check mode") self.exit_json(skipped=True, msg="remote module does not support check mode")
if self.supports_check_mode: if self.supports_check_mode:
self.check_mode = True self.check_mode = True
def _check_invalid_arguments(self):
for (k,v) in self.params.iteritems():
if k == 'CHECKMODE':
continue
if k not in self._legal_inputs: if k not in self._legal_inputs:
self.fail_json(msg="unsupported parameter for module: %s" % k) self.fail_json(msg="unsupported parameter for module: %s" % k)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment