Different messages for different conditions in one assert

After quite some time, I am ready to share this plugin -

https://galaxy.ansible.com/ui/repo/published/capable/core212/content/action/validate_vars/

There is an issue with galaxy - so documentation is not properly rendered for plugins. I am sorry for that.

Main use case for this plugin is to validate variables, but there is a nice bonus - you can have asserts with it like so:

- capable.core212.validate_vars:
    any:
      type: any
      custom_validation:
        - condition: variable1 | int > 100
          error_message: "variable1 must be greater than 100."
        - condition: variable2 | int < 0
          error_message: "variable2 must be less than 0."

And even more, plugin supports mutually_exclusive, required_together, required_one_of, required_if, required_by but for ansible variables (not module arguments)

See Ansible is capable of many things - #19 by kks

1 Like