I want to create a Custom Module call API which will take
action
:get
orsearch
resource
:car
/truck
/plane
/ship
- optional parameters - dynamic parameter based on
action
andresource
For example if action
is get
and resource
is car
, then I want to add wheels
, doors
as module parameter.
module_args = {
'action': {'required': True, 'type': 'str', choice:['get','search']},
'resource': {'required': True, 'type': 'str', choice: ['car', 'truck', 'ship']},
}
module = AnsibleModule(argument_spec=module_args,
required_if('resource', 'car', ('wheels', 'doors'))
supports_check_mode=True
)
Is there a way to put required_if
on two options i.e if action == 'search' and resource =='car'
then use different set of arguments?