Nested arguments for Ansible Module -


i developing ansible module. possible specify set of arguments required when 1 argument has value?

for example, if module has 'state' argument can either 'present' or 'absent', possible require additional set of arguments 'type', 'path' when state=present?

module_args = dict(    name=dict(type='str', required=true),    type=dict(type='str', required=false),    path=dict(type='str', required=false),    state=dict(type='str', required=false, choices=["present","absent"] }  module = ansiblemodule(    argument_spec=module_args,    supports_check_mode=true )  name = module.params["name"] script_type = module.param["type"] path = module.param["path"] state = module.state["state"] 

as far know there no such ability in current ansible 2.3.

there required_together option ansiblemodule class define parameters should supplied (but there no condition on value):

 required_together = [['s3_key', 's3_bucket'],                      ['vpc_subnet_ids', 'vpc_security_group_ids']] 

so should manual checks that.


Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -