---
#   Delete user from gitea
#   Unser info comes from datadir
#   vars:
#     USERLOGIN is given to playbook on commandline
#     vault_gitea_apikey comes from VAULTS internalit/vault_perfact_useradmin.yml
#     users[USERLOGIN].first_name
#     users[USERLOGIN].last_name
#     users[USERLOGIN].mail_address

- name: perfact_deluser - exit if USERLOGIN is not given on commandline
  meta: end_play
  run_once: true
  when: USERLOGIN is undefined
  # always execute
  check_mode: false

- name: delete gitea account and remove user from organisations
  ansible.builtin.command: ./venv/bin/python3 pf_gitea_utils.py remove -t "{{ vault_gitea_apikey }}" -u "{{ USERLOGIN }}"
  args:
    chdir: /opt/perfact/custom/pf_git_utils
  # never run anywhere else:
  when: inventory_hostname == 'pf-git'
