From b37acdf4b9c7b59f3ee41b0066e3758451ae98dd Mon Sep 17 00:00:00 2001 From: Anton Iakimov Date: Tue, 10 Oct 2023 15:04:36 +0200 Subject: [PATCH] ansible: setup postgres store db --- ansible/group_vars/node-db.yml | 22 ++++++++++++++++++++++ ansible/group_vars/node.yml | 10 +++++++--- ansible/main.yml | 10 ++++++++-- ansible/requirements.yml | 4 ++++ 4 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 ansible/group_vars/node-db.yml diff --git a/ansible/group_vars/node-db.yml b/ansible/group_vars/node-db.yml new file mode 100644 index 0000000..581672d --- /dev/null +++ b/ansible/group_vars/node-db.yml @@ -0,0 +1,22 @@ +--- + +postgres_ha_service_name: 'nim-waku-db' +postgres_ha_cont_image: 'postgres:15.1-alpine' + +postgres_ha_is_master: true +postgres_ha_replica_allowed_addresses: [] + +postgres_ha_admin_user: 'postgres' +postgres_ha_admin_pass: '{{lookup("bitwarden", "fleets/waku/"+stage+"/db/admin")}}' + +postgres_ha_databases: + - name: 'nim-waku' + user: 'nim-waku' + pass: '{{lookup("bitwarden", "fleets/waku/"+stage+"/db/nim-waku")}}' + +# Open PostgreSQL Port +open_ports_default_comment: '{{ postgres_ha_service_name }}' +open_ports_default_chain: 'SERVICES' +open_ports_default_protocol: 'tcp' +open_ports_list: + - { port: '{{ postgres_ha_cont_port }}', ipset: '{{ env }}.{{ stage }}' } diff --git a/ansible/group_vars/node.yml b/ansible/group_vars/node.yml index 50afe39..1ff6349 100644 --- a/ansible/group_vars/node.yml +++ b/ansible/group_vars/node.yml @@ -2,13 +2,13 @@ # Tag dependent on fleet: test # TODO: change to waku with CI on -nim_waku_cont_tag: 'deploy-wakuv2-{{ stage }}' +nim_waku_cont_tag: 'deploy-shards-{{ stage }}' nim_waku_cont_name: 'nim-waku' nim_waku_log_level: 'debug' -nim_waku_protocols_enabled: ['relay', 'filter', 'lightpush', 'peer-exchange'] +nim_waku_protocols_enabled: ['relay', 'store', 'filter', 'lightpush', 'peer-exchange'] nim_waku_disc_v5_enabled: true nim_waku_dns4_domain_name: '{{ dns_entry }}' -nim_waku_node_key: '{{lookup("bitwarden", "fleets/waku/"+stage+"/nodekeys", field=hostname)}}' +nim_waku_node_key: '{{lookup("bitwarden", "fleets/"+env+"/"+stage+"/nodekeys", field=hostname)}}' # Subscribe to all shards nim_waku_pubsub_topics: @@ -32,6 +32,10 @@ nim_waku_rpc_tcp_port: 8545 nim_waku_p2p_max_connections: 300 # Store +nim_waku_store_message_db_name: 'nim-waku' +nim_waku_store_message_db_user: 'nim-waku' +nim_waku_store_message_db_pass: '{{lookup("bitwarden", "fleets/"+env+"/"+stage+"/db/nim-waku")}}' +nim_waku_store_message_db_url: 'postgres://{{ nim_waku_store_message_db_user}}:{{ nim_waku_store_message_db_pass}}@node-db-01.{{ ansible_domain }}.wg:5432/{{nim_waku_store_message_db_name}}' nim_waku_store_message_retention_policy: 'time:2592000' # 30 days # DNS Discovery diff --git a/ansible/main.yml b/ansible/main.yml index 8c9975d..5df9364 100644 --- a/ansible/main.yml +++ b/ansible/main.yml @@ -10,8 +10,7 @@ changed_when: false - name: Configure Waku Nodes - hosts: - - waku + hosts: node roles: - { role: open-ports, tags: open-ports } - { role: swap-file, tags: swap-file } @@ -19,3 +18,10 @@ # - { role: conn-limit, tags: conn-limit } - { role: certbot, tags: certbot } - { role: nim-waku, tags: nim-waku } + +- name: Configure Waku Storage DB Nodes + hosts: node-db + roles: + - { role: open-ports, tags: open-ports } + - { role: swap-file, tags: swap-file } + - { role: infra-role-postgres-ha, tags: postgres-ha } diff --git a/ansible/requirements.yml b/ansible/requirements.yml index 7f4314c..d818e85 100644 --- a/ansible/requirements.yml +++ b/ansible/requirements.yml @@ -28,3 +28,7 @@ version: 0b0cbbe576f2facb6f9fea17b8c722bb8b36edca scm: git +- name: infra-role-postgres-ha + src: git@github.com:status-im/infra-role-postgres-ha.git + version: 8c10ac4c08681580dd5e60046178631579ef980e + scm: git