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