aboutsummaryrefslogtreecommitdiffstats
path: root/roles/gathio/tasks/main.yml
blob: 7e9e48e9a5d77f98381336dddf0032c235b5f6d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
- name: install packages
  dnf:
    name: '{{ gathio_packages }}'
    state: present

- name: create SELinux policy for mongodb
  include_role:
    name: selinux_policy
    apply:
      tags: selinux
  vars:
    selinux_policy_name: mongodb_custom
    selinux_policy_te: '{{ gathio_mongodb_selinux_policy_te }}'
  tags: selinux

- name: enable mongodb
  systemd:
    name: mongod
    state: started
    enabled: yes

- name: create gathio user
  user:
    name: '{{ gathio_user }}'
    system: yes
    home: '{{ gathio_home }}'
    shell: /sbin/nologin
    create_home: no

- name: create gathio home
  file:
    path: '{{ gathio_home }}'
    owner: '{{ gathio_user }}'
    group: '{{ gathio_user }}'
    mode: 0755
    state: directory

- name: disable npm package lock
  lineinfile:
    regexp: ^package-lock=
    line: package-lock=false
    path: '{{ gathio_home }}/.npmrc'
    create: yes
    owner: '{{ gathio_user }}'
    group: '{{ gathio_user }}'
    mode: 0600
    state: present

- name: clone gathio repository
  git:
    repo: '{{ gathio_git_repo }}'
    dest: '{{ gathio_install_dir }}'
    version: '{{ gathio_version }}'
    force: yes
    update: yes
  become: yes
  become_user: '{{ gathio_user }}'
  register: gathio_git
  notify: restart gathio

- name: install npm dependencies
  npm:
    production: yes
    path: '{{ gathio_install_dir }}'
  become: yes
  become_user: '{{ gathio_user }}'
  when: gathio_git.changed
  notify: restart gathio

- name: generate gathio configuration
  template:
    src: '{{ gathio_install_dir[1:] }}/config/{{ item }}.j2'
    dest: '{{ gathio_install_dir }}/config/{{ item }}'
    owner: '{{ gathio_user }}'
    group: '{{ gathio_user }}'
    mode: 0440
  loop:
    - api.js
    - database.js
    - domain.js
  notify: restart gathio

- name: create gathio systemd unit
  template:
    src: etc/systemd/system/gathio.service.j2
    dest: /etc/systemd/system/gathio.service
  register: gathio_unit
  notify: restart gathio

- name: reload systemd daemons
  systemd:
    daemon_reload: yes
  when: gathio_unit.changed

- name: open firewall ports
  firewalld:
    port: '{{ gathio_port }}/tcp'
    permanent: yes
    immediate: yes
    state: enabled
  tags: firewalld

- name: enable gathio
  systemd:
    name: gathio
    state: started
    enabled: yes