Skip to content

Commit 4722a45

Browse files
authored
ci: ansible setup for batcher (#1371)
2 parents 879cb70 + 8dbb94e commit 4722a45

28 files changed

+411
-166
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ volume
1414
config-files/*.last_processed_batch.json
1515

1616
nonce_*.bin
17+
18+
infra/ansible/playbooks/ini/**.ini

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,3 +1006,21 @@ telemetry_dump_db:
10061006
telemetry_create_env:
10071007
@cd telemetry_api && \
10081008
cp .env.dev .env
1009+
1010+
__ANSIBLE__: ## ____
1011+
1012+
ansible_batcher_create_env: ## Create empty variables files for the Batcher deploy
1013+
@cp -n infra/ansible/playbooks/ini/caddy-batcher.ini.example infra/ansible/playbooks/ini/caddy-batcher.ini
1014+
@cp -n infra/ansible/playbooks/ini/config-batcher.ini.example infra/ansible/playbooks/ini/config-batcher.ini
1015+
@cp -n infra/ansible/playbooks/ini/env-batcher.ini.example infra/ansible/playbooks/ini/env-batcher.ini
1016+
@echo "Config files for the Batcher created in infra/ansible/playbooks/ini"
1017+
@echo "Please complete the values and run make ansible_batcher_deploy"
1018+
1019+
ansible_batcher_deploy: ## Deploy the Batcher. Parameters: INVENTORY, KEYSTORE
1020+
@if [ -z "$(INVENTORY)" ] || [ -z "$(KEYSTORE)" ]; then \
1021+
echo "Error: Both INVENTORY and KEYSTORE must be set."; \
1022+
exit 1; \
1023+
fi
1024+
@ansible-playbook infra/ansible/playbooks/batcher.yaml \
1025+
-i $(INVENTORY) \
1026+
-e "keystore_path=$(KEYSTORE)"

infra/ansible/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Guide to Deploy
2+
3+
## Batcher
4+
5+
To deploy the Batcher you need to set some variables and then run the Batcher playbook
6+
7+
Create the variables files:
8+
9+
```shell
10+
make ansible_batcher_create_env
11+
```
12+
13+
This will create the following files in `infra/ansible/playbooks/ini`
14+
15+
- `config-batcher.ini`
16+
- `env-batcher.ini`
17+
- `caddy-batcher.ini`
18+
19+
Now you have to set those variables.
20+
21+
Deploy the Batcher:
22+
23+
```shell
24+
make ansible_batcher_deploy INVENTORY=</path/to/inventory> KEYSTORE=<path/to/keystore>
25+
```

infra/ansible/batcher.yaml

Lines changed: 0 additions & 47 deletions
This file was deleted.

infra/ansible/eigenlayer-cli.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.

infra/ansible/go.yaml

Lines changed: 0 additions & 41 deletions
This file was deleted.
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
- name: Run setup playbook
2+
ansible.builtin.import_playbook: setup.yaml
3+
vars:
4+
host: batcher
5+
6+
- name: Run webserver playbook
7+
ansible.builtin.import_playbook: webserver.yaml
8+
vars:
9+
host: batcher
10+
11+
- name: Run go playbook
12+
ansible.builtin.import_playbook: go.yaml
13+
vars:
14+
host: batcher
15+
16+
- name: Run rust playbook
17+
ansible.builtin.import_playbook: rust.yaml
18+
vars:
19+
host: batcher
20+
21+
- name: Run eigenlayer-cli playbook
22+
ansible.builtin.import_playbook: eigenlayer-cli.yaml
23+
vars:
24+
host: batcher
25+
26+
- hosts: batcher
27+
28+
tasks:
29+
# Install required packages
30+
- name: Update apt and install required system packages
31+
become: true
32+
apt:
33+
pkg:
34+
- pkg-config
35+
- libssl-dev
36+
state: latest
37+
update_cache: true
38+
vars:
39+
ansible_ssh_user: "{{ admin_user }}"
40+
41+
# Create directories for each service
42+
- name: Create directories for each service if do not exist
43+
ansible.builtin.file:
44+
path: /home/{{ ansible_user }}/repos/batcher
45+
state: directory
46+
mode: '0755'
47+
owner: '{{ ansible_user }}'
48+
group: '{{ ansible_user }}'
49+
50+
# Clone Aligned repository for the service
51+
- name: Clone Aligned repository
52+
ansible.builtin.git:
53+
repo: https://github.com/yetanotherco/aligned_layer.git
54+
dest: /home/{{ ansible_user }}/repos/batcher/aligned_layer
55+
version: batcher_ansible
56+
recursive: false
57+
58+
# Build the batcher
59+
- name: Install deps
60+
make:
61+
chdir: /home/{{ ansible_user }}/repos/batcher/aligned_layer
62+
target: deps
63+
environment:
64+
PATH: "{{ ansible_env.PATH }}:/usr/local/go/bin:/home/{{ ansible_user }}/.cargo/bin"
65+
66+
- name: Install batcher
67+
make:
68+
chdir: /home/{{ ansible_user }}/repos/batcher/aligned_layer
69+
target: install_batcher
70+
environment:
71+
PATH: "{{ ansible_env.PATH }}:/usr/local/go/bin:/home/{{ ansible_user }}/.cargo/bin"
72+
73+
- name: Create systemd services directory
74+
file:
75+
path: "/home/{{ ansible_user }}/.config/systemd/user/"
76+
state: directory
77+
78+
- name: Add service to systemd
79+
template:
80+
src: services/batcher.service.j2
81+
dest: "/home/{{ ansible_user }}/.config/systemd/user/batcher.service"
82+
force: no
83+
84+
- name: Upload config file for batcher
85+
template:
86+
src: config-files/config-batcher.yaml.j2
87+
dest: "/home/{{ ansible_user }}/config/config-batcher-holesky.yaml"
88+
vars:
89+
aligned_layer_deployment_config_file_path: "{{ lookup('ini', 'aligned_layer_deployment_config_file_path', file='ini/config-batcher.ini') }}"
90+
eigen_layer_deployment_config_file_path: "{{ lookup('ini', 'eigen_layer_deployment_config_file_path', file='ini/config-batcher.ini') }}"
91+
eth_rpc_url: "{{ lookup('ini', 'eth_rpc_url', file='ini/config-batcher.ini') }}"
92+
eth_rpc_url_fallback: "{{ lookup('ini', 'eth_rpc_url_fallback', file='ini/config-batcher.ini') }}"
93+
eth_ws_url: "{{ lookup('ini', 'eth_ws_url', file='ini/config-batcher.ini') }}"
94+
eth_ws_url_fallback: "{{ lookup('ini', 'eth_ws_url_fallback', file='ini/config-batcher.ini') }}"
95+
ecdsa_private_key_store_path: "{{ lookup('ini', 'ecdsa_private_key_store_path', file='ini/config-batcher.ini') }}"
96+
ecdsa_private_key_store_password: "{{ lookup('ini', 'ecdsa_private_key_store_password', file='ini/config-batcher.ini') }}"
97+
batcher_replacement_private_key: "{{ lookup('ini', 'batcher_replacement_private_key', file='ini/config-batcher.ini') }}"
98+
99+
100+
- name: Upload env file for batcher
101+
template:
102+
src: config-files/env-batcher.j2
103+
dest: "/home/{{ ansible_user }}/config/.env.batcher"
104+
vars:
105+
secret_access_key: "{{ lookup('ini', 'secret_access_key', file='ini/env-batcher.ini') }}"
106+
region: "{{ lookup('ini', 'region', file='ini/env-batcher.ini') }}"
107+
access_key_id: "{{ lookup('ini', 'access_key_id', file='ini/env-batcher.ini') }}"
108+
bucket_name: "{{ lookup('ini', 'bucket_name', file='ini/env-batcher.ini') }}"
109+
download_endpoint: "{{ lookup('ini', 'download_endpoint', file='ini/env-batcher.ini') }}"
110+
log_level: "{{ lookup('ini', 'log_level', file='ini/env-batcher.ini') }}"
111+
112+
- name: Add reverse proxy to Caddy
113+
become: true
114+
template:
115+
src: caddy/Caddyfile.batcher.j2
116+
dest: "/etc/caddy/Caddyfile"
117+
vars:
118+
ansible_ssh_user: "{{ admin_user }}"
119+
batcher_domain: "{{ lookup('ini', 'batcher_domain', file='ini/caddy-batcher.ini') }}"
120+
121+
- name: Copy keystore to server
122+
ansible.builtin.copy:
123+
src: '{{ keystore_path }}'
124+
dest: /home/{{ ansible_user }}/.keystores/batcher
125+
owner: '{{ ansible_user }}'
126+
group: '{{ ansible_user }}'
127+
128+
- name: Start Batcher service
129+
ansible.builtin.systemd_service:
130+
name: batcher
131+
state: started
132+
enabled: true
133+
scope: user
134+
135+
- name: Restart Caddy service
136+
become: true
137+
ansible.builtin.systemd_service:
138+
name: caddy
139+
state: restarted
140+
vars:
141+
ansible_ssh_user: "{{ admin_user }}"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
- name: Eigenlayer CLI Setup
2+
hosts: "{{ host }}"
3+
4+
tasks:
5+
- name: check if eigenlayer is installed
6+
stat:
7+
path: /home/{{ ansible_user }}/bin/eigenlayer
8+
register: eigenlayer_exists
9+
10+
- name: Download Eigenlayer CLI
11+
when: not eigenlayer_exists.stat.exists
12+
get_url:
13+
url: https://raw.githubusercontent.com/layr-labs/eigenlayer-cli/master/scripts/install.sh
14+
dest: /tmp/eigenlayer.sh
15+
mode: '0755'
16+
17+
- name: Install Eigenlayer CLI
18+
when: not eigenlayer_exists.stat.exists
19+
shell: /tmp/eigenlayer.sh
20+
21+
- name: Add eigenlayer path to ~/.profile
22+
when: not eigenlayer_exists.stat.exists
23+
lineinfile:
24+
path: ~/.profile
25+
line: 'export PATH=$PATH:~/bin'
26+
state: present

0 commit comments

Comments
 (0)