author | Luke Hoersten <luke@hoersten.org> |
Thu, 09 Jul 2020 19:57:16 -0500 | |
changeset 123 | e8d0308b94b2 |
parent 51 | 19fa7aa47bf1 |
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 |
|
18
ea20908c3904
Removed use of install command.
Luke Hoersten <luke@hoersten.org>
parents:
17
diff
changeset
|
19 |
copy: |
ea20908c3904
Removed use of install command.
Luke Hoersten <luke@hoersten.org>
parents:
17
diff
changeset
|
20 |
src: "/tmp/writefreely/writefreely" |
ea20908c3904
Removed use of install command.
Luke Hoersten <luke@hoersten.org>
parents:
17
diff
changeset
|
21 |
dest: "/usr/local/bin/" |
ea20908c3904
Removed use of install command.
Luke Hoersten <luke@hoersten.org>
parents:
17
diff
changeset
|
22 |
remote_src: yes |
ea20908c3904
Removed use of install command.
Luke Hoersten <luke@hoersten.org>
parents:
17
diff
changeset
|
23 |
owner: "{{writefreely_user}}" |
ea20908c3904
Removed use of install command.
Luke Hoersten <luke@hoersten.org>
parents:
17
diff
changeset
|
24 |
group: "{{writefreely_user}}" |
ea20908c3904
Removed use of install command.
Luke Hoersten <luke@hoersten.org>
parents:
17
diff
changeset
|
25 |
mode: "0755" |
26
b0e4ad2f4291
Fix writefreely role to be idempotent.
Luke Hoersten <luke@hoersten.org>
parents:
18
diff
changeset
|
26 |
notify: migrate db |
17 | 27 |
|
51 | 28 |
- name: create instance dir |
17 | 29 |
become: yes |
30 |
file: |
|
51 | 31 |
path: "{{item}}" |
17 | 32 |
state: "directory" |
33 |
owner: "{{writefreely_user}}" |
|
34 |
group: "{{writefreely_user}}" |
|
35 |
mode: "0755" |
|
36 |
notify: reload service |
|
51 | 37 |
loop: |
38 |
- "{{writefreely_dir}}" |
|
39 |
- "{{writefreely_dir}}/{{writefreely_instance}}" |
|
17 | 40 |
|
41 |
- name: install static content |
|
42 |
become: yes |
|
43 |
copy: |
|
44 |
src: "/tmp/writefreely/" |
|
45 |
remote_src: yes |
|
46 |
dest: "{{writefreely_dir}}/{{writefreely_instance}}/" |
|
47 |
owner: "{{writefreely_user}}" |
|
48 |
group: "{{writefreely_user}}" |
|
49 |
mode: "0755" |
|
1
fd351734f007
Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff
changeset
|
50 |
|
17 | 51 |
- name: configure |
52 |
become: yes |
|
53 |
template: |
|
54 |
src: "config.ini.j2" |
|
55 |
dest: "{{writefreely_dir}}/{{writefreely_instance}}/config.ini" |
|
56 |
mode: "0644" |
|
57 |
owner: "{{writefreely_user}}" |
|
58 |
group: "{{writefreely_user}}" |
|
59 |
notify: reload service |
|
60 |
||
26
b0e4ad2f4291
Fix writefreely role to be idempotent.
Luke Hoersten <luke@hoersten.org>
parents:
18
diff
changeset
|
61 |
- name: check if keys exists |
b0e4ad2f4291
Fix writefreely role to be idempotent.
Luke Hoersten <luke@hoersten.org>
parents:
18
diff
changeset
|
62 |
stat: |
b0e4ad2f4291
Fix writefreely role to be idempotent.
Luke Hoersten <luke@hoersten.org>
parents:
18
diff
changeset
|
63 |
path: "{{writefreely_dir}}/{{writefreely_instance}}/keys/cookies_auth.aes256" |
b0e4ad2f4291
Fix writefreely role to be idempotent.
Luke Hoersten <luke@hoersten.org>
parents:
18
diff
changeset
|
64 |
register: keys_file |
b0e4ad2f4291
Fix writefreely role to be idempotent.
Luke Hoersten <luke@hoersten.org>
parents:
18
diff
changeset
|
65 |
|
17 | 66 |
- name: generate keys |
67 |
become: yes |
|
68 |
become_user: "{{writefreely_user}}" |
|
69 |
command: "writefreely keys gen" |
|
70 |
args: |
|
71 |
chdir: "{{writefreely_dir}}/{{writefreely_instance}}/" |
|
27 | 72 |
when: not keys_file.stat.exists |
17 | 73 |
|
74 |
- name: check if db exists |
|
75 |
stat: |
|
76 |
path: "{{writefreely_dir}}/{{writefreely_instance}}/writefreely.db" |
|
77 |
register: db_file |
|
78 |
||
79 |
- name: create db |
|
80 |
become: yes |
|
81 |
become_user: "{{writefreely_user}}" |
|
82 |
command: "writefreely db init" |
|
83 |
args: |
|
84 |
chdir: "{{writefreely_dir}}/{{writefreely_instance}}/" |
|
85 |
when: not db_file.stat.exists |
|
86 |
||
87 |
- name: create admin |
|
88 |
become: yes |
|
89 |
become_user: "{{writefreely_user}}" |
|
90 |
command: "writefreely --create-admin admin:admin" |
|
91 |
args: |
|
92 |
chdir: "{{writefreely_dir}}/{{writefreely_instance}}/" |
|
93 |
when: not db_file.stat.exists |
|
94 |
||
95 |
- name: install systemd service |
|
96 |
become: yes |
|
97 |
template: |
|
98 |
src: "[email protected]" |
|
99 |
dest: "/lib/systemd/system/[email protected]" |
|
100 |
||
101 |
- name: ensure service is started |
|
102 |
become: yes |
|
103 |
systemd: name="writefreely@{{writefreely_instance}}.service" enabled="yes" state="started" |