From 5ade819ac29750bdf6826513a391fc3621ab820c Mon Sep 17 00:00:00 2001 From: Bartek Pacia Date: Tue, 22 Oct 2024 23:32:52 +0200 Subject: [PATCH] debug cloud-inti: start --- infra-do/droplet-executor.tf | 30 ++---------------------------- infra-do/droplet-influx.tf | 32 ++------------------------------ 2 files changed, 4 insertions(+), 58 deletions(-) diff --git a/infra-do/droplet-executor.tf b/infra-do/droplet-executor.tf index 0867610..67f71b1 100644 --- a/infra-do/droplet-executor.tf +++ b/infra-do/droplet-executor.tf @@ -20,34 +20,8 @@ resource "digitalocean_droplet" "executor" { # From: https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-22-04 runcmd: - - echo "hello from cloud-init! started! pwd is: $(pwd)" >> /root/hello.txt - - sudo apt-get install -y apt-transport-https ca-certificates curl software-properties-common - - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg - - echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null - - sudo apt-get update - - apt-cache policy docker-ce + - echo "hello from cloud-init on executor! started! pwd is: $(pwd)" >> /root/hello.txt - - sudo apt-get install -y docker-ce - - sudo systemctl status docker - - - docker pull ghcr.io/bee-ci-system/bee-ci/executor:latest - - # Postgres config - - echo "DB_HOST=${digitalocean_database_cluster.postgres.host}" >> /root/.executor.env - - echo "DB_PORT=${digitalocean_database_cluster.postgres.port}" >> /root/.executor.env - - echo "DB_PASSWORD=${digitalocean_database_cluster.postgres.password}" >> /root/.executor.env - - echo "DB_NAME=${digitalocean_database_cluster.postgres.name}" >> /root/.executor.env - - # Influx config - - echo "INFLUXDB_URL=http://${digitalocean_droplet.influxdb.ipv4_address_private}:8086" >> /root/.executor.env - - echo "INFLUXDB_ORG=${var.influxdb_org}" >> /root/.executor.env - - echo "INFLUXDB_BUCKET=${var.influxdb_bucket}" >> /root/.executor.env - - echo "INFLUXDB_TOKEN=${var.influxdb_token}" >> /root/.executor.env - - - docker run --env-file /root/.executor.env bee-ci-backend-executor:latest - - echo "hello from cloud-init! done!" >> /root/hello.txt + final_message: "executor ready!" EOF } - -# To check if cloud-init completed successfully, see: -# https://www.digitalocean.com/community/questions/how-to-make-sure-that-cloud-init-finished-running diff --git a/infra-do/droplet-influx.tf b/infra-do/droplet-influx.tf index fbd7352..adc3038 100644 --- a/infra-do/droplet-influx.tf +++ b/infra-do/droplet-influx.tf @@ -20,34 +20,9 @@ resource "digitalocean_droplet" "influxdb" { # From: https://docs.influxdata.com/influxdb/v2/install runcmd: - - echo "hello from cloud-init! started! pwd is: $(pwd)" >> /root/hello.txt + - echo "hello from cloud-init on influx! started! pwd is: $(pwd)" >> /root/hello.txt - # Install InfluxDB - - curl --silent --location -O https://repos.influxdata.com/influxdata-archive.key - - echo "943666881a1b8d9b849b74caebf02d3465d6beb716510d86a39f6c8e8dac7515 influxdata-archive.key" | sha256sum --check - && cat influxdata-archive.key | gpg --dearmor | tee /etc/apt/trusted.gpg.d/influxdata-archive.gpg > /dev/null && echo 'deb [signed-by=/etc/apt/trusted.gpg.d/influxdata-archive.gpg] https://repos.influxdata.com/debian stable main' | tee /etc/apt/sources.list.d/influxdata.list - - sudo apt-get update && sudo apt-get install -y influxdb2 - - # Mount the volume to /var/lib/influxdb2 - - mkfs.ext4 /dev/disk/by-id/scsi-0DO_Volume_influxdb-data - - mount /dev/disk/by-id/scsi-0DO_Volume_influxdb-data /var/lib/influxdb2 - - echo "/dev/disk/by-id/scsi-0DO_Volume_influxdb-data /var/lib/influxdb2 ext4 defaults,nofail 0 2" | sudo tee -a /etc/fstab - - # Create the config folder - - mkdir -p /etc/influxdb2 - - # Initialize InfluxDB with the provided environment variables - - INFLUXDB_INIT_USERNAME=beeci - - INFLUXDB_INIT_PASSWORD=${var.influxdb_password} - - INFLUXDB_INIT_ADMIN_TOKEN=${var.influxdb_token} - - INFLUXDB_INIT_ORG=${var.influxdb_org} - - INFLUXDB_INIT_BUCKET=${var.influxdb_bucket} - - - influx setup --username beeci --password ${var.influxdb_password} --token ${var.influxdb_token} --org ${var.influxdb_org} --bucket ${var.influxdb_bucket} --force - - # Restart InfluxDB to apply storage and initialization changes - - sudo systemctl enable influxdb - - sudo systemctl restart influxdb - - echo "hello from cloud-init! done!" >> /root/hello.txt + final_message: "influx ready!" EOF } @@ -57,6 +32,3 @@ resource "digitalocean_volume" "influxdb_volume" { region = "sfo3" initial_filesystem_type = "ext4" } - -# To check if cloud-init completed successfully, see: -# https://www.digitalocean.com/community/questions/how-to-make-sure-that-cloud-init-finished-running