Try this:
    required_if = [
        ('action', 'add_package_to_content_view', ['packagename']),
    ]
    module = AnsibleModule(argument_spec=argument_spec,
                           required_if=required_if)




On Friday, September 13, 2019 at 4:58:19 PM UTC-4, Joe Rosiak wrote:
>
> Hi all,
>
> I am attempting to create a custom module and when I am defining the 
> custom parameters.
>
> Example.  I have this section defined and I only want to packagename 
> required if someone passes "add_package_to_content_view" as an action.
>
>   fields = {
>         "organization": {"required": True, "type": "str"},
>         "satelliteurl": {"required": True, "type": "str"},
>         "cvname": {"required": True, "type": "str"},
>         "action": {"required": True, "type": "str", "choices": 
> ["create_standard_content_view","create_custom_content_view","add_repo_to_content_view","add_package_to_content_view"]},
>         "packagename": {"required": False, "type": "str"}
>   }
>
>
> Is there a way to mark certain params as required in this above example or 
> do I have to define the condition after everything is set?
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-devel/85e7b0af-791e-43e9-bb51-0f923287c2f4%40googlegroups.com.

Reply via email to