writefreely/server/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Mon, 12 Feb 2024 17:29:16 -0600
changeset 232 a447e60bd3e9
parent 174 431c6d5e5dd4
permissions -rw-r--r--
Version updates
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
     3
- name: add writefreely user
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
     4
  become: yes
174
431c6d5e5dd4 Lots of updates.
Luke Hoersten <luke@hoersten.org>
parents: 172
diff changeset
     5
  user: name="{{writefreely_user}}" shell="/bin/false" system="yes" create_home="no"
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
     6
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
     7
- name: unarchive writefreely
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
     8
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
     9
  unarchive:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    10
    remote_src: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    11
    src: "{{writefreely_tar}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    12
    dest: "/tmp/"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    13
    creates: "/tmp/writefreely/"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    14
    owner: "root"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    15
    group: "root"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    16
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    17
- name: install writefreely binary
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    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
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    23
    owner: "root"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    24
    group: "root"
18
ea20908c3904 Removed use of install command.
Luke Hoersten <luke@hoersten.org>
parents: 17
diff changeset
    25
    mode: "0755"
171
534b247bed1c Fixed writefreely role.
Luke Hoersten <luke@hoersten.org>
parents: 170
diff changeset
    26
  notify:
534b247bed1c Fixed writefreely role.
Luke Hoersten <luke@hoersten.org>
parents: 170
diff changeset
    27
    - migrate db
534b247bed1c Fixed writefreely role.
Luke Hoersten <luke@hoersten.org>
parents: 170
diff changeset
    28
    - restart service
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    29
51
19fa7aa47bf1 Minor writefreely change.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    30
- name: create instance dir
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    31
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    32
  file:
51
19fa7aa47bf1 Minor writefreely change.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    33
    path: "{{item}}"
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    34
    state: "directory"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    35
    owner: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    36
    group: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    37
    mode: "0755"
171
534b247bed1c Fixed writefreely role.
Luke Hoersten <luke@hoersten.org>
parents: 170
diff changeset
    38
  notify: restart service
51
19fa7aa47bf1 Minor writefreely change.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    39
  loop:
19fa7aa47bf1 Minor writefreely change.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    40
    - "{{writefreely_dir}}"
19fa7aa47bf1 Minor writefreely change.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    41
    - "{{writefreely_dir}}/{{writefreely_instance}}"
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    42
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    43
- name: install static content
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    44
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    45
  copy:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    46
    src: "/tmp/writefreely/"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    47
    remote_src: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    48
    dest: "{{writefreely_dir}}/{{writefreely_instance}}/"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    49
    owner: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    50
    group: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    51
    mode: "0755"
171
534b247bed1c Fixed writefreely role.
Luke Hoersten <luke@hoersten.org>
parents: 170
diff changeset
    52
  notify: restart service
1
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    53
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    54
- name: configure
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    55
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    56
  template:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    57
    src: "config.ini.j2"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    58
    dest: "{{writefreely_dir}}/{{writefreely_instance}}/config.ini"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    59
    mode: "0644"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    60
    owner: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    61
    group: "{{writefreely_user}}"
171
534b247bed1c Fixed writefreely role.
Luke Hoersten <luke@hoersten.org>
parents: 170
diff changeset
    62
  notify: restart service
26
b0e4ad2f4291 Fix writefreely role to be idempotent.
Luke Hoersten <luke@hoersten.org>
parents: 18
diff changeset
    63
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    64
- name: generate keys
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    65
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    66
  become_user: "{{writefreely_user}}"
170
a20a6d03747f Updated versions: minecraft, miniflux, pleroma, writefreely, ergo-oragono.
Luke Hoersten <luke@hoersten.org>
parents: 163
diff changeset
    67
  command: "writefreely keys generate"
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    68
  args:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    69
    chdir: "{{writefreely_dir}}/{{writefreely_instance}}/"
172
21cfe5ba8d13 More fixes.
Luke Hoersten <luke@hoersten.org>
parents: 171
diff changeset
    70
  changed_when: false
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    71
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    72
- name: check if db exists
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    73
  stat:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    74
    path: "{{writefreely_dir}}/{{writefreely_instance}}/writefreely.db"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    75
  register: db_file
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    76
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    77
- name: create db
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    78
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    79
  become_user: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    80
  command: "writefreely db init"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    81
  args:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    82
    chdir: "{{writefreely_dir}}/{{writefreely_instance}}/"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    83
  when: not db_file.stat.exists
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    84
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    85
- name: create admin
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    86
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    87
  become_user: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    88
  command: "writefreely --create-admin admin:admin"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    89
  args:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    90
    chdir: "{{writefreely_dir}}/{{writefreely_instance}}/"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    91
  when: not db_file.stat.exists
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    92
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    93
- name: install systemd service
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    94
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    95
  template:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    96
    src: "[email protected]"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    97
    dest: "/lib/systemd/system/[email protected]"
171
534b247bed1c Fixed writefreely role.
Luke Hoersten <luke@hoersten.org>
parents: 170
diff changeset
    98
  notify: reload service
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    99
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   100
- name: ensure service is started
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   101
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   102
  systemd: name="writefreely@{{writefreely_instance}}.service" enabled="yes" state="started"