mirror of
https://github.com/matter-labs/ansible-en-role.git
synced 2025-12-06 10:59:56 +00:00
## What ❔ Subj ## Why ❔ QoL ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [x] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Documentation comments have been added / updated.
134 lines
4.2 KiB
YAML
134 lines
4.2 KiB
YAML
---
|
|
- name: Create configuration directory
|
|
ansible.builtin.file:
|
|
path: "{{ configuration_directory }}"
|
|
state: directory
|
|
mode: '0755'
|
|
|
|
- name: Create storage directories
|
|
ansible.builtin.file:
|
|
path: "{{ storage_directory }}/{{ item }}"
|
|
state: directory
|
|
mode: '0755'
|
|
loop:
|
|
- db
|
|
- db/lightweight-new
|
|
- db/state_keeper
|
|
|
|
- name: "Verify that required variables are defined"
|
|
ansible.builtin.assert:
|
|
that:
|
|
- required_var != ""
|
|
fail_msg: "{{ required_var }} needs to be set for the role to work"
|
|
success_msg: "Required variable {{ required_var }} isn't empty"
|
|
loop_control:
|
|
loop_var: required_var
|
|
with_items:
|
|
- database_name
|
|
- database_username
|
|
- database_password
|
|
- eth_l1_url
|
|
- main_node_url
|
|
- l2_chain_id
|
|
- l1_chain_id
|
|
|
|
- name: "Verify that required variables for replication is set"
|
|
when: enable_postgres_replication
|
|
ansible.builtin.assert:
|
|
that:
|
|
- postgress_replication_required_var != ""
|
|
fail_msg: "{{ postgress_replication_required_var }} needs to be set for the role for postgres replication to work"
|
|
success_msg: "Required variable for postgres replication {{ postgress_replication_required_var }} isn't empty"
|
|
loop_control:
|
|
loop_var: postgress_replication_required_var
|
|
with_items:
|
|
- enable_postgres_replication
|
|
- postgres_replication_bind_address
|
|
- postgres_replica_address
|
|
- postgres_replications_arguments
|
|
- postgres_replica_user_name
|
|
- postgres_replica_user_password
|
|
|
|
- name: Check required en vars empty
|
|
ansible.builtin.fail:
|
|
msg: "Variable '{{ item }}' is empty"
|
|
when: vars[item] == ""
|
|
with_items: "{{ en_required_variables }}"
|
|
- name: "Verify consensus debug port configuration"
|
|
ansible.builtin.fail:
|
|
msg: "Cannot expose consensus debug port (expose_consensus_debug_port=true) if it is not enabled (enable_consensus_debug_port=false)."
|
|
when:
|
|
- enable_consensus
|
|
- expose_consensus_debug_port
|
|
- not enable_consensus_debug_port
|
|
|
|
- name: Create main configs
|
|
ansible.builtin.template:
|
|
src: '{{ item.src }}'
|
|
dest: '{{ item.dest }}'
|
|
mode: '0644'
|
|
loop:
|
|
- src: "templates/docker-compose.yaml.j2"
|
|
dest: "{{ configuration_directory }}/docker-compose.yaml"
|
|
- src: "templates/external_node.env.j2"
|
|
dest: "{{ configuration_directory }}/external_node.env"
|
|
- src: "templates/postgres.env.j2"
|
|
dest: "{{ configuration_directory }}/postgres.env"
|
|
loop_control:
|
|
label: "{{ item.dest }}"
|
|
|
|
- name: Create restore script
|
|
register: restore_dump_script
|
|
ansible.builtin.template:
|
|
src: 'templates/restore_dump.sh.j2'
|
|
dest: '{{ configuration_directory }}/restore_dump.sh'
|
|
mode: "a+x"
|
|
|
|
- name: Check required monitoring vars empty
|
|
ansible.builtin.fail:
|
|
msg: "Variable '{{ item }}' is empty"
|
|
when: enable_monitoring and ( vars[item] == "" )
|
|
with_items: "{{ monitoring_required_variables }}"
|
|
|
|
- name: Create monitoring configs
|
|
when: enable_monitoring
|
|
ansible.builtin.template:
|
|
src: '{{ item.src }}'
|
|
dest: '{{ item.dest }}'
|
|
mode: '0644'
|
|
loop:
|
|
- src: "templates/monitoring.yaml.j2"
|
|
dest: "{{ configuration_directory }}/monitoring.yaml"
|
|
- src: "templates/vmagent-config.yml.j2"
|
|
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'
|
|
notify: Restart external-node service
|
|
|
|
- name: Decrypt consensus_secrets
|
|
when: enable_consensus
|
|
ansible.builtin.copy:
|
|
src: "{{ consensus_secrets_file }}"
|
|
dest: "{{ configuration_directory }}/consensus_secrets.yaml"
|
|
decrypt: true
|
|
mode: '0600'
|
|
notify: Restart external-node service
|
|
|
|
- name: Set docker compose files list
|
|
ansible.builtin.set_fact:
|
|
docker_compose_files: "{{ ['docker-compose.yaml'] + (['monitoring.yaml'] if enable_monitoring else []) }}"
|
|
|
|
- name: Run docker compose services (non-blocking)
|
|
community.docker.docker_compose_v2:
|
|
project_src: "{{ configuration_directory }}"
|
|
files: "{{ docker_compose_files }}"
|
|
state: present
|
|
pull: "{{ docker_pull_policy | default('missing') }}"
|
|
recreate: "{{ 'always' if restore_dump_script.changed else 'auto' }}"
|
|
wait: false
|