# SPDX-License-Identifier: MIT
---
# Put the tasks for your role here.
- name: Perform platform/version specific tasks
  include_tasks: "{{ lookup('first_found', __pam_pwd_ff_params) }}"
  vars:
    __pam_pwd_ff_params:
      files:
        - "{{ ansible_facts['distribution'] ~ '_' ~
              ansible_facts['distribution_version'] }}.yml"
        - "{{ ansible_facts['distribution'] ~ '_' ~
              ansible_facts['distribution_major_version'] }}.yml"
        - "{{ ansible_facts['distribution'] }}.yml"
        - "{{ ansible_facts['os_family'] }}.yml"
        - "default.yml"
      paths:
        - "{{ role_path }}/tasks/setup"

- name: Set password quality
  blockinfile:
    path: /etc/security/pwquality.conf
    insertafter: EOF
    marker: "# {mark} ANSIBLE MANAGED BLOCK"
    block: |
      minlen = {{ pam_pwd_minlen }}
      dcredit = {{ pam_pwd_dcredit }}
      ucredit = {{ pam_pwd_ucredit }}
      lcredit = {{ pam_pwd_lcredit }}
      ocredit = {{ pam_pwd_ocredit }}
      minclass = {{ pam_pwd_minclass }}
    backup: true
