From 6c81e1b01e0850be93419b68d4c61529de519d2a Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 25 Mar 2021 21:01:23 -0400 Subject: refactor --- modules/borgmatic/manifests/init.pp | 41 +++++++++++++++++++++++++++++++++ modules/borgmatic/templates/config.yaml | 25 ++++++++++++++++++++ 2 files changed, 66 insertions(+) create mode 100644 modules/borgmatic/manifests/init.pp create mode 100644 modules/borgmatic/templates/config.yaml (limited to 'modules/borgmatic') diff --git a/modules/borgmatic/manifests/init.pp b/modules/borgmatic/manifests/init.pp new file mode 100644 index 0000000..9ea1181 --- /dev/null +++ b/modules/borgmatic/manifests/init.pp @@ -0,0 +1,41 @@ +class borgmatic($host = 'partofme.algo') { + package { 'borgmatic': + ensure => installed; + } + + $current_hostname = "${facts['networking']['hostname']}" + $borgmatic_passphrase = secret::value('borgmatic_passphrase') + file { + "/etc/borgmatic": + ensure => directory; + "/etc/borgmatic/config.yaml": + content => template('borgmatic/config.yaml'), + require => File["/etc/borgmatic"]; + } + + secret { "/etc/borgmatic/borg_ssh_key": + source => 'borg_ssh_key', + require => File["/etc/borgmatic"]; + } + + exec { '/usr/bin/borgmatic init --encryption repokey': + environment => [ + "BORG_PASSPHRASE=${borgmatic_passphrase}", + ], + unless => '/usr/bin/borgmatic info > /dev/null', + require => [ + Package['borgmatic'], + File['/etc/borgmatic/config.yaml'], + ] + } + + service { 'borgmatic.timer': + ensure => running, + enable => true, + require => [ + Package['borgmatic'], + File['/etc/borgmatic/config.yaml'], + Exec['/usr/bin/borgmatic init --encryption repokey'], + ]; + } +} diff --git a/modules/borgmatic/templates/config.yaml b/modules/borgmatic/templates/config.yaml new file mode 100644 index 0000000..60a1e42 --- /dev/null +++ b/modules/borgmatic/templates/config.yaml @@ -0,0 +1,25 @@ +location: + source_directories: + - /home + - /etc + - /usr/local/bin + repositories: + - borg@<%= @borgmatic_host %>:<%= current_hostname %> + atime: false + exclude_patterns: + - /home/*/.cache + - /home/*/.cargo + - /home/*/.rustup + - /home/doy/coding/*/target + - /home/doy/mnt + - /home/doy/tmp + +storage: + encryption_passphrase: "<%= @borgmatic_passphrase %>" + ssh_command: /usr/bin/ssh -i /etc/borgmatic/borg_ssh_key -o StrictHostKeyChecking=no + +retention: + keep_daily: 7 + keep_weekly: 4 + keep_monthly: 12 + keep_yearly: 1000 -- cgit v1.2.3-54-g00ecf