This repository has been archived by the owner on Jan 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathextras.yml
108 lines (106 loc) · 2.63 KB
/
extras.yml
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
108
---
- name: Install python
hosts: all
gather_facts: false
tasks:
- name: Install python
raw: "apt update && apt install -y python"
- name: Setup HTTP server
hosts: web
roles:
- caddy_ansible.caddy_ansible
pre_tasks:
- name: Ensure webdirs exists
file:
path: "{{ item }}"
state: directory
with_items:
- /var/www/demo
- /var/www/demo/img
- /var/www/presentation
- name: Ensure portal site exists
copy:
src: index.html
dest: /var/www/demo/index.html
- name: Copy images
copy:
src: "img/{{ item }}"
dest: "/var/www/demo/img/{{ item }}"
with_items:
- logo.png
- digitalocean.png
vars:
port_mapping:
grafana: 3000
prometheus: 9090
alertmanager: 9093
node: 9100
blackbox: 9115
snmp: 9116
caddy_update: true
caddy_systemd_capabilities_enabled: true
caddy_features: http.prometheus
caddy_config: |
{{ ansible_host }} {
ext .html
root /var/www/demo/
prometheus
tls paulfantom@gmail.com
}
presentation.cloudalchemy.org {
root /var/www/presentation
tls paulfantom@gmail.com
}
{% for name, port in port_mapping.items() %}
{{ name }}.{{ ansible_host }} {
proxy / 127.0.0.1:{{ port }}
tls paulfantom@gmail.com
}
{% endfor %}
- name: Setup random number exporter
hosts: web
tasks:
- name: Locally build random_exporter
shell: |
go get -u github.com/prometheus/client_golang/examples/random
mv $GOPATH/bin/random /tmp/random_exporter
args:
creates: /tmp/random_exporter
delegate_to: localhost
run_once: true
- name: Copy random_exporter binary
copy:
src: /tmp/random_exporter
dest: /usr/local/bin/random_exporter
owner: root
group: root
mode: 0755
notify: random_exporter restart
- name: Copy systemd service file
copy:
dest: /etc/systemd/system/random_exporter.service
mode: 0644
content: "{{ random_exporter_systemd_service }}"
notify: random_exporter restart
handlers:
- name: random_exporter restart
systemd:
name: random_exporter
state: started
daemon_reload: true
enabled: true
vars:
random_exporter_systemd_service: |
# Ansible managed
[Unit]
Description=Random Metrics Exporter
After=network.target
[Service]
Type=simple
User=nobody
Group=nogroup
ExecStart=/usr/local/bin/random_exporter -listen-address=:8999
SyslogIdentifier=random_exporter
Restart=always
[Install]
WantedBy=multi-user.target