How can I check that my password matches a regex

Viewed 32

With Ansible I am trying to verify that my password matches a regex

I have 2 variables in my group_vars: password: pa$sw0rd
regex: "^[\\\\S]{5,30}$"

(Notice the 4 \ because this regex is used in an application where I need to escape 2 \ )

And I wanted to do something like this:

- name: check password
  fail:
    msg:"password doesn't match regex"
  when: password|match(regex)

But I can't find the correct way to write this and what match or regex_search return

Thank you for your help :)

0 Answers
Related