daml/infra/vsts_agent_linux.tf
Jonas Chevalier 16aba583ce
CI linux agent changes (#509)
* ci: always use the linux-pool

reduce the difference of environment between external and internal
contributions

* infra: tweak the linux cache warmup script

Don't share the same bazel cache directory with the disk cache, which is
something else. Be more specific about the target. Clean after yourself.

* infra: bump the linux agent disk to 200GB

avoid running out of disk space
2019-04-16 11:35:46 +02:00

78 lines
1.9 KiB
HCL

# Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
resource "secret_resource" "vsts-token" {}
data "template_file" "vsts-agent-linux-startup" {
template = "${file("${path.module}/vsts_agent_linux_startup.sh")}"
vars = {
vsts_token = "${secret_resource.vsts-token.value}"
vsts_account = "digitalasset"
vsts_pool = "linux-pool"
}
}
resource "google_compute_region_instance_group_manager" "vsts-agent-linux" {
provider = "google-beta"
name = "vsts-agent-linux"
base_instance_name = "vsts-agent-linux"
region = "${local.region}"
target_size = 10
version {
name = "vsts-agent-linux"
instance_template = "${google_compute_instance_template.vsts-agent-linux.self_link}"
}
update_policy {
type = "PROACTIVE"
minimal_action = "REPLACE"
max_surge_fixed = 3
min_ready_sec = 60
}
}
resource "google_compute_instance_template" "vsts-agent-linux" {
name_prefix = "vsts-agent-linux-"
machine_type = "n1-standard-8"
labels = "${local.labels}"
disk {
disk_size_gb = 200
disk_type = "pd-ssd"
source_image = "ubuntu-os-cloud/ubuntu-1604-lts"
}
lifecycle {
create_before_destroy = true
}
metadata {
startup-script = "${data.template_file.vsts-agent-linux-startup.rendered}"
shutdown-script = <<EOS
#!/usr/bin/env bash
set -euo pipefail
cd /home/vsts/agent
su vsts <<SHUTDOWN_AGENT
export VSTS_AGENT_INPUT_TOKEN='${secret_resource.vsts-token.value}'
./config.sh remove --unattended --auth PAT
SHUTDOWN_AGENT
EOS
}
network_interface {
network = "default"
// Ephemeral IP to get access to the Internet
access_config {}
}
scheduling {
automatic_restart = false
on_host_maintenance = "TERMINATE"
preemptible = true
}
}