Skip to content

Commit

Permalink
debug cloud-inti: start
Browse files Browse the repository at this point in the history
  • Loading branch information
bartekpacia committed Oct 22, 2024
1 parent 68db813 commit 5ade819
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 58 deletions.
30 changes: 2 additions & 28 deletions infra-do/droplet-executor.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
32 changes: 2 additions & 30 deletions infra-do/droplet-influx.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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

0 comments on commit 5ade819

Please sign in to comment.