jdormit-infra/prod/syncthing/packer/syncthing.json

72 lines
2.5 KiB
JSON
Raw Normal View History

{
"builders": [
{
"type": "digitalocean",
"image": "ubuntu-18-04-x64",
"region": "nyc1",
"size": "s-1vcpu-1gb",
"snapshot_name": "packer-syncthing-{{timestamp}}",
"ssh_username": "root"
}
],
"provisioners": [
{
"type": "shell",
"inline": [
2020-12-31 19:19:27 +00:00
"sudo apt-get update",
2021-10-06 01:16:44 +00:00
"sudo apt-get install -y bindfs ca-certificates",
"sudo useradd -m syncthing",
"sudo mkdir -p /mnt/syncthing-volume",
2020-12-31 19:19:27 +00:00
"sudo mkdir -p /mnt/syncthing",
"sudo echo \"/dev/disk/by-label/syncthing-volume /mnt/syncthing-volume ext4 defaults,nofail,discard,noatime 0 2\" >> /etc/fstab",
2020-12-31 19:19:27 +00:00
"sudo echo \"/mnt/syncthing-volume /mnt/syncthing fuse.bindfs force-user=syncthing,force-group=syncthing 0 0\" >> /etc/fstab",
"sudo findmnt --verify --verbose"
]
},
{
"type": "file",
"source": "syncthing@.service",
"destination": "/tmp/syncthing@.service"
},
{
"type": "file",
"source": "syncthing-config.xml",
"destination": "/tmp/syncthing-config.xml"
},
{
"type": "file",
"source": "syncthing-cert.pem",
"destination": "/tmp/syncthing-cert.pem"
},
{
"type": "file",
"source": "syncthing-key.pem",
"destination": "/tmp/syncthing-key.pem"
},
{
"type": "shell",
"inline": [
2021-10-06 01:16:44 +00:00
"sudo update-ca-certificates",
"sudo curl -s -o /usr/share/keyrings/syncthing-archive-keyring.gpg https://syncthing.net/release-key.gpg",
"echo \"deb [signed-by=/usr/share/keyrings/syncthing-archive-keyring.gpg] https://apt.syncthing.net/ syncthing stable\" | sudo tee /etc/apt/sources.list.d/syncthing.list",
"printf \"Package: *\nPin: origin apt.syncthing.net\nPin-Priority: 990\n\" | sudo tee /etc/apt/preferences.d/syncthing",
"sudo apt-get update",
"sudo apt-get install -y syncthing",
"sudo mkdir -p /home/syncthing/.config/syncthing",
"sudo mv /tmp/syncthing-config.xml /home/syncthing/.config/syncthing/config.xml",
"sudo mv /tmp/syncthing-cert.pem /home/syncthing/.config/syncthing/cert.pem",
"sudo mv /tmp/syncthing-key.pem /home/syncthing/.config/syncthing/key.pem",
"sudo chown -R syncthing:syncthing /home/syncthing/.config/syncthing",
"sudo mv /tmp/syncthing@.service /etc/systemd/system/syncthing@.service",
"sudo systemctl daemon-reload",
"sudo systemctl enable syncthing@syncthing"
]
}
2020-12-31 16:04:47 +00:00
],
"post-processors": [
{
"type": "manifest"
}
]
}