aboutsummaryrefslogtreecommitdiffstats
path: root/ansible/roles/rrdstats/tasks/main.yml
blob: 71373f130b64093def77fe427211051a9e77ae1b (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
---
- name: Install rrdtool
  ansible.builtin.package:
    name: rrdtool
    state: present
  tags:
    - role::rrdstats

- name: Template the statistics script
  ansible.builtin.template:
    src: generate-rrdtool-stats.sh.j2
    dest: "{{ rrdstats_script_path }}"
    owner: root
    group: root
    mode: "0555"
  tags:
    - role::rrdstats

- name: Template environment variables
  ansible.builtin.copy:
    content: |
      DB_DSN="postgresql://{{ rrdstats_pg_username }}:{{ rrdstats_pg_password }}@localhost:5432/metricity?application_name=rrdstats"
    dest: "{{ rrdstats_env_path }}"
    # This must only be readable by root because systemd will read it and
    # inject the environment variables into the target process.
    owner: root
    group: root
    mode: "0400"
  tags:
    - role::rrdstats

- name: Template systemd units
  ansible.builtin.template:
    src: generate-rrdtool-stats.{{ item }}.j2
    dest: /etc/systemd/system/generate-rrdtool-stats.{{ item }}
    owner: root
    group: root
    mode: "0444"
  tags:
    - role::rrdstats
  loop:
    - service
    - timer
  notify:
    - Reload the systemd daemon
    - Restart the rrdstats timer

- name: Start and enable the timer
  ansible.builtin.service:
    name: generate-rrdtool-stats.timer
    enabled: true
    state: started
  tags:
    - role::rrdstats