Specify types in argument_spec instead of code so that checking type vs default value does not trigger

This commit is contained in:
Toshio Kuratomi 2016-02-28 22:30:39 -08:00 committed by Matt Clay
parent 776d079e6b
commit 47e9a06784

View file

@ -332,11 +332,11 @@ def main():
module = AnsibleModule(
argument_spec = dict(
host=dict(default='127.0.0.1'),
timeout=dict(default=300),
connect_timeout=dict(default=5),
delay=dict(default=0),
port=dict(default=None),
path=dict(default=None),
timeout=dict(default=300, type='int'),
connect_timeout=dict(default=5, type='int'),
delay=dict(default=0, type='int'),
port=dict(default=None, type='int'),
path=dict(default=None, type='path'),
search_regex=dict(default=None),
state=dict(default='started', choices=['started', 'stopped', 'present', 'absent', 'drained']),
exclude_hosts=dict(default=None, type='list')
@ -346,13 +346,10 @@ def main():
params = module.params
host = params['host']
timeout = int(params['timeout'])
connect_timeout = int(params['connect_timeout'])
delay = int(params['delay'])
if params['port']:
port = int(params['port'])
else:
port = None
timeout = params['timeout']
connect_timeout = params['connect_timeout']
delay = params['delay']
port = params['port']
state = params['state']
path = params['path']
search_regex = params['search_regex']