---
#   Add user to 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: create gitea account and add user to organisations
# command: ./venv/bin/python3 pf_gitea_utils.py create -t "{{ apikey }}"             -f "{{ data['first_name'] }}"         -l "{{ data['given_name'] }}"        -u "{{ data['username'] }}" -p "{{ giteapw }}" -e "{{ data['user_mail'] }}@perfact.de"
  command: ./venv/bin/python3 pf_gitea_utils.py create -t "{{ vault_gitea_apikey }}" -f "{{ users[USERLOGIN].first_name }}" -l "{{ users[USERLOGIN].last_name }}" -u "{{ USERLOGIN }}" -p "{{ Git_Password }}" -e "{{ users[USERLOGIN].mail_address }}"
  #  "cmd": ["./venv/bin/python3", "pf_gitea_utils.py", "create", "-t", "APIKEY", "-f", "Anton", "-l", "Mustermann", "-u", "amustermann", "-p", "PASSWORD", "-e", "anton.mustermann@perfact.de"]
  args:
    chdir: /opt/perfact/custom/pf_git_utils
  # never run anywhere else:
  when: inventory_hostname == 'pf-git'
