From b9d97b808de5dad4b964818eb911005c41a22e21 Mon Sep 17 00:00:00 2001 From: Chris O'Neil Date: Tue, 3 Dec 2024 21:25:21 +0000 Subject: [PATCH] chore: update machine images to ubuntu 24.04 Initially the Telegraf configurations don't seem to be working with this new version. --- Justfile | 8 ++-- resources/ansible/create_node_image.yml | 4 +- .../roles/prerequisites/tasks/main.yml | 42 +++++++++++++++++-- .../roles/uploader-metrics/tasks/main.yml | 10 ++--- resources/packer/build/build.pkr.hcl | 2 +- resources/packer/node/node.pkr.hcl | 4 +- resources/scripts/install_ansible.sh | 6 ++- .../testnet/digital-ocean/dev.tfvars | 12 +++--- .../testnet/digital-ocean/staging.tfvars | 12 +++--- .../testnet/digital-ocean/variables.tf | 4 +- src/ansible/extra_vars.rs | 13 ------ src/ansible/provisioning.rs | 20 --------- 12 files changed, 69 insertions(+), 68 deletions(-) diff --git a/Justfile b/Justfile index 0e0d7241..089520c4 100644 --- a/Justfile +++ b/Justfile @@ -19,7 +19,7 @@ build-evm-node-image: build.pkr.hcl ) -build-staging-bootstrap-image: +build-bootstrap-image: #!/usr/bin/env bash ( cd resources/packer/node @@ -27,7 +27,7 @@ build-staging-bootstrap-image: packer build -var 'size=s-1vcpu-2gb' node.pkr.hcl ) -build-staging-node-image: +build-node-image: #!/usr/bin/env bash ( cd resources/packer/node @@ -35,7 +35,7 @@ build-staging-node-image: packer build -var 'size=s-2vcpu-4gb' node.pkr.hcl ) -build-staging-uploader-image: +build-uploader-image: #!/usr/bin/env bash ( cd resources/packer/node @@ -43,7 +43,7 @@ build-staging-uploader-image: packer build -var 'size=s-2vcpu-4gb' node.pkr.hcl ) -build-prod-nat-gateway-image: +build-nat-gateway-image: #!/usr/bin/env bash ( cd resources/packer/node diff --git a/resources/ansible/create_node_image.yml b/resources/ansible/create_node_image.yml index e0cc2999..a967d8da 100644 --- a/resources/ansible/create_node_image.yml +++ b/resources/ansible/create_node_image.yml @@ -1,9 +1,7 @@ --- - name: build a custom node image hosts: all - become: False + become: True roles: - role: prerequisites - become: True - role: filebeat - become: True diff --git a/resources/ansible/roles/prerequisites/tasks/main.yml b/resources/ansible/roles/prerequisites/tasks/main.yml index 0af822a5..20e72624 100644 --- a/resources/ansible/roles/prerequisites/tasks/main.yml +++ b/resources/ansible/roles/prerequisites/tasks/main.yml @@ -3,24 +3,58 @@ apt: update_cache: yes -# The retries are for random lock failures. +- name: prerequisites for adding telegraf repository + apt: + name: + - curl + - gnupg + state: present + +- name: add influxdata gpg key + ansible.builtin.command: > + curl -fsSL https://repos.influxdata.com/influxdata-archive_compat.key + -o /etc/apt/keyrings/influxdata-archive_compat.key + args: + creates: /etc/apt/keyrings/influxdata-archive_compat.key + +- name: add influxdata repository + ansible.builtin.copy: + dest: /etc/apt/sources.list.d/influxdata.list + content: "deb [signed-by=/etc/apt/keyrings/influxdata-archive_compat.key] https://repos.influxdata.com/ubuntu stable main" + owner: root + group: root + mode: '0644' + +- name: update apt cache for new repository + apt: + update_cache: yes + +- name: install telegraf + apt: + name: telegraf + state: present + register: result + until: result is succeeded + retries: 20 + delay: 10 + +# Retry logic for other package installations - name: install packages ansible.builtin.package: name: "{{ item }}" state: present with_items: - - graphviz # for the sn_auditor + - graphviz - heaptrack - jq - python3 - python3-pip - ripgrep - - telegraf - zip register: result until: result is succeeded retries: 20 delay: 10 -- name: install boto3 +- name: Install boto3 ansible.builtin.command: pip3 install boto3 --prefix /usr diff --git a/resources/ansible/roles/uploader-metrics/tasks/main.yml b/resources/ansible/roles/uploader-metrics/tasks/main.yml index 81e33fbd..3efb558e 100644 --- a/resources/ansible/roles/uploader-metrics/tasks/main.yml +++ b/resources/ansible/roles/uploader-metrics/tasks/main.yml @@ -106,8 +106,8 @@ systemd: daemon_reload: yes -- name: start telegraf service - systemd: - name: telegraf - enabled: yes - state: started \ No newline at end of file +# - name: start telegraf service +# systemd: +# name: telegraf +# enabled: yes +# state: started diff --git a/resources/packer/build/build.pkr.hcl b/resources/packer/build/build.pkr.hcl index 4edc0d20..16ca335a 100644 --- a/resources/packer/build/build.pkr.hcl +++ b/resources/packer/build/build.pkr.hcl @@ -17,7 +17,7 @@ variable "user_home" { variable "droplet_image" { type = string - default = "ubuntu-22-04-x64" + default = "ubuntu-24-04-x64" description = "" } diff --git a/resources/packer/node/node.pkr.hcl b/resources/packer/node/node.pkr.hcl index be54543c..3d57e486 100644 --- a/resources/packer/node/node.pkr.hcl +++ b/resources/packer/node/node.pkr.hcl @@ -17,7 +17,7 @@ variable "user_home" { variable "droplet_image" { type = string - default = "ubuntu-22-04-x64" + default = "ubuntu-24-04-x64" } variable "region" { @@ -41,7 +41,7 @@ source "digitalocean" "build" { image = var.droplet_image region = var.region size = var.size - snapshot_name = "safe_network-node-{{timestamp}}" + snapshot_name = "ant-node-{{timestamp}}" ssh_username = var.ssh_username } diff --git a/resources/scripts/install_ansible.sh b/resources/scripts/install_ansible.sh index 6f760e57..c5208305 100755 --- a/resources/scripts/install_ansible.sh +++ b/resources/scripts/install_ansible.sh @@ -1,9 +1,11 @@ #!/bin/bash +cat /etc/os-release + export DEBIAN_FRONTEND=noninteractive -max_retries=10 -retry_delay=5 +max_retries=20 +retry_delay=10 for i in $(seq 1 $max_retries); do echo "Update Apt index attempt $i of $max_retries..." diff --git a/resources/terraform/testnet/digital-ocean/dev.tfvars b/resources/terraform/testnet/digital-ocean/dev.tfvars index 35d1a6c0..fd4b02c1 100644 --- a/resources/terraform/testnet/digital-ocean/dev.tfvars +++ b/resources/terraform/testnet/digital-ocean/dev.tfvars @@ -1,15 +1,15 @@ bootstrap_droplet_size = "s-2vcpu-4gb" -bootstrap_droplet_image_id = 162461040 +bootstrap_droplet_image_id = 172040723 bootstrap_node_vm_count = 1 evm_node_droplet_size = "s-4vcpu-8gb" -evm_node_droplet_image_id = 167317579 +evm_node_droplet_image_id = 172040852 evm_node_vm_count = 1 -nat_gateway_droplet_image_id = 166664184 +nat_gateway_droplet_image_id = 172051596 node_droplet_size = "s-4vcpu-8gb" -node_droplet_image_id = 162460774 +node_droplet_image_id = 172040547 node_vm_count = 10 private_node_vm_count = 1 setup_nat_gateway = true uploader_droplet_size = "s-2vcpu-4gb" -uploader_droplet_image_id = 162461150 -uploader_vm_count = 1 \ No newline at end of file +uploader_droplet_image_id = 172051523 +uploader_vm_count = 1 diff --git a/resources/terraform/testnet/digital-ocean/staging.tfvars b/resources/terraform/testnet/digital-ocean/staging.tfvars index d9f3c555..7c8b2675 100644 --- a/resources/terraform/testnet/digital-ocean/staging.tfvars +++ b/resources/terraform/testnet/digital-ocean/staging.tfvars @@ -1,15 +1,15 @@ bootstrap_droplet_size = "s-2vcpu-4gb" -bootstrap_droplet_image_id = 162461040 +bootstrap_droplet_image_id = 172040723 bootstrap_node_vm_count = 2 evm_node_vm_count = 1 evm_node_droplet_size = "s-4vcpu-8gb" -evm_node_droplet_image_id = 167317579 -nat_gateway_droplet_image_id = 166664184 +evm_node_droplet_image_id = 172040852 +nat_gateway_droplet_image_id = 172051596 node_droplet_size = "s-4vcpu-8gb" -node_droplet_image_id = 162460774 +node_droplet_image_id = 172040547 node_vm_count = 39 private_node_vm_count = 1 setup_nat_gateway = true uploader_droplet_size = "s-2vcpu-4gb" -uploader_droplet_image_id = 162461150 -uploader_vm_count = 2 \ No newline at end of file +uploader_droplet_image_id = 172051523 +uploader_vm_count = 2 diff --git a/resources/terraform/testnet/digital-ocean/variables.tf b/resources/terraform/testnet/digital-ocean/variables.tf index 70f0d1df..4c7e6d41 100644 --- a/resources/terraform/testnet/digital-ocean/variables.tf +++ b/resources/terraform/testnet/digital-ocean/variables.tf @@ -41,7 +41,7 @@ variable "build_machine_size" { } variable "build_droplet_image_id" { - default = "165140612" + default = "172040819" } variable "bootstrap_droplet_image_id" { @@ -137,4 +137,4 @@ variable "node_volume_size" { variable "private_node_volume_size" { description = "Size of each volume in GB for private nodes" type = number -} \ No newline at end of file +} diff --git a/src/ansible/extra_vars.rs b/src/ansible/extra_vars.rs index 861205e9..f01c6e8f 100644 --- a/src/ansible/extra_vars.rs +++ b/src/ansible/extra_vars.rs @@ -361,19 +361,6 @@ pub fn build_node_extra_vars_doc( Ok(extra_vars.build()) } -pub fn build_safenode_rpc_client_extra_vars_doc( - cloud_provider: &str, - options: &ProvisionOptions, - genesis_multiaddr: &str, -) -> Result { - let mut extra_vars = ExtraVarsDocBuilder::default(); - extra_vars.add_variable("provider", cloud_provider); - extra_vars.add_variable("testnet_name", &options.name); - extra_vars.add_variable("genesis_multiaddr", genesis_multiaddr); - extra_vars.add_rpc_client_url_or_version(&options.name, &options.binary_option); - Ok(extra_vars.build()) -} - pub fn build_uploaders_extra_vars_doc( cloud_provider: &str, options: &ProvisionOptions, diff --git a/src/ansible/provisioning.rs b/src/ansible/provisioning.rs index f322ef03..449188a6 100644 --- a/src/ansible/provisioning.rs +++ b/src/ansible/provisioning.rs @@ -439,26 +439,6 @@ impl AnsibleProvisioner { Ok(()) } - pub fn provision_safenode_rpc_client( - &self, - options: &ProvisionOptions, - genesis_multiaddr: &str, - ) -> Result<()> { - let start = Instant::now(); - println!("Running ansible against genesis node to start safenode_rpc_client service..."); - self.ansible_runner.run_playbook( - AnsiblePlaybook::RpcClient, - AnsibleInventoryType::Genesis, - Some(extra_vars::build_safenode_rpc_client_extra_vars_doc( - &self.cloud_provider.to_string(), - options, - genesis_multiaddr, - )?), - )?; - print_duration(start.elapsed()); - Ok(()) - } - pub async fn provision_uploaders( &self, options: &ProvisionOptions,