Skip to content

Commit c226382

Browse files
committed
Added ansible playbooks to update a pre-deployed server.
1 parent f5e7347 commit c226382

File tree

9 files changed

+215
-18
lines changed

9 files changed

+215
-18
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,13 @@ ansible_aggregator_deploy: ## Deploy the Operator. Parameters: INVENTORY
11701170
-e "ecdsa_keystore_path=$(ECDSA_KEYSTORE)" \
11711171
-e "bls_keystore_path=$(BLS_KEYSTORE)"
11721172

1173+
ansible_aggregator_update:
1174+
@if [ -z "$(INVENTORY)" ]; then \
1175+
echo "Error: INVENTORY must be set."; \
1176+
exit 1; \
1177+
fi
1178+
@ansible-playbook infra/ansible/playbooks/update/aggregator.yaml -i $(INVENTORY)
1179+
11731180
ansible_operator_create_env: ## Create empty variables files for the Operator deploy
11741181
@cp -n infra/ansible/playbooks/ini/config-operator.ini.example infra/ansible/playbooks/ini/config-operator.ini
11751182
@cp -n infra/ansible/playbooks/ini/config-register-operator.ini.example infra/ansible/playbooks/ini/config-register-operator.ini

infra/ansible/playbooks/aggregator.yaml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,6 @@
5050
group: '{{ ansible_user }}'
5151
recurse: yes
5252

53-
- name: Copy ECDSA keystore to server
54-
copy:
55-
src: '{{ ecdsa_keystore_path }}'
56-
dest: /home/{{ ansible_user }}/.keystores/aggregator.ecdsa
57-
owner: '{{ ansible_user }}'
58-
group: '{{ ansible_user }}'
59-
60-
- name: Copy BLS keystore to server
61-
copy:
62-
src: '{{ bls_keystore_path }}'
63-
dest: /home/{{ ansible_user }}/.keystores/aggregator.bls
64-
owner: '{{ ansible_user }}'
65-
group: '{{ ansible_user }}'
66-
6753
- name: Build aggregator
6854
shell:
6955
chdir: /home/{{ ansible_user }}/repos/aggregator/aligned_layer/
@@ -80,9 +66,7 @@
8066
eth_rpc_url_fallback: "{{ lookup('ini', 'eth_rpc_url_fallback', file='ini/config-aggregator.ini') }}"
8167
eth_ws_url: "{{ lookup('ini', 'eth_ws_url', file='ini/config-aggregator.ini') }}"
8268
eth_ws_url_fallback: "{{ lookup('ini', 'eth_ws_url_fallback', file='ini/config-aggregator.ini') }}"
83-
ecdsa_private_key_store_path: "{{ lookup('ini', 'ecdsa_private_key_store_path', file='ini/config-aggregator.ini') }}"
8469
ecdsa_private_key_store_password: "{{ lookup('ini', 'ecdsa_private_key_store_password', file='ini/config-aggregator.ini') }}"
85-
bls_private_key_store_path: "{{ lookup('ini', 'bls_private_key_store_path', file='ini/config-aggregator.ini') }}"
8670
bls_private_key_store_password: "{{ lookup('ini', 'bls_private_key_store_password', file='ini/config-aggregator.ini') }}"
8771
enable_metrics: "{{ lookup('ini', 'enable_metrics', file='ini/config-aggregator.ini') }}"
8872
metrics_ip_port_address: "{{ lookup('ini', 'metrics_ip_port_address', file='ini/config-aggregator.ini') }}"
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
- name: Run go playbook
2+
ansible.builtin.import_playbook: go.yaml
3+
vars:
4+
host: aggregator
5+
6+
- hosts: aggregator
7+
vars:
8+
service: "aggregator"
9+
10+
tasks:
11+
- name: Create directories
12+
file:
13+
path: "{{ item }}"
14+
recurse: yes
15+
state: directory
16+
loop:
17+
- /tmp/aggregator/aligned_layer
18+
- /home/{{ ansible_user }}/repos/aggregator/aligned_layer/build
19+
- /home/{{ ansible_user }}/config
20+
- /home/{{ ansible_user }}/.config/systemd/user
21+
22+
- name: Clone Aligned repository on /tmp/
23+
git:
24+
repo: https://github.com/yetanotherco/aligned_layer.git
25+
dest: /tmp/aggregator/aligned_layer/
26+
version: v0.12.0
27+
28+
- name: Set permissions for cloned repository
29+
file:
30+
path: /home/{{ ansible_user }}/repos/{{ service }}/aligned_layer
31+
mode: '0755'
32+
owner: '{{ ansible_user }}'
33+
group: '{{ ansible_user }}'
34+
recurse: yes
35+
36+
- name: Build aggregator on /tmp/
37+
shell:
38+
chdir: /tmp/aggregator/aligned_layer/
39+
cmd: /usr/local/go/bin/go build -o /tmp/aggregator/aligned_layer/build/aligned-aggregator /tmp/aggregator/aligned_layer/aggregator/cmd/main.go
40+
41+
- name: Move compiled aggregator to user directory
42+
copy:
43+
src: /tmp/aggregator/aligned_layer/build/aligned-aggregator
44+
dest: /home/{{ ansible_user }}/repos/aggregator/aligned_layer/build/aligned-aggregator
45+
remote_src: true
46+
47+
- name: Remove Aligned repository on /tmp/
48+
file:
49+
path: /tmp/aggregator/aligned_layer/
50+
state: absent
51+
52+
- name: Upload config file for aggregator
53+
template:
54+
src: config-files/config-aggregator.yaml.j2
55+
dest: "/home/{{ ansible_user }}/config/config-aggregator.yaml"
56+
force: yes
57+
vars:
58+
aligned_layer_deployment_config_file_path: "{{ lookup('ini', 'aligned_layer_deployment_config_file_path', file='ini/config-aggregator.ini') }}"
59+
eigen_layer_deployment_config_file_path: "{{ lookup('ini', 'eigen_layer_deployment_config_file_path', file='ini/config-aggregator.ini') }}"
60+
eth_rpc_url: "{{ lookup('ini', 'eth_rpc_url', file='ini/config-aggregator.ini') }}"
61+
eth_rpc_url_fallback: "{{ lookup('ini', 'eth_rpc_url_fallback', file='ini/config-aggregator.ini') }}"
62+
eth_ws_url: "{{ lookup('ini', 'eth_ws_url', file='ini/config-aggregator.ini') }}"
63+
eth_ws_url_fallback: "{{ lookup('ini', 'eth_ws_url_fallback', file='ini/config-aggregator.ini') }}"
64+
ecdsa_private_key_store_path: "{{ lookup('ini', 'ecdsa_private_key_store_path', file='ini/config-aggregator.ini') }}"
65+
ecdsa_private_key_store_password: "{{ lookup('ini', 'ecdsa_private_key_store_password', file='ini/config-aggregator.ini') }}"
66+
bls_private_key_store_path: "{{ lookup('ini', 'bls_private_key_store_path', file='ini/config-aggregator.ini') }}"
67+
bls_private_key_store_password: "{{ lookup('ini', 'bls_private_key_store_password', file='ini/config-aggregator.ini') }}"
68+
enable_metrics: "{{ lookup('ini', 'enable_metrics', file='ini/config-aggregator.ini') }}"
69+
metrics_ip_port_address: "{{ lookup('ini', 'metrics_ip_port_address', file='ini/config-aggregator.ini') }}"
70+
telemetry_ip_port_address: "{{ lookup('ini', 'telemetry_ip_port_address', file='ini/config-aggregator.ini') }}"
71+
72+
- name: Add service to systemd
73+
template:
74+
src: services/aggregator.service.j2
75+
dest: "/home/{{ ansible_user }}/.config/systemd/user/aggregator.service"
76+
force: yes
77+
78+
- name: Restart aggregator service
79+
systemd_service:
80+
name: aggregator
81+
state: restarted
82+
enabled: true
83+
scope: user
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# https://everythingcoding.in/go-setup-through-ansible/
2+
- name: Go Setup
3+
hosts: "{{ host }}"
4+
vars:
5+
version: 1.22.2
6+
7+
tasks:
8+
- name: check if go is installed
9+
stat:
10+
path: /usr/local/go/bin/go
11+
register: go_exists
12+
13+
- name: get golang download link
14+
set_fact:
15+
go_download_url: >-
16+
{% if ansible_architecture == 'x86_64' %}
17+
https://go.dev/dl/go{{ version }}.linux-amd64.tar.gz
18+
{% elif ansible_architecture == 'aarch64' %}
19+
https://go.dev/dl/go{{ version }}.linux-arm64.tar.gz
20+
{% endif %}
21+
22+
- name: download Go tarball
23+
when: not go_exists.stat.exists
24+
get_url:
25+
url: "{{ go_download_url }}"
26+
dest: "/tmp/{{ go_download_url | basename }}"
27+
mode: '0755'
28+
29+
- name: install Go
30+
when: not go_exists.stat.exists
31+
ansible.builtin.unarchive:
32+
src: "/tmp/{{ go_download_url | basename }}"
33+
dest: /usr/local/
34+
remote_src: yes
35+
become: yes
36+
vars:
37+
ansible_ssh_user: admin
38+
39+
- name: update user PATH
40+
when: not go_exists.stat.exists
41+
lineinfile:
42+
path: "/home/{{ ansible_user }}/.bashrc"
43+
line: "{{ item }}"
44+
state: present
45+
with_items:
46+
- 'export PATH=$PATH:/usr/local/go/bin'
47+
- 'export GOPATH=$HOME/go'
48+
- 'export PATH=$PATH:$GOPATH/bin'
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[global]
2+
aligned_layer_deployment_config_file_path=/home/dev/repos/aggregator/aligned_layer/contracts/script/output/devnet/alignedlayer_deployment_output.json
3+
eigen_layer_deployment_config_file_path=/home/dev/repos/aggregator/aligned_layer/contracts/script/output/devnet/eigenlayer_deployment_output.json
4+
eth_rpc_url=http://100.71.4.115:8545
5+
eth_rpc_url_fallback=http://100.71.4.115:8550
6+
eth_ws_url=ws://100.71.4.115:8546
7+
eth_ws_url_fallback=ws://100.71.4.115:8551
8+
ecdsa_private_key_store_path=/home/dev/repos/aggregator/aligned_layer/config-files/anvil.aggregator.ecdsa.key.json
9+
ecdsa_private_key_store_password=
10+
bls_private_key_store_path=/home/dev/repos/aggregator/aligned_layer/config-files/anvil.aggregator.bls.key.json
11+
bls_private_key_store_password=
12+
enable_metrics=true
13+
metrics_ip_port_address=100.106.174.11:9091
14+
telemetry_ip_port_address=100.96.200.99:4001
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[global]
2+
aligned_layer_deployment_config_file_path=
3+
eigen_layer_deployment_config_file_path=
4+
eth_rpc_url=
5+
eth_rpc_url_fallback=
6+
eth_ws_url=
7+
eth_ws_url_fallback=
8+
ecdsa_private_key_store_path=
9+
ecdsa_private_key_store_password=
10+
bls_private_key_store_path=
11+
bls_private_key_store_password=
12+
enable_metrics=
13+
metrics_ip_port_address=
14+
telemetry_ip_port_address=
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Common variables for all the services
2+
# 'production' only prints info and above. 'development' also prints debug
3+
environment: "production"
4+
aligned_layer_deployment_config_file_path: "{{ aligned_layer_deployment_config_file_path }}"
5+
eigen_layer_deployment_config_file_path: "{{ eigen_layer_deployment_config_file_path }}"
6+
eth_rpc_url: "{{ eth_rpc_url }}"
7+
eth_rpc_url_fallback: "{{ eth_rpc_url_fallback }}"
8+
eth_ws_url: "{{ eth_ws_url }}"
9+
eth_ws_url_fallback: "{{ eth_ws_url_fallback }}"
10+
eigen_metrics_ip_port_address: "localhost:9090"
11+
12+
## ECDSA Configurations
13+
ecdsa:
14+
private_key_store_path: "{{ ecdsa_private_key_store_path }}"
15+
private_key_store_password: "{{ ecdsa_private_key_store_password }}"
16+
17+
## BLS Configurations
18+
bls:
19+
private_key_store_path: "{{ bls_private_key_store_path }}"
20+
private_key_store_password: "{{ bls_private_key_store_password }}"
21+
22+
## Aggregator Configurations
23+
aggregator:
24+
server_ip_port_address: localhost:8090
25+
bls_public_key_compendium_address:
26+
avs_service_manager_address:
27+
enable_metrics: {{ enable_metrics }}
28+
metrics_ip_port_address: "{{ metrics_ip_port_address }}"
29+
telemetry_ip_port_address: "{{ telemetry_ip_port_address }}"
30+
garbage_collector_period: 2m #The period of the GC process. Suggested value for Prod: '168h' (7 days)
31+
garbage_collector_tasks_age: 20 #The age of tasks that will be removed by the GC, in blocks. Suggested value for prod: '216000' (30 days)
32+
garbage_collector_tasks_interval: 10 #The interval of queried blocks to get an old batch. Suggested value for prod: '900' (3 hours)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
[Unit]
2+
Description=Aggregator
3+
After=network.target
4+
5+
[Service]
6+
Type=simple
7+
WorkingDirectory=/home/{{ ansible_user }}/repos/aggregator/aligned_layer/aggregator
8+
ExecStart=/home/{{ ansible_user }}/repos/aggregator/aligned_layer/build/aligned-aggregator --config /home/{{ ansible_user }}/config/config-aggregator.yaml
9+
Restart=always
10+
RestartSec=1
11+
StartLimitBurst=100
12+
LimitNOFILE=100000
13+
14+
[Install]
15+
WantedBy=multi-user.target

infra/ansible/stage_inventory.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
aggregator:
22
hosts:
33
aligned-holesky-aggregator-1:
4-
ansible_host: aligned-holesky-stage-1-aggregator
4+
ansible_host: aligned-holesky-stage-2-aggregator
55
admin_user: admin
6-
ansible_user: app
6+
ansible_user: dev
77
ansible_python_interpreter: /usr/bin/python3
88
batcher:
99
hosts:

0 commit comments

Comments
 (0)