1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# https://docs.pleroma.social/backend/installation/otp_en/
---
- hosts: ramble-hard
  become: true
  tasks:

    # arch="$(uname -m)";if [ "$arch" = "x86_64" ];then arch="amd64";elif [ "$arch" = "armv7l" ];then arch="arm";elif [ "$arch" = "aarch64" ];then arch="arm64";else echo "Unsupported arch: $arch">&2;fi;if getconf GNU_LIBC_VERSION>/dev/null;then libc_postfix="";elif [ "$(ldd 2>&1|head -c 9)" = "musl libc" ];then libc_postfix="-musl";elif [ "$(find /lib/libc.musl*|wc -l)" ];then libc_postfix="-musl";else echo "Unsupported libc">&2;fi;echo "$arch$libc_postfix" # noqa yaml[line-length]
    - shell: |
        arch="$(uname -m)"
        if [ "$arch" = "x86_64" ]; then
          arch="amd64";
        elif [ "$arch" = "armv7l" ]; then
          arch="arm";
        elif [ "$arch" = "aarch64" ]; then
          arch="arm64";
        else
          echo "Unsupported arch: $arch">&2;
        fi;
        if getconf GNU_LIBC_VERSION>/dev/null; then
          libc_postfix="";
        elif [ "$(ldd 2>&1|head -c 9)" = "musl libc" ]; then
          libc_postfix="-musl";
        elif [ "$(find /lib/libc.musl*|wc -l)" ]; then
          libc_postfix="-musl";
        else
          echo "Unsupported libc">&2;
        fi;
        echo "$arch$libc_postfix"
      register: arch_result
    - set_fact:
        pleroma_flavour: "{{ arch_result.stdout | trim }}"

    - apt:
        update_cache: true

    # apt install curl unzip libncurses5 postgresql postgresql-contrib nginx certbot libmagic-dev
    # apt install imagemagick ffmpeg libimage-exiftool-perl
    # apt install postgresql-11-rum
    - package:
        name:
          - curl
          - unzip
          - libncurses5
          - postgresql
          - postgresql-contrib
          - nginx
          - certbot
          - libmagic-dev
          - imagemagick
          - ffmpeg
          - libimage-exiftool-perl
          # - postgresql-13-rum
      notify:
        - Restart postgres

    # Create a Pleroma user
    # adduser --system --shell  /bin/false --home /opt/pleroma pleroma
    - user:
        name: pleroma
        home: /opt/pleroma
        shell: /bin/false
        system: true

    # Clone the release build into a temporary directory and unpack it
    # su pleroma -s $SHELL -lc "
    # curl 'https://git.pleroma.social/api/v4/projects/2/jobs/artifacts/stable/download?job=$FLAVOUR' -o /tmp/pleroma.zip
    # unzip /tmp/pleroma.zip -d /tmp/
    # "
    - get_url:
        url: https://git.pleroma.social/api/v4/projects/2/jobs/artifacts/stable/download?job={{ pleroma_flavour }}
        dest: /tmp/pleroma.zip
    - command: unzip /tmp/pleroma.zip -d /tmp/

    # Move the release to the home directory and delete temporary files
    # su pleroma -s $SHELL -lc "
    # mv /tmp/release/* /opt/pleroma
    # rmdir /tmp/release
    # rm /tmp/pleroma.zip
    # "
    - copy:
        src: /tmp/release/
        dest: /opt/pleroma/
        remote_src: true
        owner: pleroma
    - file:
        path: "{{ item }}"
        state: absent
      loop:
        - /tmp/release
        - /tmp/pleroma.zip

    # Create uploads directory and set proper permissions (skip if planning to use a remote uploader)
    # Note: It does not have to be `/var/lib/pleroma/uploads`, the config generator will ask about the upload directory later
    # mkdir -p /var/lib/pleroma/uploads
    # chown -R pleroma /var/lib/pleroma

    # Create custom public files directory (custom emojis, frontend bundle overrides, robots.txt, etc.)
    # Note: It does not have to be `/var/lib/pleroma/static`, the config generator will ask about the custom public files directory later
    # mkdir -p /var/lib/pleroma/static
    # chown -R pleroma /var/lib/pleroma

    # Create a config directory
    # mkdir -p /etc/pleroma
    # chown -R pleroma /etc/pleroma
    - file:
        path: "{{ item }}"
        state: directory
        owner: pleroma
      loop:
        - /var/lib/pleroma/uploads
        - /var/lib/pleroma/static
        - /etc/pleroma

  handlers:
    - name: Restart postgres
      service:
        name: postgresql
        state: restarted