2021-02-17 08:49:07 +00:00
|
|
|
variable "ci_workspace_bins" {
|
|
|
|
type = string
|
|
|
|
default = "./linux"
|
|
|
|
}
|
|
|
|
|
|
|
|
variable "lotus_network" {
|
|
|
|
type = string
|
|
|
|
default = "mainnet"
|
|
|
|
}
|
2021-02-16 07:12:37 +00:00
|
|
|
|
2021-02-17 08:49:07 +00:00
|
|
|
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}"
|
2021-02-16 07:12:37 +00:00
|
|
|
ami_regions = [
|
|
|
|
"us-east-1",
|
|
|
|
"us-west-2",
|
|
|
|
]
|
2021-02-17 15:30:11 +00:00
|
|
|
ami_groups = [
|
|
|
|
# This causes the ami to be publicly-accessable.
|
|
|
|
"all",
|
|
|
|
]
|
2021-02-16 07:12:37 +00:00
|
|
|
ami_description = "Lotus Filecoin AMI"
|
2021-02-19 21:45:59 +00:00
|
|
|
launch_block_device_mappings {
|
|
|
|
device_name = "/dev/sda1"
|
|
|
|
volume_size = 100
|
|
|
|
delete_on_termination = true
|
|
|
|
}
|
2021-02-16 07:12:37 +00:00
|
|
|
|
|
|
|
instance_type = "t2.micro"
|
|
|
|
source_ami_filter {
|
|
|
|
filters = {
|
|
|
|
name = "ubuntu-minimal/images/*ubuntu-focal-20.04-amd64-minimal*"
|
|
|
|
root-device-type = "ebs"
|
|
|
|
virtualization-type = "hvm"
|
|
|
|
}
|
|
|
|
most_recent = true
|
|
|
|
owners = ["099720109477"]
|
|
|
|
}
|
|
|
|
ssh_username = "ubuntu"
|
|
|
|
}
|
|
|
|
|
2021-02-17 08:49:07 +00:00
|
|
|
source "digitalocean" "lotus" {
|
|
|
|
droplet_name = "lotus-${var.lotus_network}"
|
2021-02-16 07:12:37 +00:00
|
|
|
size = "s-1vcpu-1gb"
|
|
|
|
region = "nyc3"
|
|
|
|
image = "ubuntu-20-04-x64"
|
2021-03-01 18:11:52 +00:00
|
|
|
snapshot_name = "lotus-${var.lotus_network}-${var.git_tag}-${local.timestamp}"
|
2021-02-16 07:12:37 +00:00
|
|
|
ssh_username = "root"
|
|
|
|
}
|
|
|
|
|
|
|
|
build {
|
|
|
|
sources = [
|
2021-02-17 08:49:07 +00:00
|
|
|
"source.amazon-ebs.lotus",
|
|
|
|
"source.digitalocean.lotus",
|
2021-02-16 07:12:37 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
# Lotus software (from CI workspace)
|
|
|
|
provisioner "file" {
|
2021-02-17 08:49:07 +00:00
|
|
|
source = "${var.ci_workspace_bins}/lotus"
|
2021-02-16 07:12:37 +00:00
|
|
|
destination = "lotus"
|
|
|
|
}
|
|
|
|
provisioner "file" {
|
2021-02-17 08:49:07 +00:00
|
|
|
source = "${var.ci_workspace_bins}/lotus-miner"
|
2021-02-16 07:12:37 +00:00
|
|
|
destination = "lotus-miner"
|
|
|
|
}
|
|
|
|
# First run script
|
|
|
|
provisioner "file" {
|
2021-02-17 08:49:07 +00:00
|
|
|
source = "./tools/packer/scripts/${var.lotus_network}/lotus-init.sh"
|
2021-02-16 07:12:37 +00:00
|
|
|
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" {
|
2021-02-19 21:45:59 +00:00
|
|
|
source = "./tools/packer/etc/motd"
|
|
|
|
destination = "motd"
|
2021-02-16 07:12:37 +00:00
|
|
|
}
|
|
|
|
provisioner "file" {
|
2021-02-17 08:49:07 +00:00
|
|
|
source = "./tools/packer/homedir/bashrc"
|
2021-02-16 07:12:37 +00:00
|
|
|
destination = ".bashrc"
|
|
|
|
}
|
|
|
|
# build it.
|
|
|
|
provisioner "shell" {
|
|
|
|
script = "./tools/packer/setup.sh"
|
|
|
|
}
|
|
|
|
}
|