Move borg credentials to a separate file
To be used from a service
This commit is contained in:
parent
374654f8fd
commit
a5b2eb5f97
|
@ -12,16 +12,24 @@ file "/root/.ssh/borg_rsa" do
|
|||
mode '0600'
|
||||
end
|
||||
|
||||
bash "Add borg environment variables for bash" do
|
||||
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"]}'
|
||||
EOF
|
||||
end
|
||||
|
||||
bash "Load borg credentials in console sessions" do
|
||||
code <<-EOF
|
||||
cat >>/root/.bashrc <<EOL
|
||||
|
||||
# GENERATED BY CHEF
|
||||
export BORG_RSH='ssh -i /root/.ssh/borg_rsa'
|
||||
export BORG_PASSPHRASE=#{borg_credentials["passphrase"]}
|
||||
export BORG_REPO='#{borg_credentials["repository"]}'
|
||||
set -o allexport
|
||||
source ~/.borg_credentials.env
|
||||
set +o allexport
|
||||
EOF
|
||||
not_if "grep -q BORG /root/.bashrc"
|
||||
not_if "grep -q borg_credentials /root/.bashrc"
|
||||
end
|
||||
|
||||
directory "/root/backups" do
|
||||
|
|
Loading…
Reference in New Issue