mirror of
https://github.com/roles-ansible/ansible_role_gitea.git
synced 2024-08-16 11:39:50 +02:00
Merge pull request #157 from roles-ansible/user
Create local users in gitea/forgejo
This commit is contained in:
commit
bf89f5b68c
7 changed files with 43 additions and 7 deletions
|
@ -25,6 +25,15 @@ gitea_configuration_path: '/etc/gitea'
|
||||||
gitea_shell: '/bin/false'
|
gitea_shell: '/bin/false'
|
||||||
gitea_systemd_cap_net_bind_service: false
|
gitea_systemd_cap_net_bind_service: false
|
||||||
|
|
||||||
|
# optional users on gitea instance
|
||||||
|
gitea_users: []
|
||||||
|
# example of entry
|
||||||
|
# - name: johndoe
|
||||||
|
# password: verysecret
|
||||||
|
# email: "johndoe@example.com"
|
||||||
|
# admin: false
|
||||||
|
# must_change_password: true
|
||||||
|
|
||||||
# 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
|
||||||
gitea_app_name: 'Gitea'
|
gitea_app_name: 'Gitea'
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
dest: "{{ gitea_configuration_path }}/gitea.ini"
|
dest: "{{ gitea_configuration_path }}/gitea.ini"
|
||||||
owner: "{{ gitea_user }}"
|
owner: "{{ gitea_user }}"
|
||||||
group: "{{ gitea_group }}"
|
group: "{{ gitea_group }}"
|
||||||
mode: 0600
|
mode: '0640'
|
||||||
notify: "Restart gitea"
|
notify: "Restart gitea"
|
||||||
|
|
||||||
- name: "Service gitea"
|
- name: "Service gitea"
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
dest: "{{ gitea_custom }}/templates/custom/extra_links_footer.tmpl"
|
dest: "{{ gitea_custom }}/templates/custom/extra_links_footer.tmpl"
|
||||||
owner: "{{ gitea_user }}"
|
owner: "{{ gitea_user }}"
|
||||||
group: "{{ gitea_group }}"
|
group: "{{ gitea_group }}"
|
||||||
mode: '0644'
|
mode: '0640'
|
||||||
failed_when: false
|
failed_when: false
|
||||||
tags: skip_ansible_lint
|
tags: skip_ansible_lint
|
||||||
notify: "Restart gitea"
|
notify: "Restart gitea"
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
dest: "{{ gitea_custom }}/public/assets/img/logo.svg"
|
dest: "{{ gitea_custom }}/public/assets/img/logo.svg"
|
||||||
owner: "{{ gitea_user }}"
|
owner: "{{ gitea_user }}"
|
||||||
group: "{{ gitea_group }}"
|
group: "{{ gitea_group }}"
|
||||||
mode: "0644"
|
mode: "0640"
|
||||||
tags: skip_ansible_lint
|
tags: skip_ansible_lint
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
dest: "{{ gitea_custom }}/public/assets/img/logo.png"
|
dest: "{{ gitea_custom }}/public/assets/img/logo.png"
|
||||||
owner: "{{ gitea_user }}"
|
owner: "{{ gitea_user }}"
|
||||||
group: "{{ gitea_group }}"
|
group: "{{ gitea_group }}"
|
||||||
mode: "0644"
|
mode: "0640"
|
||||||
tags: skip_ansible_lint
|
tags: skip_ansible_lint
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
dest: "{{ gitea_custom }}/public/assets/img/favicon.png"
|
dest: "{{ gitea_custom }}/public/assets/img/favicon.png"
|
||||||
owner: "{{ gitea_user }}"
|
owner: "{{ gitea_user }}"
|
||||||
group: "{{ gitea_group }}"
|
group: "{{ gitea_group }}"
|
||||||
mode: "0644"
|
mode: "0640"
|
||||||
tags: skip_ansible_lint
|
tags: skip_ansible_lint
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
|
||||||
|
@ -52,6 +52,6 @@
|
||||||
dest: "{{ gitea_custom }}/public/assets/img/apple-touch-icon.png"
|
dest: "{{ gitea_custom }}/public/assets/img/apple-touch-icon.png"
|
||||||
owner: "{{ gitea_user }}"
|
owner: "{{ gitea_user }}"
|
||||||
group: "{{ gitea_group }}"
|
group: "{{ gitea_group }}"
|
||||||
mode: "0644"
|
mode: "0640"
|
||||||
tags: skip_ansible_lint
|
tags: skip_ansible_lint
|
||||||
failed_when: false
|
failed_when: false
|
||||||
|
|
22
tasks/local_git_users.yml
Normal file
22
tasks/local_git_users.yml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
---
|
||||||
|
- 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
|
||||||
|
register: _giteusers
|
||||||
|
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'
|
||||||
|
when: "_giteusers is defined and item.name in _giteusers"
|
||||||
|
loop: "{{ gitea_users }}"
|
|
@ -79,3 +79,8 @@
|
||||||
ansible.builtin.include_tasks:
|
ansible.builtin.include_tasks:
|
||||||
file: "customize_public_files.yml"
|
file: "customize_public_files.yml"
|
||||||
when: gitea_customize_files | bool or gitea_custom_themes is defined
|
when: gitea_customize_files | bool or gitea_custom_themes is defined
|
||||||
|
|
||||||
|
- name: Optionally create local Users on git instance
|
||||||
|
ansible.builtin.include_tasks:
|
||||||
|
file: 'local_git_users.yml'
|
||||||
|
when: gitea_users | length > 0
|
||||||
|
|
|
@ -63,5 +63,5 @@ transfer_custom_footer:
|
||||||
- 'files/gitea_footer/extra_links_footer.tmpl'
|
- 'files/gitea_footer/extra_links_footer.tmpl'
|
||||||
- 'files/extra_links_footer.tmpl'
|
- 'files/extra_links_footer.tmpl'
|
||||||
|
|
||||||
playbook_version_number: 57
|
playbook_version_number: 58
|
||||||
playbook_version_path: 'do1jlr.gitea.version'
|
playbook_version_path: 'do1jlr.gitea.version'
|
||||||
|
|
Loading…
Reference in a new issue