writefreely/server/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Sun, 18 Jul 2021 17:43:46 -0500
changeset 163 40b78af86337
parent 159 05d0cf32e077
child 170 a20a6d03747f
permissions -rw-r--r--
Tons of 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
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
     5
  user: name="{{writefreely_user}}"
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"
26
b0e4ad2f4291 Fix writefreely role to be idempotent.
Luke Hoersten <luke@hoersten.org>
parents: 18
diff changeset
    26
  notify: migrate db
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    27
51
19fa7aa47bf1 Minor writefreely change.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    28
- name: create instance dir
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    29
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    30
  file:
51
19fa7aa47bf1 Minor writefreely change.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    31
    path: "{{item}}"
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    32
    state: "directory"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    33
    owner: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    34
    group: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    35
    mode: "0755"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    36
  notify: reload service
51
19fa7aa47bf1 Minor writefreely change.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    37
  loop:
19fa7aa47bf1 Minor writefreely change.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    38
    - "{{writefreely_dir}}"
19fa7aa47bf1 Minor writefreely change.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    39
    - "{{writefreely_dir}}/{{writefreely_instance}}"
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    40
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    41
- name: install static content
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    42
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    43
  copy:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    44
    src: "/tmp/writefreely/"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    45
    remote_src: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    46
    dest: "{{writefreely_dir}}/{{writefreely_instance}}/"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    47
    owner: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    48
    group: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    49
    mode: "0755"
1
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    50
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    51
- name: configure
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    52
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    53
  template:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    54
    src: "config.ini.j2"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    55
    dest: "{{writefreely_dir}}/{{writefreely_instance}}/config.ini"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    56
    mode: "0644"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    57
    owner: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    58
    group: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    59
  notify: reload service
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    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
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    66
- name: generate keys
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    67
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    68
  become_user: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    69
  command: "writefreely keys gen"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    70
  args:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    71
    chdir: "{{writefreely_dir}}/{{writefreely_instance}}/"
27
8fddefdd948b More fixes
Luke Hoersten <luke@hoersten.org>
parents: 26
diff changeset
    72
  when: not keys_file.stat.exists
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    73
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    74
- name: check if db exists
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    75
  stat:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    76
    path: "{{writefreely_dir}}/{{writefreely_instance}}/writefreely.db"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    77
  register: db_file
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    78
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    79
- name: create db
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    80
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    81
  become_user: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    82
  command: "writefreely db init"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    83
  args:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    84
    chdir: "{{writefreely_dir}}/{{writefreely_instance}}/"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    85
  when: not db_file.stat.exists
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    86
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    87
- name: create admin
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    88
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    89
  become_user: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    90
  command: "writefreely --create-admin admin:admin"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    91
  args:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    92
    chdir: "{{writefreely_dir}}/{{writefreely_instance}}/"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    93
  when: not db_file.stat.exists
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    94
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    95
- name: install systemd service
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    96
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    97
  template:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    98
    src: "[email protected]"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    99
    dest: "/lib/systemd/system/[email protected]"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   100
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   101
- name: ensure service is started
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   102
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   103
  systemd: name="writefreely@{{writefreely_instance}}.service" enabled="yes" state="started"