2024-03-25 17:55:37 +01:00
|
|
|
---
|
|
|
|
- name: Identify gitea users
|
|
|
|
ansible.builtin.command: su - {{ gitea_user }} -c '{{ gitea_full_executable_path }} -c {{ gitea_configuration_path }}/gitea.ini admin user list'
|
|
|
|
become: true
|
2024-04-07 13:40:10 +02:00
|
|
|
register: _giteausers
|
2024-03-25 17:55:37 +01:00
|
|
|
changed_when: false
|
|
|
|
|
|
|
|
- name: Use gitea cli to create user
|
|
|
|
become: true
|
|
|
|
ansible.builtin.command: |
|
|
|
|
su - {{ gitea_user }} -c
|
|
|
|
'{{ gitea_full_executable_path }} -c {{ gitea_configuration_path }}/gitea.ini
|
|
|
|
admin user create --username "{{ item.name }}"
|
|
|
|
--password "{{ item.password }}" --email "{{ item.email }}"
|
|
|
|
--must-change-password={{ item.must_change_password }} --admin={{ item.admin }}'
|
|
|
|
register: _gitearesult
|
|
|
|
failed_when:
|
|
|
|
- '"successfully created" not in gitearesult.stdout'
|
|
|
|
changed_when:
|
|
|
|
- '"successfully created!" in gitearesult.stdout'
|
2024-04-07 13:40:10 +02:00
|
|
|
when: "_giteausers is defined and item.name not in _giteausers"
|
2024-03-25 17:55:37 +01:00
|
|
|
loop: "{{ gitea_users }}"
|