blob: 41205c1f96f3139a9bd0c6969e7b1a8a15b53a16 (
plain)
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
119
120
121
122
123
124
125
|
- name: install packages
dnf:
name: '{{ mastodon_packages }}'
state: present
- name: add local user
user:
name: '{{ mastodon_user }}'
system: yes
home: '{{ mastodon_home }}'
shell: /sbin/nologin
create_home: no
- import_tasks: freeipa.yml
- name: create home directory
file:
path: '{{ mastodon_home }}'
owner: '{{ mastodon_user }}'
group: '{{ mastodon_user }}'
mode: 0755
state: directory
- name: clone repo
git:
repo: '{{ mastodon_git_repo }}'
dest: '{{ mastodon_install_dir }}'
version: 'v{{ mastodon_version }}'
update: yes
force: yes
become: yes
become_user: '{{ mastodon_user }}'
register: mastodon_git
- name: set selinux context on writeable directories
sefcontext:
target: '{{ mastodon_webroot }}(/.*)?'
setype: httpd_sys_content_t
state: present
register: mastodon_webroot_sefcontext
tags: selinux
- name: apply selinux context to writeable directories
command: 'restorecon -R {{ mastodon_webroot }}'
when: mastodon_webroot_sefcontext.changed
tags: selinux
- name: build mastodon
command:
chdir: '{{ mastodon_install_dir }}'
cmd: '{{ item }}'
loop:
- "bundle config deployment 'true'"
- "bundle config without 'development test'"
- 'bundle install -j{{ ansible_processor_vcpus }}'
- yarn install --pure-lockfile
become: yes
become_user: '{{ mastodon_user }}'
notify: restart mastodon
when: mastodon_git.changed
- name: generate .env.production
template:
src: '{{ mastodon_install_dir[1:] }}/.env.production.j2'
dest: '{{ mastodon_install_dir }}/.env.production'
owner: '{{ mastodon_user }}'
group: '{{ mastodon_user }}'
mode: 0600
notify: restart mastodon
- import_tasks: database.yml
- name: precompile assets
command:
chdir: '{{ mastodon_install_dir }}'
cmd: '{{ item }}'
loop:
- 'bundle exec rake db:migrate'
- 'bundle exec rake assets:precompile'
environment:
NODE_OPTIONS: --openssl-legacy-provider
RAILS_ENV: production
become: yes
become_user: '{{ mastodon_user }}'
notify: restart mastodon
when: mastodon_git.changed
- name: create systemd units
template:
src: etc/systemd/system/{{ item }}.j2
dest: /etc/systemd/system/{{ item }}
loop:
- mastodon-sidekiq.service
- mastodon-streaming.service
- mastodon-web.service
- mastodon-cleanup.service
- mastodon-cleanup.timer
register: mastodon_systemd_units
notify: restart mastodon
- name: reload systemd daemons
systemd:
daemon_reload: yes
when: mastodon_systemd_units.changed
- name: start mastodon
systemd:
name: '{{ item }}'
enabled: yes
state: started
loop:
- mastodon-sidekiq.service
- mastodon-streaming.service
- mastodon-web.service
- mastodon-cleanup.timer
- name: configure registrations
command:
chdir: '{{ mastodon_install_dir }}'
cmd: './bin/tootctl settings registrations {{ mastodon_registrations }}'
environment:
RAILS_ENV: production
become: yes
become_user: '{{ mastodon_user }}'
changed_when: no
|