--- a/writefreely/defaults/main.yaml Sat May 02 18:38:02 2020 -0500
+++ b/writefreely/defaults/main.yaml Sun May 03 12:57:47 2020 -0500
@@ -1,9 +1,11 @@
---
-writefreely_version: "0.11.2"
-writefreely_release: "https://github.com/writeas/writefreely/releases/download/v{{writefreely_version}}/writefreely_{{writefreely_version}}_linux_arm7.tar.gz"
+writefreely_user: "writefreely"
+writefreely_arch: "arm7"
+writefreely_version: "0.12.0"
+writefreely_tar: "https://github.com/writeas/writefreely/releases/download/v{{writefreely_version}}/writefreely_{{writefreely_version}}_linux_{{writefreely_arch}}.tar.gz"
-writefreely_install_path: "/opt/writefreely"
-
-writefreely_apt_packages:
- - "mysql"
+writefreely_dir: "/var/writefreely"
+writefreely_port: "8080"
+writefreely_url: "https://{{writefreely_instance}}"
+writefreely_site_name: "{{writefreely_instance}}"
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/writefreely/handlers/main.yaml Sun May 03 12:57:47 2020 -0500
@@ -0,0 +1,5 @@
+---
+
+- name: reload service
+ become: yes
+ systemd: name="writefreely@{{writefreely_instance}}.service" enabled="yes" daemon_reload="yes"
--- a/writefreely/tasks/main.yaml Sat May 02 18:38:02 2020 -0500
+++ b/writefreely/tasks/main.yaml Sun May 03 12:57:47 2020 -0500
@@ -1,8 +1,106 @@
---
-- name: install apt packages
- apt: name="{{writefreely_apt_packages}}"
+- name: add writefreely user
+ become: yes
+ user: name="{{writefreely_user}}"
+
+- name: unarchive writefreely
+ become: yes
+ unarchive:
+ remote_src: yes
+ src: "{{writefreely_tar}}"
+ dest: "/tmp/"
+ creates: "/tmp/writefreely/"
+ owner: "root"
+ group: "root"
+
+- name: install writefreely binary
+ become: yes
+ command: "install -m 0755 -o {{writefreely_user}} -g {{writefreely_user}} -t /usr/local/bin /tmp/writefreely/writefreely"
+ changed_when: false
+
+- name: create root dir
+ become: yes
+ file:
+ path: "{{writefreely_dir}}"
+ state: "directory"
+ owner: "{{writefreely_user}}"
+ group: "{{writefreely_user}}"
+ mode: "0755"
+ notify: reload service
+
+- name: create instance dir
+ become: yes
+ file:
+ path: "{{writefreely_dir}}/{{writefreely_instance}}"
+ state: "directory"
+ owner: "{{writefreely_user}}"
+ group: "{{writefreely_user}}"
+ mode: "0755"
+ notify: reload service
+
+- name: install static content
+ become: yes
+ copy:
+ src: "/tmp/writefreely/"
+ remote_src: yes
+ dest: "{{writefreely_dir}}/{{writefreely_instance}}/"
+ owner: "{{writefreely_user}}"
+ group: "{{writefreely_user}}"
+ mode: "0755"
-- name: download writefreely
- archive:
- src: "{{writefreely_release}}"
+- name: configure
+ become: yes
+ template:
+ src: "config.ini.j2"
+ dest: "{{writefreely_dir}}/{{writefreely_instance}}/config.ini"
+ mode: "0644"
+ owner: "{{writefreely_user}}"
+ group: "{{writefreely_user}}"
+ notify: reload service
+
+- name: generate keys
+ become: yes
+ become_user: "{{writefreely_user}}"
+ command: "writefreely keys gen"
+ args:
+ chdir: "{{writefreely_dir}}/{{writefreely_instance}}/"
+
+- name: check if db exists
+ stat:
+ path: "{{writefreely_dir}}/{{writefreely_instance}}/writefreely.db"
+ register: db_file
+
+- name: create db
+ become: yes
+ become_user: "{{writefreely_user}}"
+ command: "writefreely db init"
+ args:
+ chdir: "{{writefreely_dir}}/{{writefreely_instance}}/"
+ when: not db_file.stat.exists
+
+- name: create admin
+ become: yes
+ become_user: "{{writefreely_user}}"
+ command: "writefreely --create-admin admin:admin"
+ args:
+ chdir: "{{writefreely_dir}}/{{writefreely_instance}}/"
+ when: not db_file.stat.exists
+
+- name: migrate db
+ become: yes
+ become_user: "{{writefreely_user}}"
+ command: "writefreely db migrate"
+ args:
+ chdir: "{{writefreely_dir}}/{{writefreely_instance}}/"
+ when: db_file.stat.exists
+
+- name: install systemd service
+ become: yes
+ template:
+ src: "[email protected]"
+ dest: "/lib/systemd/system/[email protected]"
+
+- name: ensure service is started
+ become: yes
+ systemd: name="writefreely@{{writefreely_instance}}.service" enabled="yes" state="started"
--- a/writefreely/templates/config.ini.j2 Sat May 02 18:38:02 2020 -0500
+++ b/writefreely/templates/config.ini.j2 Sun May 03 12:57:47 2020 -0500
@@ -1,44 +1,71 @@
[server]
hidden_host =
-port = {{writefreely_server_port}}
+port = {{writefreely_port}}
bind = localhost
tls_cert_path =
tls_key_path =
-autocert = true
+autocert = false
templates_parent_dir =
static_parent_dir =
pages_parent_dir =
keys_parent_dir =
+hash_seed =
[database]
type = sqlite3
-filename = {{writefreely_db_name}}.db
+filename = writefreely.db
username =
password =
-database =
+database = writefreely
host = localhost
port = 3306
[app]
site_name = {{writefreely_site_name}}
-site_description = {{writefreely_site_desc}}
-host = {{writefreely_site_host}}
+site_description =
+host = {{writefreely_url}}
theme = write
editor =
disable_js = false
webfonts = true
-landing =
+landing = /read
simple_nav = false
wf_modesty = false
chorus = false
+forest = false
disable_drafts = false
-single_user = true
+single_user = false
open_registration = false
min_username_len = 3
max_blogs = 1
federation = true
public_stats = true
private = false
-local_timeline = false
-user_invites =
-default_visibility =
+local_timeline = true
+user_invites = admin
+default_visibility = public
+update_checks = false
+
+[oauth.slack]
+client_id =
+client_secret =
+team_id =
+callback_proxy =
+callback_proxy_api =
+
+[oauth.writeas]
+client_id =
+client_secret =
+auth_location =
+token_location =
+inspect_location =
+callback_proxy =
+callback_proxy_api =
+
+[oauth.gitlab]
+client_id =
+client_secret =
+host =
+display_name =
+callback_proxy =
+callback_proxy_api =
--- a/writefreely/templates/writefreely.service.j2 Sat May 02 18:38:02 2020 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-[Unit]
-Description=WriteFreely %I Instance
-After=syslog.target network.target
-
-[Service]
-WorkingDirectory=/run/writefreely/%i
-ExecStart=/usr/local/bin/writefreely -c /etc/writefreely/%i.conf
-Restart=always
-
-[Install]
-WantedBy=multi-user.target
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/writefreely/templates/[email protected] Sun May 03 12:57:47 2020 -0500
@@ -0,0 +1,12 @@
+[Unit]
+Description=WriteFreely %I Instance
+After=syslog.target network.target
+
+[Service]
+WorkingDirectory={{writefreely_dir}}/%i/
+ExecStart=/usr/local/bin/writefreely
+Restart=always
+User={{writefreely_user}}
+
+[Install]
+WantedBy=multi-user.target