# - name: get some vars
#   ansible.builtin.set_fact:
#     pla_bind_dn: "{{ lookup( 'keepass', '{{ group_names[0] }}/{{ inventory_hostname }})pla_dn', 'username' ) }}"
#     pla_bin_pwd:  "{{ lookup( 'keepass', '{{ group_names[0] }}/{{ inventory_hostname }})pla_dn', 'password' ) }}"
#   when: pla_bind_dn is not defined
#   tags: always

- name: get archive
  ansible.builtin.get_url:
      url: https://github.com/leenooks/phpLDAPadmin/archive/{{ pla_version }}.tar.gz
      dest: /tmp/pla_{{pla_version }}.gz

- ansible.builtin.file:
    path: "{{ pla_install_dir }}"
    state: directory

- ansible.builtin.unarchive:
    dest: /{{ pla_install_dir }}
    src:  /tmp/pla_{{pla_version }}.gz
    remote_src: true
- ansible.builtin.file:
    src: /{{ pla_install_dir }}/phpLDAPadmin-{{ pla_version }}
    state: link
    dest: /{{ pla_install_dir }}/pla

- name: "[pla] - configure"
  vars:
    bigrandomstring: "{{ lookup('password', '/dev/null chars=ascii_letters,digit length=128', seed=inventory_hostname) | lower }}"
  ansible.builtin.template:
    src: pla_config.php
    dest: /{{ pla_install_dir }}/pla/config/config.php

