0

I am trying to take a variable that is saved as a password from an Ansible Tower Survey and then verify its complexity.

The password needs to be at least 17 characters and contain uppercase, lowercase, number, and special character.

Does anyone know how to do this?

U880D
  • 8,601
  • 6
  • 24
  • 40
Cade T
  • 1

1 Answers1

0

Since I have the same use case, to filter data I've started with first with assert module, Jinja2 filter length.

---
- hosts: localhost
  become: false
  gather_facts: false

  vars:

    NEW_PASSWORD: "12345678901234567"

  tasks:

  - name : Check if password is long enough
    assert:
      that:
        - NEW_PASSWORD | length > 16
      success_msg: "Passed."
      fail_msg: "New password is too short!"
      quiet: true

It is also possible to use regex with assert operator which can be filled within the in the comment mentioned regex to validate password strength.

Further Q&A

U880D
  • 8,601
  • 6
  • 24
  • 40