Make the file module work as expected in check mode

pull/4420/head
Michael DeHaan 2013-02-17 12:27:00 -05:00
parent 931b9f41c8
commit cd32597af0
1 changed files with 7 additions and 1 deletions

View File

@ -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):
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)