Skip to content

Commit e894c80

Browse files
committed
Telemetry ansible.
1 parent 276c152 commit e894c80

File tree

6 files changed

+245
-19
lines changed

6 files changed

+245
-19
lines changed

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,3 +1193,12 @@ ansible_operator_deploy: ## Deploy the Operator. Parameters: INVENTORY
11931193
-i $(INVENTORY) \
11941194
-e "ecdsa_keystore_path=$(ECDSA_KEYSTORE)" \
11951195
-e "bls_keystore_path=$(BLS_KEYSTORE)"
1196+
1197+
ansible_telemetry_create_env:
1198+
@cp -n infra/ansible/playbooks/ini/config-telemetry.ini.example infra/ansible/playbooks/ini/config-telemetry.ini
1199+
@echo "Config files for Telemetry created in infra/ansible/playbooks/ini"
1200+
@echo "Please complete the values and run make ansible_telemetry_deploy"
1201+
1202+
ansible_telemetry_deploy:
1203+
@ansible-playbook infra/ansible/playbooks/telemetry.yaml \
1204+
-i $(INVENTORY)
Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
- name: Elixir Setup
2-
hosts: all
3-
become: true
2+
hosts: "{{ host }}"
43
vars:
5-
user: "{{ user }}"
64
erlang_version: 26.0
75
elixir_version: 1.16.2-otp-26
86

97
tasks:
108
# Install required packages
119
- name: Update apt and install required system packages
10+
become: true
1211
apt:
1312
pkg:
1413
- build-essential
1514
- autoconf
1615
- m4
1716
- libncurses5-dev
18-
- libwxgtk3.0-gtk3-dev
19-
- libwxgtk-webview3.0-gtk3-dev
17+
- libwxgtk3.2-dev
18+
- libwxgtk-webview3.2-dev
2019
- libgl1-mesa-dev
2120
- libglu1-mesa-dev
2221
- libpng-dev
@@ -26,44 +25,40 @@
2625
- fop
2726
- libxml2-utils
2827
- libncurses-dev
29-
- openjdk-11-jdk
28+
- openjdk-17-jdk
3029
state: latest
3130
update_cache: true
31+
vars:
32+
ansible_ssh_user: "{{ admin_user }}"
3233

3334
- name: Clone asdf repository into ~/.asdf
3435
ansible.builtin.git:
3536
name: https://github.com/asdf-vm/asdf.git
3637
dest: ~/.asdf
3738
single_branch: yes
3839
version: v0.14.0
39-
become_user: "{{ user }}"
4040

4141
- name: Insert lines to ~/.bashrc to source asdf
4242
ansible.builtin.blockinfile:
43-
path: "/home/{{ user }}/.bashrc"
43+
path: "/home/{{ ansible_user }}/.bashrc"
4444
block: |
4545
. "$HOME/.asdf/asdf.sh"
4646
. "$HOME/.asdf/completions/asdf.bash"
47-
become_user: "{{ user }}"
48-
49-
# - name: Add asdf to the shell
50-
# shell: export ASDF_DIR="$HOME/.asdf" && . ~/.asdf/asdf.sh
51-
# become_user: "{{ user }}"
5247
5348
- name: Add Erlang plugin to asdf
54-
shell: asdf plugin add erlang
49+
shell: /home/app/.asdf/bin/asdf plugin add erlang
5550

5651
- name: Add Erlang version to asdf
57-
shell: asdf install erlang {{ erlang_version }}
52+
shell: /home/app/.asdf/bin/asdf install erlang {{ erlang_version }}
5853

5954
- name: Set Erlang version as global
60-
shell: asdf global erlang {{ erlang_version }}
55+
shell: /home/app/.asdf/bin/asdf global erlang {{ erlang_version }}
6156

6257
- name: Add Elixir plugin to asdf
63-
shell: asdf plugin add elixir
58+
shell: /home/app/.asdf/bin/asdf plugin add elixir
6459

6560
- name: Add Elixir version to asdf
66-
shell: asdf install elixir {{ elixir_version }}
61+
shell: /home/app/.asdf/bin/asdf install elixir {{ elixir_version }}
6762

6863
- name: Set Elixir version as global
69-
shell: asdf global elixir {{ elixir_version }}
64+
shell: /home/app/.asdf/bin/asdf global elixir {{ elixir_version }}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[global]
2+
telemetry_api_url=
3+
aligned_aggregator_prometheus_ip=
4+
aligned_operator_prometheus_ip=
5+
aligned_batcher_prometheus_ip=
6+
aligned_tracker_prometheus_ip=
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
- name: Run setup playbook
2+
ansible.builtin.import_playbook: setup.yaml
3+
vars:
4+
host: telemetry
5+
6+
- name: Run elixir playbook
7+
ansible.builtin.import_playbook: elixir.yaml # fix!
8+
vars:
9+
host: telemetry
10+
11+
- name: Setup Telemetry
12+
hosts: telemetry
13+
become: true
14+
15+
vars:
16+
prometheus_version: "2.53.2"
17+
ansible_ssh_user: admin
18+
19+
tasks:
20+
# install prometeus
21+
# add config template to set server's IP (ini file)
22+
# grafana
23+
# config
24+
# OpenTelemetry Collector
25+
# install Jaeger
26+
# install Cassandra
27+
# install postgres
28+
# install aligned Telemetry api
29+
# install caddy
30+
# add template for caddyfile for grafana (public) and Jaeger (tailscale)
31+
32+
- name: Install dependencies
33+
apt:
34+
name:
35+
- apt-transport-https
36+
- software-properties-common
37+
- wget
38+
state: present
39+
update_cache: yes
40+
41+
- name: Create keyrings directory for Grafana
42+
file:
43+
path: /etc/apt/keyrings
44+
state: directory
45+
mode: '0755'
46+
47+
- name: Download and install Grafana GPG key
48+
shell:
49+
cmd: wget -q -O - https://apt.grafana.com/gpg.key | gpg --dearmor -o /etc/apt/keyrings/grafana.gpg
50+
creates: /etc/apt/keyrings/grafana.gpg
51+
52+
- name: Add Grafana stable repository
53+
shell:
54+
cmd: echo "deb [signed-by=/etc/apt/keyrings/grafana.gpg] https://apt.grafana.com stable main" | sudo tee -a /etc/apt/sources.list.d/grafana.list
55+
creates: /etc/apt/sources.list.d/grafana.list
56+
57+
- name: Update apt cache and install Grafana
58+
apt:
59+
name: grafana
60+
state: present
61+
update_cache: yes
62+
63+
- name: Check if Prometheus is installed
64+
stat:
65+
path: /usr/local/bin/prometheus
66+
register: prometheus_exists
67+
68+
- name: Create Prometheus group
69+
when: not prometheus_exists.stat.exists
70+
group:
71+
name: prometheus
72+
system: yes
73+
74+
- name: Create Prometheus user
75+
when: not prometheus_exists.stat.exists
76+
user:
77+
name: prometheus
78+
group: prometheus
79+
shell: /sbin/nologin
80+
system: yes
81+
82+
- name: Download Prometheus
83+
when: not prometheus_exists.stat.exists
84+
get_url:
85+
url: "https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/prometheus-{{ prometheus_version }}.linux-amd64.tar.gz"
86+
dest: "/tmp/prometheus-{{ prometheus_version }}.tar.gz"
87+
mode: '0644'
88+
89+
- name: Extract Prometheus
90+
when: not prometheus_exists.stat.exists
91+
unarchive:
92+
src: "/tmp/prometheus-{{ prometheus_version }}.tar.gz"
93+
dest: /tmp/
94+
remote_src: yes
95+
96+
- name: Create Prometheus directories
97+
when: not prometheus_exists.stat.exists
98+
file:
99+
path: "{{ item }}"
100+
state: directory
101+
owner: prometheus
102+
group: prometheus
103+
mode: '0755'
104+
loop:
105+
- /etc/prometheus
106+
- /var/lib/prometheus
107+
108+
- name: Move Prometheus
109+
when: not prometheus_exists.stat.exists
110+
copy:
111+
remote_src: true
112+
src: "{{ item.src }}"
113+
dest: "{{ item.dest }}"
114+
owner: prometheus
115+
group: prometheus
116+
mode: '0755'
117+
with_items:
118+
- { src: "/tmp/prometheus-{{ prometheus_version }}.linux-amd64/prometheus", dest: "/usr/local/bin/prometheus" }
119+
- { src: "/tmp/prometheus-{{ prometheus_version }}.linux-amd64/promtool", dest: "/usr/local/bin/promtool" }
120+
121+
- name: Move Prometheus configuration and consoles
122+
when: not prometheus_exists.stat.exists
123+
copy:
124+
remote_src: true
125+
src: "{{ item.src }}"
126+
dest: "{{ item.dest }}"
127+
owner: prometheus
128+
group: prometheus
129+
mode: '0755'
130+
with_items:
131+
- { src: "/tmp/prometheus-{{ prometheus_version }}.linux-amd64/consoles", dest: "/etc/prometheus/consoles" }
132+
- { src: "/tmp/prometheus-{{ prometheus_version }}.linux-amd64/console_libraries", dest: "/etc/prometheus/console_libraries" }
133+
- { src: "/tmp/prometheus-{{ prometheus_version }}.linux-amd64/prometheus.yml", dest: "/etc/prometheus/prometheus.yml" }
134+
135+
- name: Clean up Prometheus tar and extracted directory
136+
when: not prometheus_exists.stat.exists
137+
file:
138+
path: "{{ item }}"
139+
state: absent
140+
loop:
141+
- "/tmp/prometheus-{{ prometheus_version }}.tar.gz"
142+
- "/tmp/prometheus-{{ prometheus_version }}.linux-amd64"
143+
144+
- name: Add prometheus config file
145+
template:
146+
src: prometheus/prometheus.yaml.j2
147+
dest: /etc/prometheus/prometheus.yml
148+
vars:
149+
aligned_aggregator_prometheus_ip: "{{ lookup('ini', 'aligned_aggregator_prometheus_ip', file='ini/config-telemetry.ini') }}"
150+
aligned_operator_prometheus_ip: "{{ lookup('ini', 'aligned_operator_prometheus_ip', file='ini/config-telemetry.ini') }}"
151+
aligned_batcher_prometheus_ip: "{{ lookup('ini', 'aligned_batcher_prometheus_ip', file='ini/config-telemetry.ini') }}"
152+
aligned_tracker_prometheus_ip: "{{ lookup('ini', 'aligned_tracker_prometheus_ip', file='ini/config-telemetry.ini') }}"
153+
154+
- name: Add grafana config file
155+
template:
156+
src: grafana.ini.j21
157+
dest: /etc/grafana/grafana.ini
158+
159+
- name: Add Caddy repository to sources list
160+
become: true
161+
apt_repository:
162+
repo:
163+
"deb https://dl.cloudsmith.io/public/caddy/stable/deb/debian
164+
any-version main"
165+
state: present
166+
filename: caddy-stable
167+
vars:
168+
ansible_ssh_user: "{{ admin_user }}"
169+
170+
- name: Add Caddy src repository to sources list
171+
become: true
172+
apt_repository:
173+
repo:
174+
"deb-src https://dl.cloudsmith.io/public/caddy/stable/deb/debian
175+
any-version main"
176+
state: present
177+
filename: caddy-stable
178+
vars:
179+
ansible_ssh_user: "{{ admin_user }}"
180+
181+
- name: Install Caddy
182+
become: true
183+
apt:
184+
update_cache: yes
185+
name: caddy
186+
state: present
187+
vars:
188+
ansible_ssh_user: "{{ admin_user }}"
189+
190+
- name: Add caddyfile config
191+
become: true
192+
template:
193+
src: caddy/Caddyfile.telemetry.j2
194+
dest: /etc/caddy/Caddyfile
195+
vars:
196+
telemetry_api_url: "{{ lookup('ini', 'telemetry_api_url', file='ini/config-telemetry.ini') }}"
197+
198+
handlers:
199+
- name: Restart Grafana
200+
service:
201+
name: grafana-server
202+
state: restarted
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{{ telemetry_api_url }} {
2+
# reference https://gist.github.com/vocuzi/5cb835dde177cf892e2ca1a03c2a443f
3+
@whitelisted {
4+
path /versions*
5+
}
6+
reverse_proxy @whitelisted localhost:4001
7+
}

infra/ansible/stage_inventory.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ batcher:
1212
admin_user: admin
1313
ansible_user: app
1414
ansible_python_interpreter: /usr/bin/python3
15+
telemetry:
16+
hosts:
17+
aligned-holesky-stage-1-telemetry:
18+
ansible_host: aligned-holesky-stage-1-telemetry
19+
admin_user: admin
20+
ansible_user: app
21+
ansible_python_interpreter: /usr/bin/python3
1522
# explorer:
1623
# hosts:
1724
# aligned-holesky-explorer:

0 commit comments

Comments
 (0)