I want to write role about network configuration, in my role many variable exist that only accept IP value. so I want to check this constraint in role argument specification. but I do not know how to do it?
As I found, this specification accept only few types such as below
str
list
dict
bool
int
float
path
raw
jsonarg
json
bytes
bits
And I do not know, how to add new custom type (IP type) to above list?
Or maybe role argument specification can accept some regex validator, but I do not find anything about that. and after I read specification format, I think ansible does not provide any way to add argument regex validator, but I want to sure does not exist anyway.
What is standard way to role argument validation?
Roles parameters specification is a relatively new thing in Ansible, as per the documentation it was introduced in 2.11.
A common way to validate the parameters before that (or if you have more complex validation rules, like in your case) was to define a separate task file with assertions and include it as the first task to the role's entrypoint
main.yml: