Support node-specific borg repo config

This commit is contained in:
Râu Cao
2023-12-05 18:09:44 +01:00
parent b1763cd032
commit 769ac4a081
2 changed files with 26 additions and 11 deletions

View File

@@ -7,6 +7,14 @@ apt_package "borgbackup"
borg_credentials = data_bag_item("credentials", "borg")
if borg_credentials["nodes"].keys.include?(node.name)
passphrase = borg_credentials["nodes"][node.name]["passphrase"]
repository = borg_credentials["nodes"][node.name]["repository"]
else
passphrase = borg_credentials["passphrase"]
repository = borg_credentials["repository"]
end
file "/root/.ssh/borg_rsa" do
content borg_credentials["ssh_key"]
mode '0600'
@@ -15,8 +23,8 @@ end
file "/root/.borg_credentials.env" do
content <<-EOF
BORG_RSH='ssh -i /root/.ssh/borg_rsa'
BORG_PASSPHRASE=#{borg_credentials["passphrase"]}
BORG_REPO='#{borg_credentials["repository"]}'
BORG_PASSPHRASE=#{passphrase}
BORG_REPO='#{repository}'
EOF
end