From 0a75a69a09f2c4e5bf9e8828cbff87c806aacbc3 Mon Sep 17 00:00:00 2001
From: Arthur Koziel <arthur@arthurkoziel.com>
Date: Tue, 22 Jun 2021 17:49:48 +0800
Subject: [PATCH] Deploy mainnet beacon nodes on hetzner server
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This will run multiple mainnet beacon nodes on the hetzner server. It
will use the `infra-role-beacon-node-linux` to build and run `stable`,
`unstable` and `testing` on the machine.

Signed-off-by: Arthur Koziel <arthur@arthurkoziel.com>
Signed-off-by: Jakub SokoĊ‚owski <jakub@status.im>
---
 ansible/group_vars/nimbus-mainnet-metal.yml   |  1 -
 ...ble-metal-01.he-eu-hel1.nimbus.mainnet.yml | 11 -------
 ansible/mainnet.yml                           | 33 ++++++++++++++-----
 ansible/requirements.yml                      |  5 +++
 4 files changed, 30 insertions(+), 20 deletions(-)
 delete mode 100644 ansible/host_vars/stable-metal-01.he-eu-hel1.nimbus.mainnet.yml

diff --git a/ansible/group_vars/nimbus-mainnet-metal.yml b/ansible/group_vars/nimbus-mainnet-metal.yml
index 243fe17..81271ff 100644
--- a/ansible/group_vars/nimbus-mainnet-metal.yml
+++ b/ansible/group_vars/nimbus-mainnet-metal.yml
@@ -1,6 +1,5 @@
 ---
 beacon_node_network: 'mainnet'
-beacon_node_cont_tag: 'stable-metal-01'
 
 # WARNING: Since these are Eth 2 bootnodes we need to keep the keys and IPs unchanged.
 #beacon_node_netkey: '{{lookup("passwordstore","services/Nimbus/netkey/"+hostname)}}'
diff --git a/ansible/host_vars/stable-metal-01.he-eu-hel1.nimbus.mainnet.yml b/ansible/host_vars/stable-metal-01.he-eu-hel1.nimbus.mainnet.yml
deleted file mode 100644
index 5889fb8..0000000
--- a/ansible/host_vars/stable-metal-01.he-eu-hel1.nimbus.mainnet.yml
+++ /dev/null
@@ -1,11 +0,0 @@
----
-# Docker image builds
-beacon_node_builds_docker_hub_user: '{{lookup("passwordstore", "cloud/DockerHub/user")}}'
-beacon_node_builds_docker_hub_token: '{{lookup("passwordstore", "cloud/DockerHub/token")}}'
-
-# The -small suffix is because of native compilation
-beacon_node_builds_branches:
-  - name: 'stable-metal-01'
-    version: 'stable'
-    targets: ['nimbus_beacon_node', 'nimbus_signing_process']
-    frequency: '*-*-* 12:00:00'
diff --git a/ansible/mainnet.yml b/ansible/mainnet.yml
index 3783304..ea2202a 100644
--- a/ansible/mainnet.yml
+++ b/ansible/mainnet.yml
@@ -9,16 +9,33 @@
     - local_action: command ./versioncheck.py
       changed_when: false
 
-- name: Configure build nodes
+- name: Configure network mainnet bootnodes
+  become: true
+  hosts: 'nimbus-mainnet-small'
+  roles:
+    - { role: get-geth-web3-urls,     tags: [ get-geth-web3-urls ] }
+    - { role: infra-role-beacon-node, tags: [ infra-role-beacon-node, beacon-node ] }
+
+- name: Deploy mainnet linux beacon nodes
   become: true
   hosts:
     - stable-metal-01.he-eu-hel1.nimbus.mainnet
-  roles:
-    - { role: beacon-node-builds,     tags: beacon-node-builds }
-
-- name: Configure network mainnet bootnodes
-  become: true
-  hosts: 'nimbus.mainnet'
   roles:
     - { role: get-geth-web3-urls,     tags: [ get-geth-web3-urls ] }
-    - { role: infra-role-beacon-node, tags: [ infra-role-beacon-node, beacon-node ] }
+  tasks:
+    - include_role: name=infra-role-beacon-node-linux
+      tags: [ infra-role-beacon-node-linux, beacon-node ]
+      vars:
+        beacon_node_repo_branch: '{{ node.branch }}'
+        beacon_node_build_frequency: '{{ node.build_frequency }}'
+        beacon_node_discovery_port: '{{ 9000 + port_offset }}'
+        beacon_node_listening_port: '{{ 9000 + port_offset }}'
+        beacon_node_metrics_port:   '{{ 9200 + port_offset }}'
+        beacon_node_rpc_port:       '{{ 9900 + port_offset }}'
+      with_items:
+        - { branch: 'stable', build_frequency: '*-*-* 12:00:00' }
+        - { branch: 'unstable', build_frequency: '*-*-* 14:00:00' }
+        - { branch: 'testing', build_frequency: '*-*-* 16:00:00' }
+      loop_control:
+        loop_var: node
+        index_var: port_offset
diff --git a/ansible/requirements.yml b/ansible/requirements.yml
index c0b06ce..10efe6d 100644
--- a/ansible/requirements.yml
+++ b/ansible/requirements.yml
@@ -39,6 +39,11 @@
   version: a14c9afe0293196f8b3cb45e86abcbaee3078d77
   scm: git
 
+- name: infra-role-beacon-node-linux
+  src: git@github.com:status-im/infra-role-beacon-node-linux.git
+  version: e69cebc8bd6bd5bf7f0cc1bb9ebd48a05cb31298
+  scm: git
+
 - name: infra-role-beacon-node-windows
   src: git@github.com:status-im/infra-role-beacon-node-windows.git
   version: 1809e84d48d31cac0b783ed3a2182fdd23e34779