Add creation of admin users

This commit is contained in:
CherryKitten 2023-10-23 18:54:21 +02:00
parent 50924deae1
commit a5561ea227
Signed by: sammy
GPG key ID: 0B696A86A853E955
2 changed files with 32 additions and 2 deletions

View file

@ -5,11 +5,18 @@ gotosocial_base_dir: /opt/gotosocial
# gotosocial_hostname: gts.example.com
gotosocial_version: "0.12.0-rc2"
gotosocial_release_url: https://github.com/superseriousbusiness/gotosocial/releases/download/v{{ gotosocial_version }}/gotosocial_{{ gotosocial_version }}_linux_amd64.tar.gz
gotosocial_version: "0.12.0"
gotosocial_release_url: |
https://github.com/superseriousbusiness/gotosocial/releases/download/v{{ gotosocial_version }}/gotosocial_{{ gotosocial_version }}_linux_amd64.tar.gz
gotosocial_letsencrypt_enabled: false
# gotosocial_letsencrypt_email: admin@example.com # required if letsencrypt is enabled
#
gotosocial_http_port: 80
gotosocial_https_port: 443
gotosocial_admin_users: []
# gotosocial_admin_users:
# - name: username
# - email: example@example.com
# - password: SECRET

View file

@ -65,3 +65,26 @@
name: gotosocial.service
state: started
enabled: true
- name: Create gotosocial users
ansible.builtin.shell: |
{{ gotosocial_base_dir }}/gotosocial --config-path {{ gotosocial_base_dir }}/config.yaml \
admin account create --username {{ user.name }} --email {{ user.email }} --password {{ user.password }} > /dev/null
loop: "{{ gotosocial_admin_users | list }}"
register: gotosocial_user_creation
changed_when: gotosocial_user_creation.rc == 0
failed_when: gotosocial_user_creation.rc != 0 and not 'is already in use' in gotosocial_user_creation.stderr
loop_control:
loop_var: user
label: "{{ user.name }}"
- name: Set admin rights for gotosocial admin users
ansible.builtin.shell: |
{{ gotosocial_base_dir }}/gotosocial --config-path {{ gotosocial_base_dir }}/config.yaml \
admin account promote --username {{ user.name }}
loop: "{{ gotosocial_admin_users | list }}"
register: gotosocial_admin_promotion
changed_when: gotosocial_admin_promotion.rc == 0
loop_control:
loop_var: user
label: "{{ user.name }}"