mirror of
https://github.com/matter-labs/ansible-en-role.git
synced 2025-12-06 10:59:56 +00:00
Compare commits
29 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 605525c7ba | |||
| 5bdeb0fcfa | |||
| bf186104d4 | |||
| 493e5ceffc | |||
| 7a77daacf3 | |||
| 8290a1cd9b | |||
| 191ebeced5 | |||
| 0cdbf98bf1 | |||
| ce94f307e7 | |||
| 9a8b0af6c3 | |||
| 7500e2b2da | |||
| ace0df965b | |||
| e8d79755da | |||
| 160f497294 | |||
| cdf5deb718 | |||
| cbf199a152 | |||
| c8a8c1b76c | |||
| 7fcf8ab7b6 | |||
| 2c04aabc1a | |||
| 875c50be71 | |||
| 135adfdeb6 | |||
| 0ed6245a1d | |||
| a240fac3ec | |||
| eed88e8b72 | |||
| 47edb8a161 | |||
| d5c66009cb | |||
| 437b174a25 | |||
| 842af18f5c | |||
| 7f2102550b |
12
README.md
12
README.md
@ -100,8 +100,7 @@ Basic auth secret can be generated by `htpasswd` and `sed` for interpolation:
|
|||||||
Skip this step if you are recovering from a snapshot!
|
Skip this step if you are recovering from a snapshot!
|
||||||
|
|
||||||
* [Era Mainnet latest dump](https://storage.googleapis.com/zksync-era-mainnet-external-node-backups/external_node_latest.pgdump)
|
* [Era Mainnet latest dump](https://storage.googleapis.com/zksync-era-mainnet-external-node-backups/external_node_latest.pgdump)
|
||||||
* [Era Sepolia Testnet latest dump](https://storage.googleapis.com/zksync-era-boojnet-external-node-snapshots/external_node_latest.pgdump)
|
* [Era Sepolia Testnet latest dump](https://storage.googleapis.com/zksync-era-testnet-sepolia-external-node-backups/external_node_latest.pgdump)
|
||||||
* [Era Goerli Testnet latest dump](https://storage.googleapis.com/zksync-era-testnet-external-node-backups/external_node_latest.pgdump)
|
|
||||||
|
|
||||||
Downloaded dump file should be placed into `{{ storage_directory }}/pg_backups` directory (`/usr/src/en/pg_backups` by default)
|
Downloaded dump file should be placed into `{{ storage_directory }}/pg_backups` directory (`/usr/src/en/pg_backups` by default)
|
||||||
|
|
||||||
@ -124,13 +123,18 @@ vm_auth_password
|
|||||||
|
|
||||||
## Snapshots Recovery
|
## Snapshots Recovery
|
||||||
|
|
||||||
example config enabling recovery from a snapshot
|
Example config enabling recovery from a snapshot:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- enable_snapshots_recovery: true
|
- enable_snapshots_recovery: true
|
||||||
- snapshots_bucket_base_url: "zksync-era-mainnet-external-node-snapshots"
|
- snapshots_bucket_base_url: "snapshots-bucket-name"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Snapshot buckets:
|
||||||
|
|
||||||
|
* Era Mainnet: `zksync-era-mainnet-external-node-snapshots`
|
||||||
|
* Era Sepolia Testnet: `zksync-era-boojnet-external-node-snapshots`
|
||||||
|
|
||||||
## Example Playbook
|
## Example Playbook
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
|
|||||||
@ -11,8 +11,9 @@ docker_compose_version: "v2.23.0"
|
|||||||
# Versions of External Node and 3rd party components
|
# Versions of External Node and 3rd party components
|
||||||
traefik_version: 2.11
|
traefik_version: 2.11
|
||||||
postgres_version: 14
|
postgres_version: 14
|
||||||
external_node_version: 21.0.2
|
external_node_version: 24.16.0
|
||||||
vmagent_version: 1.95.1
|
external_node_raw_docker_tag: ""
|
||||||
|
vmagent_version: 1.100.1
|
||||||
cadvisor_version: 0.47.2
|
cadvisor_version: 0.47.2
|
||||||
postgres_exporter_version: 0.15.0
|
postgres_exporter_version: 0.15.0
|
||||||
|
|
||||||
@ -72,6 +73,12 @@ force_pg_restore: false
|
|||||||
enable_snapshots_recovery: false
|
enable_snapshots_recovery: false
|
||||||
snapshots_bucket_base_url: ""
|
snapshots_bucket_base_url: ""
|
||||||
|
|
||||||
|
# https://github.com/matter-labs/zksync-era/blob/main/docs/guides/external-node/09_decentralization.md
|
||||||
|
enable_consensus: false
|
||||||
|
consensus_secrets_file: ""
|
||||||
|
consensus_port: 3054
|
||||||
|
consensus_outbound: []
|
||||||
|
|
||||||
# External Node and database options
|
# External Node and database options
|
||||||
database_name: ""
|
database_name: ""
|
||||||
database_username: ""
|
database_username: ""
|
||||||
|
|||||||
@ -5,7 +5,7 @@ roles:
|
|||||||
version: "7.1.0"
|
version: "7.1.0"
|
||||||
- name: external_node
|
- name: external_node
|
||||||
src: https://github.com/matter-labs/ansible-en-role
|
src: https://github.com/matter-labs/ansible-en-role
|
||||||
version: "v3.0.0"
|
version: "v3.3.0"
|
||||||
|
|
||||||
collections:
|
collections:
|
||||||
- name: community.general
|
- name: community.general
|
||||||
|
|||||||
@ -49,6 +49,14 @@
|
|||||||
source: "{{ loadbalancer_ip | mandatory }}"
|
source: "{{ loadbalancer_ip | mandatory }}"
|
||||||
jump: ACCEPT
|
jump: ACCEPT
|
||||||
|
|
||||||
|
- name: Allow consensus port traffic from any IP
|
||||||
|
when: enable_consensus
|
||||||
|
ansible.builtin.iptables:
|
||||||
|
chain: INPUT
|
||||||
|
protocol: tcp
|
||||||
|
destination_port: "{{ consensus_port }}"
|
||||||
|
jump: ACCEPT
|
||||||
|
|
||||||
- name: Set default policy to DROP
|
- name: Set default policy to DROP
|
||||||
ansible.builtin.iptables:
|
ansible.builtin.iptables:
|
||||||
chain: INPUT
|
chain: INPUT
|
||||||
|
|||||||
@ -38,7 +38,7 @@
|
|||||||
when: vars[item] == ""
|
when: vars[item] == ""
|
||||||
with_items: "{{ en_required_variables }}"
|
with_items: "{{ en_required_variables }}"
|
||||||
|
|
||||||
- name: Copy main configs
|
- name: Create main configs
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: '{{ item.src }}'
|
src: '{{ item.src }}'
|
||||||
dest: '{{ item.dest }}'
|
dest: '{{ item.dest }}'
|
||||||
@ -51,7 +51,7 @@
|
|||||||
- src: "templates/postgres.env.j2"
|
- src: "templates/postgres.env.j2"
|
||||||
dest: "{{ configuration_directory }}/postgres.env"
|
dest: "{{ configuration_directory }}/postgres.env"
|
||||||
|
|
||||||
- name: Copy restore script
|
- name: Create restore script
|
||||||
register: restore_dump_script
|
register: restore_dump_script
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: 'templates/restore_dump.sh.j2'
|
src: 'templates/restore_dump.sh.j2'
|
||||||
@ -64,7 +64,7 @@
|
|||||||
when: enable_monitoring and ( vars[item] == "" )
|
when: enable_monitoring and ( vars[item] == "" )
|
||||||
with_items: "{{ monitoring_required_variables }}"
|
with_items: "{{ monitoring_required_variables }}"
|
||||||
|
|
||||||
- name: Copy monitoring configs
|
- name: Create monitoring configs
|
||||||
when: enable_monitoring
|
when: enable_monitoring
|
||||||
ansible.builtin.template:
|
ansible.builtin.template:
|
||||||
src: '{{ item.src }}'
|
src: '{{ item.src }}'
|
||||||
@ -76,23 +76,38 @@
|
|||||||
- src: "templates/vmagent-config.yml.j2"
|
- src: "templates/vmagent-config.yml.j2"
|
||||||
dest: "{{ configuration_directory }}/vmagent-config.yml"
|
dest: "{{ configuration_directory }}/vmagent-config.yml"
|
||||||
|
|
||||||
|
- name: Create consensus config
|
||||||
|
when: enable_consensus
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: "templates/consensus_config.yaml.j2"
|
||||||
|
dest: "{{ configuration_directory }}/consensus_config.yaml"
|
||||||
|
mode: '0644'
|
||||||
|
|
||||||
|
- name: Decrypt consensus_secrets
|
||||||
|
when: enable_consensus
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "{{ consensus_secrets_file }}"
|
||||||
|
dest: "{{ configuration_directory }}/consensus_secrets.yaml"
|
||||||
|
decrypt: true
|
||||||
|
mode: '0600'
|
||||||
|
|
||||||
- name: Run docker-compose without monitoring
|
- name: Run docker-compose without monitoring
|
||||||
when: not enable_monitoring
|
when: not enable_monitoring
|
||||||
ansible.builtin.shell:
|
ansible.builtin.shell:
|
||||||
cmd: nohup docker compose -f docker-compose.yaml up -d &
|
cmd: nohup docker compose -f docker-compose.yaml up -d </dev/null >/dev/null 2>&1 &
|
||||||
chdir: "{{ configuration_directory }}"
|
chdir: "{{ configuration_directory }}"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Run docker-compose with monitoring
|
- name: Run docker-compose with monitoring
|
||||||
when: enable_monitoring and (not restore_dump_script.changed)
|
when: enable_monitoring and (not restore_dump_script.changed)
|
||||||
ansible.builtin.shell:
|
ansible.builtin.shell:
|
||||||
cmd: nohup docker compose -f monitoring.yaml -f docker-compose.yaml up -d &
|
cmd: nohup docker compose -f monitoring.yaml -f docker-compose.yaml up -d </dev/null >/dev/null 2>&1 &
|
||||||
chdir: "{{ configuration_directory }}"
|
chdir: "{{ configuration_directory }}"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Run docker-compose with monitoring with recreation
|
- name: Run docker-compose with monitoring with recreation
|
||||||
when: enable_monitoring and restore_dump_script.changed
|
when: enable_monitoring and restore_dump_script.changed
|
||||||
ansible.builtin.shell:
|
ansible.builtin.shell:
|
||||||
cmd: nohup docker compose -f monitoring.yaml -f docker-compose.yaml up -d --force-recreate &
|
cmd: nohup docker compose -f monitoring.yaml -f docker-compose.yaml up -d --force-recreate </dev/null >/dev/null 2>&1 &
|
||||||
chdir: "{{ configuration_directory }}"
|
chdir: "{{ configuration_directory }}"
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|||||||
9
templates/consensus_config.yaml.j2
Normal file
9
templates/consensus_config.yaml.j2
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
server_addr: '0.0.0.0:3054'
|
||||||
|
public_addr: '{{ ansible_default_ipv4.address }}:{{ consensus_port }}'
|
||||||
|
max_payload_size: 5000000
|
||||||
|
gossip_dynamic_inbound_limit: 100
|
||||||
|
gossip_static_outbound:
|
||||||
|
{% for item in consensus_outbound %}
|
||||||
|
- key: {{ item.key }}
|
||||||
|
addr: {{ item.addr }}
|
||||||
|
{% endfor %}
|
||||||
@ -8,10 +8,13 @@ services:
|
|||||||
- "--log.level=INFO"
|
- "--log.level=INFO"
|
||||||
- "--providers.docker=true"
|
- "--providers.docker=true"
|
||||||
- "--providers.docker.exposedbydefault=false"
|
- "--providers.docker.exposedbydefault=false"
|
||||||
- "--entrypoints.web.address=:80"
|
- "--entryPoints.web.address=:80"
|
||||||
- "--entrypoints.external_node_health.address=:3080"
|
- "--entryPoints.external_node_health.address=:3080"
|
||||||
|
{% if enable_consensus %}
|
||||||
|
- "--entryPoints.external_node_consensus.address=:{{ consensus_port }}"
|
||||||
|
{% endif %}
|
||||||
{% if enable_tls %}
|
{% if enable_tls %}
|
||||||
- "--entrypoints.websecure.address=:443"
|
- "--entryPoints.websecure.address=:443"
|
||||||
- "--certificatesresolvers.en_resolver.acme.tlschallenge=true"
|
- "--certificatesresolvers.en_resolver.acme.tlschallenge=true"
|
||||||
- "--certificatesresolvers.en_resolver.acme.storage=/letsencrypt/acme.json"
|
- "--certificatesresolvers.en_resolver.acme.storage=/letsencrypt/acme.json"
|
||||||
- "--certificatesresolvers.myresolver.acme.email={{ acme_email }}"
|
- "--certificatesresolvers.myresolver.acme.email={{ acme_email }}"
|
||||||
@ -76,12 +79,20 @@ services:
|
|||||||
{% if enable_basic_auth %}
|
{% if enable_basic_auth %}
|
||||||
- "traefik.http.routers.external_node_main.middlewares=external_node_auth"
|
- "traefik.http.routers.external_node_main.middlewares=external_node_auth"
|
||||||
- "traefik.http.middlewares.external_node_auth.basicauth.users={{ basic_auth_secret }}"
|
- "traefik.http.middlewares.external_node_auth.basicauth.users={{ basic_auth_secret }}"
|
||||||
|
{% endif %}
|
||||||
|
{% if enable_consensus %}
|
||||||
|
- "traefik.tcp.services.external_node_consensus.loadbalancer.server.port={{ consensus_port }}"
|
||||||
|
- "traefik.tcp.routers.external_node_consensus.entrypoints=external_node_consensus"
|
||||||
|
- "traefik.tcp.routers.external_node_consensus.service=external_node_consensus"
|
||||||
{% endif %}
|
{% endif %}
|
||||||
expose:
|
expose:
|
||||||
- {{ rpc_http_port }}
|
- {{ rpc_http_port }}
|
||||||
- {{ rpc_ws_port }}
|
- {{ rpc_ws_port }}
|
||||||
- {{ healthcheck_port }}
|
- {{ healthcheck_port }}
|
||||||
- {{ metrics_port }}
|
- {{ metrics_port }}
|
||||||
|
{% if enable_consensus %}
|
||||||
|
- {{ consensus_port }}
|
||||||
|
{% endif %}
|
||||||
environment:
|
environment:
|
||||||
ZKSYNC_HOME: "/"
|
ZKSYNC_HOME: "/"
|
||||||
EN_STATE_CACHE_PATH: /db/state_keeper
|
EN_STATE_CACHE_PATH: /db/state_keeper
|
||||||
@ -96,6 +107,10 @@ services:
|
|||||||
EN_MAX_BLOCKS_PER_TREE_BATCH: 200
|
EN_MAX_BLOCKS_PER_TREE_BATCH: 200
|
||||||
MISC_LOG_FORMAT: json
|
MISC_LOG_FORMAT: json
|
||||||
RUST_LOG: {{ rust_log }}
|
RUST_LOG: {{ rust_log }}
|
||||||
|
{% if enable_consensus %}
|
||||||
|
EN_CONSENSUS_CONFIG_PATH: /etc/consensus_config.yaml
|
||||||
|
EN_CONSENSUS_SECRETS_PATH: /run/secrets/consensus_secrets
|
||||||
|
{% endif %}
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: [ "CMD", "curl", "-f", "http://localhost:{{ healthcheck_port }}/health" ]
|
test: [ "CMD", "curl", "-f", "http://localhost:{{ healthcheck_port }}/health" ]
|
||||||
interval: 1m
|
interval: 1m
|
||||||
@ -104,10 +119,24 @@ services:
|
|||||||
start_period: 1m
|
start_period: 1m
|
||||||
volumes:
|
volumes:
|
||||||
- "{{ storage_directory }}/db:/db"
|
- "{{ storage_directory }}/db:/db"
|
||||||
|
{% if enable_consensus %}
|
||||||
|
- "{{ configuration_directory }}/consensus_config.yaml:/etc/consensus_config.yaml"
|
||||||
|
{% endif %}
|
||||||
env_file:
|
env_file:
|
||||||
- "external_node.env"
|
- "external_node.env"
|
||||||
- "postgres.env"
|
- "postgres.env"
|
||||||
{% if enable_snapshots_recovery %}
|
|
||||||
command:
|
command:
|
||||||
|
{% if enable_snapshots_recovery %}
|
||||||
- --enable-snapshots-recovery
|
- --enable-snapshots-recovery
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if enable_consensus %}
|
||||||
|
- --enable-consensus
|
||||||
|
secrets:
|
||||||
|
- consensus_secrets
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if enable_consensus %}
|
||||||
|
secrets:
|
||||||
|
consensus_secrets:
|
||||||
|
file: consensus_secrets.yaml
|
||||||
|
{% endif %}
|
||||||
|
|||||||
@ -33,7 +33,8 @@ scrape_configs:
|
|||||||
- job_name: traefik
|
- job_name: traefik
|
||||||
static_configs:
|
static_configs:
|
||||||
- targets:
|
- targets:
|
||||||
- "traefik:8080"
|
# traefik uses network host, so docker DNS wouldn't work.
|
||||||
|
- "127.0.0.1:8080"
|
||||||
relabel_configs:
|
relabel_configs:
|
||||||
- source_labels: [instance]
|
- source_labels: [instance]
|
||||||
target_label: instance
|
target_label: instance
|
||||||
|
|||||||
Reference in New Issue
Block a user