lotus/tools/packer/lotus.pkr.hcl
Cory Schwartz 01202c5276
digitalocean pass test ()
* force packer build

* disable ami temporarially

* apt and ufw

* initial lotus config

* rename correctly

* apt-get instead of apt

* undo temporary edits

* install before upgrade

* tmp - force digitalocean

* reenable filters

* uncomment ebs

* tmp, remove filter for digitalocean build

* doc

* install ufw (for iams where it isn't installed)

* more amazon regions

* missing comma

* missing comma

* remove unavailable regions

* switch to ubuntu, not minimal

* pro server

* change owner

* change image

* uncomment circleci filters

* remove api from firewall

* tmp: remove circleci filter

* dpkg options

* confold

* try export

* re-add filter
2021-03-25 13:25:11 +01:00

121 lines
2.6 KiB
HCL

variable "ci_workspace_bins" {
type = string
default = "./linux"
}
variable "lotus_network" {
type = string
default = "mainnet"
}
variable "git_tag" {
type = string
default = ""
}
locals {
timestamp = regex_replace(timestamp(), "[- TZ:]", "")
}
source "amazon-ebs" "lotus" {
ami_name = "lotus-${var.lotus_network}-${var.git_tag}-${local.timestamp}"
ami_regions = [
"ap-east-1",
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ap-south-1",
"ap-southeast-1",
"ap-southeast-2",
"ca-central-1",
"eu-central-1",
"eu-north-1",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"sa-east-1",
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
]
ami_groups = [
# This causes the ami to be publicly-accessable.
"all",
]
ami_description = "Lotus Filecoin AMI"
launch_block_device_mappings {
device_name = "/dev/sda1"
volume_size = 100
delete_on_termination = true
}
instance_type = "t2.micro"
source_ami_filter {
filters = {
name = "ubuntu/images/*ubuntu-focal-20.04-amd64-server-*"
root-device-type = "ebs"
virtualization-type = "hvm"
}
most_recent = true
owners = ["099720109477"]
}
ssh_username = "ubuntu"
}
source "digitalocean" "lotus" {
droplet_name = "lotus-${var.lotus_network}"
size = "s-1vcpu-1gb"
region = "nyc3"
image = "ubuntu-20-04-x64"
snapshot_name = "lotus-${var.lotus_network}-${var.git_tag}-${local.timestamp}"
ssh_username = "root"
}
build {
sources = [
"source.amazon-ebs.lotus",
"source.digitalocean.lotus",
]
# Lotus software (from CI workspace)
provisioner "file" {
source = "${var.ci_workspace_bins}/lotus"
destination = "lotus"
}
provisioner "file" {
source = "${var.ci_workspace_bins}/lotus-miner"
destination = "lotus-miner"
}
# First run script
provisioner "file" {
source = "./tools/packer/scripts/${var.lotus_network}/lotus-init.sh"
destination = "lotus-init.sh"
}
# Systemd service units.
provisioner "file" {
source = "./tools/packer/systemd/lotus-daemon.service"
destination = "lotus-daemon.service"
}
provisioner "file" {
source = "./tools/packer/systemd/lotus-miner.service"
destination = "lotus-miner.service"
}
provisioner "file" {
source = "./tools/packer/repo/config.toml"
destination = "config.toml"
}
provisioner "file" {
source = "./tools/packer/etc/motd"
destination = "motd"
}
provisioner "file" {
source = "./tools/packer/homedir/bashrc"
destination = ".bashrc"
}
# build it.
provisioner "shell" {
script = "./tools/packer/setup.sh"
}
}