|
1 --- |
|
2 |
|
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 copy: |
|
20 src: "/tmp/writefreely/writefreely" |
|
21 dest: "/usr/local/bin/" |
|
22 remote_src: yes |
|
23 owner: "{{writefreely_user}}" |
|
24 group: "{{writefreely_user}}" |
|
25 mode: "0755" |
|
26 notify: migrate db |
|
27 |
|
28 - name: create instance dir |
|
29 become: yes |
|
30 file: |
|
31 path: "{{item}}" |
|
32 state: "directory" |
|
33 owner: "{{writefreely_user}}" |
|
34 group: "{{writefreely_user}}" |
|
35 mode: "0755" |
|
36 notify: reload service |
|
37 loop: |
|
38 - "{{writefreely_dir}}" |
|
39 - "{{writefreely_dir}}/{{writefreely_instance}}" |
|
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" |
|
50 |
|
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 |
|
61 - name: check if keys exists |
|
62 stat: |
|
63 path: "{{writefreely_dir}}/{{writefreely_instance}}/keys/cookies_auth.aes256" |
|
64 register: keys_file |
|
65 |
|
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}}/" |
|
72 when: not keys_file.stat.exists |
|
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" |