Add volume mount and config.xml in packer image for syncthing

This commit is contained in:
Jeremy Dormitzer 2020-12-29 15:20:26 -05:00
parent 269873e755
commit 88a771f3c1
5 changed files with 152 additions and 5 deletions

1
prod/syncthing-packer/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
packer/syncthing-config.xml

View File

@ -0,0 +1,7 @@
.PHONY: packer
packer: syncthing-config.xml syncthing.json
packer build syncthing.json
syncthing-config.xml: syncthing-config.xml.template
sigil -p -f syncthing-config.xml.template > syncthing-config.xml

View File

@ -0,0 +1,119 @@
<configuration version="30">
<folder id="default" label="Default Folder" path="/mnt/syncthing-volume/Sync" type="sendreceive" rescanIntervalS="3600" fsWatcherEnabled="true" fsWatcherDelayS="10" ignorePerms="false" autoNormalize="true">
<filesystemType>basic</filesystemType>
<device id="UW7FOJM-POJIOL5-JRHZ3BP-BOWBHKY-VY3B5UH-MO2QNKB-4HBSNR6-DD6RIQL" introducedBy=""></device>
<device id="U7CQRH7-7CG4M2R-QOGYHBJ-ZJZ35GA-KZR2JE5-7OLJZ7R-FRKT2RG-UMYUHQM" introducedBy=""></device>
<device id="WJHJK2I-R3EOVWD-FW3KD2P-P4OMCIK-EDNCI3D-QQQGXEY-3OGUAGC-MWQX5AL" introducedBy=""></device>
<device id="3TVGWWD-CWLUBJI-6IPGB2Z-JESEM5U-JBZOOHJ-RAYO2EA-JDJVNLG-S52GTAQ" introducedBy=""></device>
<minDiskFree unit="%">1</minDiskFree>
<versioning type="staggered">
<param key="cleanInterval" val="3600"></param>
<param key="maxAge" val="31536000"></param>
<param key="versionsPath" val=""></param>
</versioning>
<copiers>0</copiers>
<pullerMaxPendingKiB>0</pullerMaxPendingKiB>
<hashers>0</hashers>
<order>random</order>
<ignoreDelete>false</ignoreDelete>
<scanProgressIntervalS>0</scanProgressIntervalS>
<pullerPauseS>0</pullerPauseS>
<maxConflicts>-1</maxConflicts>
<disableSparseFiles>false</disableSparseFiles>
<disableTempIndexes>false</disableTempIndexes>
<paused>false</paused>
<weakHashThresholdPct>25</weakHashThresholdPct>
<markerName>.stfolder</markerName>
<copyOwnershipFromParent>false</copyOwnershipFromParent>
<modTimeWindowS>0</modTimeWindowS>
<maxConcurrentWrites>2</maxConcurrentWrites>
<disableFsync>false</disableFsync>
<blockPullOrder>standard</blockPullOrder>
</folder>
<device id="UW7FOJM-POJIOL5-JRHZ3BP-BOWBHKY-VY3B5UH-MO2QNKB-4HBSNR6-DD6RIQL" name="jdormit-syncthing" compression="metadata" introducer="false" skipIntroductionRemovals="false" introducedBy="">
<address>dynamic</address>
<paused>false</paused>
<autoAcceptFolders>false</autoAcceptFolders>
<maxSendKbps>0</maxSendKbps>
<maxRecvKbps>0</maxRecvKbps>
<maxRequestKiB>0</maxRequestKiB>
</device>
<device id="U7CQRH7-7CG4M2R-QOGYHBJ-ZJZ35GA-KZR2JE5-7OLJZ7R-FRKT2RG-UMYUHQM" name="Pixel 3 XL" compression="metadata" introducer="false" skipIntroductionRemovals="false" introducedBy="">
<address>dynamic</address>
<paused>false</paused>
<autoAcceptFolders>false</autoAcceptFolders>
<maxSendKbps>0</maxSendKbps>
<maxRecvKbps>0</maxRecvKbps>
<maxRequestKiB>0</maxRequestKiB>
</device>
<device id="WJHJK2I-R3EOVWD-FW3KD2P-P4OMCIK-EDNCI3D-QQQGXEY-3OGUAGC-MWQX5AL" name="jdormit-laptop" compression="metadata" introducer="false" skipIntroductionRemovals="false" introducedBy="">
<address>dynamic</address>
<paused>false</paused>
<autoAcceptFolders>false</autoAcceptFolders>
<maxSendKbps>0</maxSendKbps>
<maxRecvKbps>0</maxRecvKbps>
<maxRequestKiB>0</maxRequestKiB>
</device>
<device id="3TVGWWD-CWLUBJI-6IPGB2Z-JESEM5U-JBZOOHJ-RAYO2EA-JDJVNLG-S52GTAQ" name="Jeremys-MBP" compression="metadata" introducer="false" skipIntroductionRemovals="false" introducedBy="">
<address>dynamic</address>
<paused>false</paused>
<autoAcceptFolders>false</autoAcceptFolders>
<maxSendKbps>0</maxSendKbps>
<maxRecvKbps>0</maxRecvKbps>
<maxRequestKiB>0</maxRequestKiB>
</device>
<gui enabled="true" tls="false" debugging="false">
<address>127.0.0.1:8384</address>
<user>${SYNCTHING_USER:?}</user>
<password>${SYNCTHING_PW:?}</password>
<apikey>${SYNCTHING_API_KEY:?}</apikey>
<theme>default</theme>
</gui>
<ldap></ldap>
<options>
<listenAddress>default</listenAddress>
<globalAnnounceServer>default</globalAnnounceServer>
<globalAnnounceEnabled>true</globalAnnounceEnabled>
<localAnnounceEnabled>true</localAnnounceEnabled>
<localAnnouncePort>21027</localAnnouncePort>
<localAnnounceMCAddr>[ff12::8384]:21027</localAnnounceMCAddr>
<maxSendKbps>0</maxSendKbps>
<maxRecvKbps>0</maxRecvKbps>
<reconnectionIntervalS>60</reconnectionIntervalS>
<relaysEnabled>true</relaysEnabled>
<relayReconnectIntervalM>10</relayReconnectIntervalM>
<startBrowser>true</startBrowser>
<natEnabled>true</natEnabled>
<natLeaseMinutes>60</natLeaseMinutes>
<natRenewalMinutes>30</natRenewalMinutes>
<natTimeoutSeconds>10</natTimeoutSeconds>
<urAccepted>-1</urAccepted>
<urSeen>3</urSeen>
<urUniqueID></urUniqueID>
<urURL>https://data.syncthing.net/newdata</urURL>
<urPostInsecurely>false</urPostInsecurely>
<urInitialDelayS>1800</urInitialDelayS>
<restartOnWakeup>true</restartOnWakeup>
<autoUpgradeIntervalH>12</autoUpgradeIntervalH>
<upgradeToPreReleases>false</upgradeToPreReleases>
<keepTemporariesH>24</keepTemporariesH>
<cacheIgnoredFiles>false</cacheIgnoredFiles>
<progressUpdateIntervalS>5</progressUpdateIntervalS>
<limitBandwidthInLan>false</limitBandwidthInLan>
<minHomeDiskFree unit="%">1</minHomeDiskFree>
<releasesURL>https://upgrades.syncthing.net/meta.json</releasesURL>
<overwriteRemoteDeviceNamesOnConnect>false</overwriteRemoteDeviceNamesOnConnect>
<tempIndexMinBlocks>10</tempIndexMinBlocks>
<trafficClass>0</trafficClass>
<defaultFolderPath>~</defaultFolderPath>
<setLowPriority>true</setLowPriority>
<maxFolderConcurrency>0</maxFolderConcurrency>
<crashReportingURL>https://crash.syncthing.net/newcrash</crashReportingURL>
<crashReportingEnabled>true</crashReportingEnabled>
<stunKeepaliveStartS>180</stunKeepaliveStartS>
<stunKeepaliveMinS>20</stunKeepaliveMinS>
<stunServer>default</stunServer>
<databaseTuning>auto</databaseTuning>
<maxConcurrentIncomingRequestKiB>0</maxConcurrentIncomingRequestKiB>
</options>
</configuration>

View File

@ -10,19 +10,36 @@
}
],
"provisioners": [
{
"type": "shell",
"inline": [
"sudo useradd -m syncthing",
"sudo mkdir -p /mnt/syncthing-volume",
"sudo chown syncthing:syncthing /mnt/syncthing-volume",
"sudo echo \"/dev/disk/by-label/syncthing-volume /mnt/syncthing-volume ext4 defaults,nofail,discard,noatime 0 2\" >> /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": "shell",
"inline": [
"sudo useradd -m syncthing",
"curl -s https://syncthing.net/release-key.txt | sudo apt-key add -",
"echo \"deb https://apt.syncthing.net/ syncthing stable\" | sudo tee /etc/apt/sources.list.d/syncthing.list",
"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 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"

View File

@ -5,7 +5,7 @@ provider "digitalocean" {
}
data "digitalocean_image" "syncthing" {
name = "syncthing-packer-1608562878"
name = "syncthing-packer-1609271401"
}
data "terraform_remote_state" "do_ssh_keys" {
@ -37,7 +37,10 @@ resource "digitalocean_droplet" "syncthing" {
}
resource "digitalocean_volume" "syncthing_volume" {
name = "syncthing-volume"
region = "nyc1"
size = 100
name = "syncthing-volume"
description = "The volume to hold the default Sync folder"
region = "nyc1"
size = 100
initial_filesystem_label = "syncthing-volume"
initial_filesystem_type = "ext4"
}