mirror of
https://github.com/roles-ansible/ansible_role_gitea.git
synced 2024-08-16 11:39:50 +02:00
Create option to delete local git user
This commit is contained in:
parent
f5aaa880be
commit
9de97250c6
3 changed files with 36 additions and 10 deletions
|
@ -33,6 +33,7 @@ gitea_users: []
|
||||||
# email: "johndoe@example.com"
|
# email: "johndoe@example.com"
|
||||||
# admin: false
|
# admin: false
|
||||||
# must_change_password: true
|
# must_change_password: true
|
||||||
|
# state: present
|
||||||
|
|
||||||
# Overall (DEFAULT)
|
# Overall (DEFAULT)
|
||||||
# -> https://docs.gitea.io/en-us/config-cheat-sheet/#overall-default
|
# -> https://docs.gitea.io/en-us/config-cheat-sheet/#overall-default
|
||||||
|
|
|
@ -1,4 +1,24 @@
|
||||||
---
|
---
|
||||||
|
- name: "Create config and data directory"
|
||||||
|
become: true
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: directory
|
||||||
|
owner: "{{ gitea_user }}"
|
||||||
|
group: "{{ gitea_group }}"
|
||||||
|
mode: "u=rwX,g=rX"
|
||||||
|
recurse: true
|
||||||
|
loop:
|
||||||
|
- "{{ gitea_user_home }}"
|
||||||
|
- "{{ gitea_home }}"
|
||||||
|
- "{{ gitea_home }}/data"
|
||||||
|
- "{{ gitea_custom }}"
|
||||||
|
- "{{ gitea_custom }}/https"
|
||||||
|
- "{{ gitea_custom }}/mailer"
|
||||||
|
- "{{ gitea_home }}/indexers"
|
||||||
|
- "{{ gitea_home }}/log"
|
||||||
|
- "{{ gitea_repository_root }}"
|
||||||
|
|
||||||
- name: "Create config and data directory"
|
- name: "Create config and data directory"
|
||||||
become: true
|
become: true
|
||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
|
@ -10,12 +30,3 @@
|
||||||
recurse: true
|
recurse: true
|
||||||
loop:
|
loop:
|
||||||
- "{{ gitea_configuration_path }}"
|
- "{{ gitea_configuration_path }}"
|
||||||
- "{{ gitea_user_home }}"
|
|
||||||
- "{{ gitea_home }}"
|
|
||||||
- "{{ gitea_home }}/data"
|
|
||||||
- "{{ gitea_custom }}"
|
|
||||||
- "{{ gitea_custom }}/https"
|
|
||||||
- "{{ gitea_custom }}/mailer"
|
|
||||||
- "{{ gitea_home }}/indexers"
|
|
||||||
- "{{ gitea_home }}/log"
|
|
||||||
- "{{ gitea_repository_root }}"
|
|
||||||
|
|
|
@ -18,5 +18,19 @@
|
||||||
- '"successfully created" not in _gitearesult.stdout'
|
- '"successfully created" not in _gitearesult.stdout'
|
||||||
changed_when:
|
changed_when:
|
||||||
- '"successfully created!" in _gitearesult.stdout'
|
- '"successfully created!" in _gitearesult.stdout'
|
||||||
when: "_giteausers is defined and item.name not in _giteausers.stdout"
|
when: "_giteausers is defined and item.name not in _giteausers.stdout and item.state | default('present') == 'present'"
|
||||||
|
loop: "{{ gitea_users }}"
|
||||||
|
|
||||||
|
- name: Use gitea cli to delete user
|
||||||
|
become: true
|
||||||
|
ansible.builtin.command: |
|
||||||
|
su - {{ gitea_user }} -c \
|
||||||
|
'{{ gitea_full_executable_path }} -c {{ gitea_configuration_path }}/gitea.ini \
|
||||||
|
admin user delete --username "{{ item.name }}"'
|
||||||
|
register: _giteadelresult
|
||||||
|
failed_when:
|
||||||
|
- '"error" in _giteadelresult.stdout'
|
||||||
|
changed_when:
|
||||||
|
"_giteausers is defined and item.name in _giteausers.stdout"
|
||||||
|
when: "_giteausers is defined and item.name in _giteausers.stdout and item.state | default('present') == 'absent'"
|
||||||
loop: "{{ gitea_users }}"
|
loop: "{{ gitea_users }}"
|
||||||
|
|
Loading…
Reference in a new issue