2023-10-20 23:48:14 +00:00
|
|
|
---
|
|
|
|
# tasks file for gotosocial
|
|
|
|
- name: Create gotosocial user
|
|
|
|
ansible.builtin.user:
|
|
|
|
name: "{{ gotosocial_user }}"
|
|
|
|
system: true
|
|
|
|
state: present
|
|
|
|
|
|
|
|
- name: Create gotosocial directories
|
|
|
|
ansible.builtin.file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
owner: "{{ gotosocial_user }}"
|
2023-10-22 14:18:54 +00:00
|
|
|
group: "{{ gotosocial_group | default(gotosocial_user) }}"
|
2023-10-20 23:48:14 +00:00
|
|
|
mode: "0750"
|
|
|
|
state: directory
|
|
|
|
loop:
|
|
|
|
- "{{ gotosocial_base_dir }}"
|
|
|
|
- "{{ gotosocial_base_dir }}/storage"
|
|
|
|
- "{{ gotosocial_base_dir }}/storage/certs"
|
|
|
|
|
2023-10-22 14:18:54 +00:00
|
|
|
- name: Download gotosocial release
|
2023-10-20 23:48:14 +00:00
|
|
|
ansible.builtin.get_url:
|
2023-10-22 14:18:54 +00:00
|
|
|
url: "{{ gotosocial_release_url }}"
|
|
|
|
dest: "{{ gotosocial_base_dir }}/gotosocial_{{ gotosocial_version }}_linux_amd64.tar.gz"
|
2023-10-20 23:48:14 +00:00
|
|
|
owner: "{{ gotosocial_user }}"
|
2023-10-22 14:18:54 +00:00
|
|
|
group: "{{ gotosocial_group | default(gotosocial_user) }}"
|
|
|
|
mode: "0640"
|
2023-10-20 23:48:14 +00:00
|
|
|
force: false
|
2023-10-22 14:18:54 +00:00
|
|
|
retries: 3
|
|
|
|
delay: 3
|
2023-10-20 23:48:14 +00:00
|
|
|
register: gotosocial_tarball
|
2023-10-22 14:18:54 +00:00
|
|
|
until: gotosocial_tarball is not failed
|
2023-10-20 23:48:14 +00:00
|
|
|
|
|
|
|
- name: Unpack gotosocial binary
|
|
|
|
ansible.builtin.unarchive:
|
|
|
|
src: "{{ gotosocial_tarball['dest'] }}"
|
|
|
|
dest: "{{ gotosocial_base_dir }}/"
|
|
|
|
remote_src: true
|
|
|
|
owner: "{{ gotosocial_user }}"
|
2023-10-22 14:18:54 +00:00
|
|
|
group: "{{ gotosocial_group | default(gotosocial_user) }}"
|
2023-10-20 23:48:14 +00:00
|
|
|
mode: "0750"
|
|
|
|
keep_newer: true
|
|
|
|
notify: Restart gotosocial
|
|
|
|
|
|
|
|
- name: Template gotosocial configuration
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: config.yaml.j2
|
2023-10-22 14:18:54 +00:00
|
|
|
dest: "{{ gotosocial_base_dir }}/config.yaml"
|
2023-10-20 23:48:14 +00:00
|
|
|
owner: "{{ gotosocial_user }}"
|
2023-10-22 14:18:54 +00:00
|
|
|
group: "{{ gotosocial_group | default(gotosocial_user) }}"
|
2023-10-20 23:48:14 +00:00
|
|
|
mode: "0750"
|
2023-10-22 14:18:54 +00:00
|
|
|
notify: Restart gotosocial
|
2023-10-20 23:48:14 +00:00
|
|
|
|
|
|
|
- name: Template gotosocial systemd service
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: gotosocial.service.j2
|
|
|
|
dest: /etc/systemd/system/gotosocial.service
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0640"
|
2023-10-22 14:18:54 +00:00
|
|
|
notify: Restart gotosocial
|
2023-10-20 23:48:14 +00:00
|
|
|
|
|
|
|
- name: Enable and start gotosocial systemd service
|
|
|
|
ansible.builtin.systemd:
|
|
|
|
name: gotosocial.service
|
|
|
|
state: started
|
|
|
|
enabled: true
|
2023-10-23 16:54:21 +00:00
|
|
|
|
|
|
|
- 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 }}"
|