writefreely/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Sun, 03 May 2020 15:55:21 -0500
changeset 18 ea20908c3904
parent 17 41034ea52480
child 26 b0e4ad2f4291
permissions -rw-r--r--
Removed use of install command.
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"
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    26
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    27
- name: create root dir
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    28
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    29
  file:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    30
    path: "{{writefreely_dir}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    31
    state: "directory"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    32
    owner: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    33
    group: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    34
    mode: "0755"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    35
  notify: reload service
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    36
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    37
- name: create instance dir
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    38
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    39
  file:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    40
    path: "{{writefreely_dir}}/{{writefreely_instance}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    41
    state: "directory"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    42
    owner: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    43
    group: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    44
    mode: "0755"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    45
  notify: reload service
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    46
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    47
- name: install static content
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    48
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    49
  copy:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    50
    src: "/tmp/writefreely/"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    51
    remote_src: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    52
    dest: "{{writefreely_dir}}/{{writefreely_instance}}/"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    53
    owner: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    54
    group: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    55
    mode: "0755"
1
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    56
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    57
- name: configure
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    58
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    59
  template:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    60
    src: "config.ini.j2"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    61
    dest: "{{writefreely_dir}}/{{writefreely_instance}}/config.ini"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    62
    mode: "0644"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    63
    owner: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    64
    group: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    65
  notify: reload service
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    66
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    67
- name: generate keys
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    68
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    69
  become_user: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    70
  command: "writefreely keys gen"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    71
  args:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    72
    chdir: "{{writefreely_dir}}/{{writefreely_instance}}/"
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: migrate db
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
  become_user: "{{writefreely_user}}"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    98
  command: "writefreely db migrate"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    99
  args:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   100
    chdir: "{{writefreely_dir}}/{{writefreely_instance}}/"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   101
  when: db_file.stat.exists
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   102
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   103
- name: install systemd service
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   104
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   105
  template:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   106
    src: "[email protected]"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   107
    dest: "/lib/systemd/system/[email protected]"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   108
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   109
- name: ensure service is started
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   110
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   111
  systemd: name="[email protected]{{writefreely_instance}}.service" enabled="yes" state="started"