1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

reinstate invalid argument checks where possible, daisy chainee/chained modules turn it off

This commit is contained in:
Michael DeHaan 2012-08-01 19:42:31 -04:00
parent 08999a2a2f
commit ed14312ad6
4 changed files with 12 additions and 11 deletions

View file

@ -54,7 +54,7 @@ except ImportError:
class AnsibleModule(object): class AnsibleModule(object):
def __init__(self, argument_spec, bypass_checks=False, no_log=False): def __init__(self, argument_spec, bypass_checks=False, no_log=False, check_invalid_arguments=True):
''' '''
common code for quickly building an ansible module in Python common code for quickly building an ansible module in Python
(although you can write modules in anything that can return JSON) (although you can write modules in anything that can return JSON)
@ -66,8 +66,11 @@ class AnsibleModule(object):
self._legal_inputs = [] self._legal_inputs = []
self._handle_aliases() self._handle_aliases()
# temporarily disabled
# self._check_invalid_arguments() # this may be disabled where modules are going to daisy chain into others
if check_invalid_arguments:
self._check_invalid_arguments()
self._set_defaults(pre=True) self._set_defaults(pre=True)
if not bypass_checks: if not bypass_checks:

View file

@ -23,6 +23,8 @@ import shutil
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
# not checking because of daisy chain to file module
check_invalid_arguments = False,
argument_spec = dict( argument_spec = dict(
src=dict(required=True), src=dict(required=True),
dest=dict(required=True) dest=dict(required=True)

View file

@ -212,7 +212,8 @@ def rmtree_error(func, path, exc_info):
def main(): def main():
global module global module
module = AnsibleFileModule( module = AnsibleModule(
check_invalid_arguments = False,
argument_spec = dict( argument_spec = dict(
state = dict(choices=['file','directory','link','absent'], default='file'), state = dict(choices=['file','directory','link','absent'], default='file'),
path = dict(aliases=['dest', 'name'], required=True), path = dict(aliases=['dest', 'name'], required=True),
@ -348,12 +349,5 @@ def main():
# this is magic, see lib/ansible/module_common.py # this is magic, see lib/ansible/module_common.py
#<<INCLUDE_ANSIBLE_MODULE_COMMON>> #<<INCLUDE_ANSIBLE_MODULE_COMMON>>
class AnsibleFileModule(AnsibleModule):
def _check_invalid_arguments(self):
# needed to support daisy chaining
pass
main() main()

View file

@ -128,6 +128,8 @@ def main():
module.fail_json(msg="urlparse is not installed") module.fail_json(msg="urlparse is not installed")
module = AnsibleModule( module = AnsibleModule(
# not checking because of daisy chain to file module
check_invalid_arguments = False,
argument_spec = dict( argument_spec = dict(
url = dict(required=True), url = dict(required=True),
dest = dict(required=True), dest = dict(required=True),