author | Luke Hoersten <luke@hoersten.org> |
Sun, 03 May 2020 12:57:47 -0500 | |
changeset 17 | 41034ea52480 |
parent 2 | 2556522a2a45 |
child 18 | ea20908c3904 |
permissions | -rw-r--r-- |
1
fd351734f007
Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
1 |
--- |
fd351734f007
Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
2 |
|
17 | 3 |
- name: add writefreely user |
4 |
become: yes |
|
5 |
user: name="{{writefreely_user}}" |
|
6 |
||
7 |
- name: unarchive writefreely |
|
8 |
become: yes |
|
9 |
unarchive: |
|
10 |
remote_src: yes |
|
11 |
src: "{{writefreely_tar}}" |
|
12 |
dest: "/tmp/" |
|
13 |
creates: "/tmp/writefreely/" |
|
14 |
owner: "root" |
|
15 |
group: "root" |
|
16 |
||
17 |
- name: install writefreely binary |
|
18 |
become: yes |
|
19 |
command: "install -m 0755 -o {{writefreely_user}} -g {{writefreely_user}} -t /usr/local/bin /tmp/writefreely/writefreely" |
|
20 |
changed_when: false |
|
21 |
||
22 |
- name: create root dir |
|
23 |
become: yes |
|
24 |
file: |
|
25 |
path: "{{writefreely_dir}}" |
|
26 |
state: "directory" |
|
27 |
owner: "{{writefreely_user}}" |
|
28 |
group: "{{writefreely_user}}" |
|
29 |
mode: "0755" |
|
30 |
notify: reload service |
|
31 |
||
32 |
- name: create instance dir |
|
33 |
become: yes |
|
34 |
file: |
|
35 |
path: "{{writefreely_dir}}/{{writefreely_instance}}" |
|
36 |
state: "directory" |
|
37 |
owner: "{{writefreely_user}}" |
|
38 |
group: "{{writefreely_user}}" |
|
39 |
mode: "0755" |
|
40 |
notify: reload service |
|
41 |
||
42 |
- name: install static content |
|
43 |
become: yes |
|
44 |
copy: |
|
45 |
src: "/tmp/writefreely/" |
|
46 |
remote_src: yes |
|
47 |
dest: "{{writefreely_dir}}/{{writefreely_instance}}/" |
|
48 |
owner: "{{writefreely_user}}" |
|
49 |
group: "{{writefreely_user}}" |
|
50 |
mode: "0755" |
|
1
fd351734f007
Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
51 |
|
17 | 52 |
- name: configure |
53 |
become: yes |
|
54 |
template: |
|
55 |
src: "config.ini.j2" |
|
56 |
dest: "{{writefreely_dir}}/{{writefreely_instance}}/config.ini" |
|
57 |
mode: "0644" |
|
58 |
owner: "{{writefreely_user}}" |
|
59 |
group: "{{writefreely_user}}" |
|
60 |
notify: reload service |
|
61 |
||
62 |
- name: generate keys |
|
63 |
become: yes |
|
64 |
become_user: "{{writefreely_user}}" |
|
65 |
command: "writefreely keys gen" |
|
66 |
args: |
|
67 |
chdir: "{{writefreely_dir}}/{{writefreely_instance}}/" |
|
68 |
||
69 |
- name: check if db exists |
|
70 |
stat: |
|
71 |
path: "{{writefreely_dir}}/{{writefreely_instance}}/writefreely.db" |
|
72 |
register: db_file |
|
73 |
||
74 |
- name: create db |
|
75 |
become: yes |
|
76 |
become_user: "{{writefreely_user}}" |
|
77 |
command: "writefreely db init" |
|
78 |
args: |
|
79 |
chdir: "{{writefreely_dir}}/{{writefreely_instance}}/" |
|
80 |
when: not db_file.stat.exists |
|
81 |
||
82 |
- name: create admin |
|
83 |
become: yes |
|
84 |
become_user: "{{writefreely_user}}" |
|
85 |
command: "writefreely --create-admin admin:admin" |
|
86 |
args: |
|
87 |
chdir: "{{writefreely_dir}}/{{writefreely_instance}}/" |
|
88 |
when: not db_file.stat.exists |
|
89 |
||
90 |
- name: migrate db |
|
91 |
become: yes |
|
92 |
become_user: "{{writefreely_user}}" |
|
93 |
command: "writefreely db migrate" |
|
94 |
args: |
|
95 |
chdir: "{{writefreely_dir}}/{{writefreely_instance}}/" |
|
96 |
when: db_file.stat.exists |
|
97 |
||
98 |
- name: install systemd service |
|
99 |
become: yes |
|
100 |
template: |
|
101 |
src: "[email protected]" |
|
102 |
dest: "/lib/systemd/system/[email protected]" |
|
103 |
||
104 |
- name: ensure service is started |
|
105 |
become: yes |
|
106 |
systemd: name="writefreely@{{writefreely_instance}}.service" enabled="yes" state="started" |