main.yml 5.83 KB
Newer Older
1
2
3
4
5
---

- name: install prometheus-node-exporter
  pacman: name=prometheus-node-exporter,arch-audit,pacman-contrib state=present

6
7
8
9
- name: install prometheus-blackbox-exporter
  pacman: name=prometheus-blackbox-exporter state=present
  when: "'prometheus' in group_names"

10
11
12
13
- name: install prometheus-memcached-exporter
  pacman: name=prometheus-memcached-exporter state=present
  when: "'memcached' in group_names"

14
15
16
17
18
19
20
21
- name: install jq for rebuilderd-textcollector
  pacman: name=jq state=present
  when: "'rebuilderd' in group_names"

- name: add node_exporter to rebuilderd group
  user: name=node_exporter groups=rebuilderd append=yes
  when: "'rebuilderd' in group_names"

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
- name: install prometheus-mysqld-exporter
  pacman: name=prometheus-mysqld-exporter state=present
  when: "'mysql_servers' in group_names"

- name: create prometheus mysqld database user
  mysql_user:
    name: '{{ prometheus_mysqld_user }}'
    password: '{{ vault_prometheus_mysql_password }}'
    priv: "*.*:PROCESS,REPLICATION CLIENT"
    state: present
  when: "'mysql_servers' in group_names"

# TODO: with ansible 2.10 this can be set by mysql_user https://github.com/ansible/ansible/issues/26581
- name: set max_user_connections for prometheus mysqld user
  command: mysql -u root -e "ALTER USER '{{ prometheus_mysqld_user }}'@'localhost' WITH MAX_USER_CONNECTIONS 3;"
  when: "'mysql_servers' in group_names"

- name: copy prometheus mysqld exporter configuration
  template: src=prometheus-mysqld-exporter.j2 dest=/etc/conf.d/prometheus-mysqld-exporter owner=root group=root mode=600
  when: "'mysql_servers' in group_names"

- name: enable prometheus-mysqld-exporter service
  systemd: name=prometheus-mysqld-exporter enabled=yes daemon_reload=yes state=started
  when: "'mysql_servers' in group_names"

- name: install node exporter configuration
  template: src=prometheus-node-exporter.env.j2 dest=/etc/conf.d/prometheus-node-exporter owner=root group=root mode=600

- name: create textcollector directory
  file: path="{{ prometheus_textfile_dir }}" state=directory owner=node_exporter group=node_exporter mode=700

- name: install node exporter textcollector scripts
  copy: src={{ item }} dest=/usr/local/bin/{{ item }} owner=root group=root mode=0755
  with_items:
    - arch-textcollector.sh
    - borg-textcollector.sh
58
    - rebuilderd-textcollector.sh
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

- name: install arch textcollector service
  template: src=prometheus-arch-textcollector.service.j2 dest=/etc/systemd/system/prometheus-arch-textcollector.service owner=root group=root mode=600

- name: install arch textcollector timer
  template: src=prometheus-arch-textcollector.timer.j2 dest=/etc/systemd/system/prometheus-arch-textcollector.timer owner=root group=root mode=600

- name: enable and start prometheus arch textcollector timer
  systemd: name=prometheus-arch-textcollector.timer enabled=yes daemon_reload=yes state=started

- name: install borg textcollector service
  template: src=prometheus-borg-textcollector.service.j2 dest=/etc/systemd/system/prometheus-borg-textcollector.service owner=root group=root mode=600
  when: "'borg_clients' in group_names"

- name: install borg textcollector timer
  template: src=prometheus-borg-textcollector.timer.j2 dest=/etc/systemd/system/prometheus-borg-textcollector.timer owner=root group=root mode=600
  when: "'borg_clients' in group_names"

- name: enable and start prometheus borg textcollector timer
  systemd: name=prometheus-borg-textcollector.timer enabled=yes daemon_reload=yes state=started
  when: "'borg_clients' in group_names"

81
82
83
84
- name: install blackbox exporter configuration
  copy: src=blackbox.yml dest=/etc/prometheus/blackbox.yml owner=root group=root mode=0755
  when: "'prometheus' in group_names"

85
86
87
88
89
90
91
92
93
94
95
96
- name: install rebuilderd textcollector service
  template: src=prometheus-rebuilderd-textcollector.service.j2 dest=/etc/systemd/system/prometheus-rebuilderd-textcollector.service owner=root group=root mode=600
  when: "'rebuilderd' in group_names"

- name: install rebuilderd textcollector timer
  template: src=prometheus-rebuilderd-textcollector.timer.j2 dest=/etc/systemd/system/prometheus-rebuilderd-textcollector.timer owner=root group=root mode=600
  when: "'rebuilderd' in group_names"

- name: enable and start prometheus rebuilderd textcollector timer
  systemd: name=prometheus-rebuilderd-textcollector.timer enabled=yes daemon_reload=yes state=started
  when: "'rebuilderd' in group_names"

97
98
99
- name: enable prometheus-node-exporter service
  systemd: name=prometheus-node-exporter enabled=yes daemon_reload=yes state=started

100
101
102
103
- name: enable prometheus-blackbox-exporter service
  systemd: name=prometheus-blackbox-exporter enabled=yes daemon_reload=yes state=started
  when: "'prometheus' in group_names"

104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
- name: enable prometheus-memcached-exporter service
  systemd: name=prometheus-memcached-exporter enabled=yes daemon_reload=yes state=started
  when: "'memcached' in group_names"

- name: open prometheus-node-exporter ipv4 port for monitoring.archlinux.org
  firewalld: state=enabled permanent=true immediate=yes
        rich_rule="rule family=ipv4 source address={{ hostvars['monitoring.archlinux.org']['ipv4_address'] }} port protocol=tcp port={{ prometheus_exporter_port }} accept"
  when: "'prometheus' not in group_names"

- name: open gitlab exporter ipv4 port for monitoring.archlinux.org
  firewalld: state=enabled permanent=true immediate=yes
        rich_rule="rule family=ipv4 source address={{ hostvars['monitoring.archlinux.org']['ipv4_address'] }} port protocol=tcp port={{ gitlab_runner_exporter_port }} accept"
  when: "'gitlab_runners' in group_names"

- name: open prometheus mysqld exporter ipv4 port for monitoring.archlinux.org
  firewalld: state=enabled permanent=true immediate=yes
        rich_rule="rule family=ipv4 source address={{ hostvars['monitoring.archlinux.org']['ipv4_address'] }} port protocol=tcp port={{ prometheus_mysqld_exporter_port }} accept"
  when: "'mysql_servers' in group_names"