summaryrefslogtreecommitdiff
path: root/roles/monitoring/sachet/tasks/main.yml
blob: bb77dc44f613fa4dd76de1f7b5533c37d733e4b6 (plain) (blame)
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
---
- name: check if prometheus apt component of spreadspace repo is enabled
  assert:
    msg: "please enable the 'prometheus' component of spreadspace repo using 'spreadspace_apt_repo_components'"
    that:
    - spreadspace_apt_repo_components is defined
    - "'prometheus' in spreadspace_apt_repo_components"

- name: generate apt pin file for sachet package
  when: sachet_version is defined
  copy:
    dest: "/etc/apt/preferences.d/sachet.pref"
    content: |
      Package: sachet
      Pin: version {{ sachet_version }}-1
      Pin-Priority: 1001

- name: remove apt pin file for sachet package
  when: sachet_version is not defined
  file:
    path: "/etc/apt/preferences.d/sachet.pref"
    state: absent

- name: install apt packages
  apt:
    name: "sachet{% if sachet_version is defined %}={{ sachet_version }}-1{% endif %}"
    state: present
    allow_downgrade: yes
  notify: restart sachet

- name: add user for sachet
  user:
    name: sachet
    system: yes
    home: /nonexistent
    create_home: no

- name: install and configure smstools
  when: "'smstools' in sachet_providers"
  include_tasks: smstools.yml

- name: generate configuration file
  template:
    src: sachet.yml.j2
    dest: /etc/sachet.yml
    owner: sachet
    mode: 0600
  notify: restart sachet

- name: generate systemd service unit
  template:
    src: sachet.service.j2
    dest: /etc/systemd/system/sachet.service
  notify: restart sachet

- name: make sure sachet is enabled and started
  systemd:
    name: sachet.service
    daemon_reload: yes
    state: started
    enabled: yes