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