I would do something like this -
---
- name: Prompt and validation demo
hosts: localhost
gather_facts: false
vars_prompt:
- name: release_version
prompt: "What is the release version (Allowed values a-z, 0-9, hyphen)?"
private: no
pre_tasks:
- name: Make sure version is ok
fail:
msg: >-
Release version is not formatted correctly.
when: not release_version is regex('^[a-z0-9\-]+$')
run_once: true
On Tue, May 31, 2022 at 11:36 PM Dick Visser <[email protected]> wrote:
> How is the user input being supplied to the playbook?
>
> On 2022-05-31 (Tue) 16:27, Shivani Arora wrote:
> > Hi All,
> >
> > I'm creating a playbook which validates user input.
> >
> > Input string would be something like : "cluster-test-1"
> >
> > I want to assert that input has only lowercase, digits or hypen. (No
> > other special character is allowed)
> >
> > Please suggest how I can achieve this, so that the playbook exits if
> > input validation is failed.
> >
> > Thanks,
> > Shivani
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Ansible Project" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> > an email to [email protected]
> > <mailto:[email protected]>.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/ansible-project/05f9b75c-7d97-4f50-b595-2b55e7dfe270n%40googlegroups.com
> > <
> https://groups.google.com/d/msgid/ansible-project/05f9b75c-7d97-4f50-b595-2b55e7dfe270n%40googlegroups.com?utm_medium=email&utm_source=footer
> >.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/c7bc76a8-fef2-700f-4c8f-1b6242de9792%40gmail.com
> .
>
--
Thanks,
Abhijeet Kasurde
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAFwWkHp9E3RiEd7uUug6Hc1yVhE1R-HRp5NXUh0JNr9CaaiBYA%40mail.gmail.com.