--- # 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 }}" group: "{{ gotosocial_group | default(gotosocial_user) }}" mode: "0750" state: directory loop: - "{{ gotosocial_base_dir }}" - "{{ gotosocial_base_dir }}/storage" - "{{ gotosocial_base_dir }}/storage/certs" - name: Download gotosocial release ansible.builtin.get_url: url: "{{ gotosocial_release_url }}" dest: "{{ gotosocial_base_dir }}/gotosocial_{{ gotosocial_version }}_linux_amd64.tar.gz" owner: "{{ gotosocial_user }}" group: "{{ gotosocial_group | default(gotosocial_user) }}" mode: "0640" force: false retries: 3 delay: 3 register: gotosocial_tarball until: gotosocial_tarball is not failed - name: Unpack gotosocial binary ansible.builtin.unarchive: src: "{{ gotosocial_tarball['dest'] }}" dest: "{{ gotosocial_base_dir }}/" remote_src: true owner: "{{ gotosocial_user }}" group: "{{ gotosocial_group | default(gotosocial_user) }}" mode: "0750" keep_newer: true notify: Restart gotosocial - name: Template gotosocial configuration ansible.builtin.template: src: config.yaml.j2 dest: "{{ gotosocial_base_dir }}/config.yaml" owner: "{{ gotosocial_user }}" group: "{{ gotosocial_group | default(gotosocial_user) }}" mode: "0750" notify: Restart gotosocial - name: Template gotosocial systemd service ansible.builtin.template: src: gotosocial.service.j2 dest: /etc/systemd/system/gotosocial.service owner: root group: root mode: "0640" notify: Restart gotosocial - name: Enable and start gotosocial systemd service ansible.builtin.systemd: 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 }}"