summaryrefslogtreecommitdiffstats
path: root/modules/duplicati/manifests/client.pp
blob: ff4c5e40c4c4a700b82fe4a0ac8973022e0cc474 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
class duplicati::client {
  package { ['python-yaml', 'python-dateutil', 'python-requests']:
    ensure => installed;
  }

  file {
    '/usr/local/bin/duplicati-client':
      ensure => link,
      target => '/opt/duplicati-client/duplicati_client.py',
      require => Exec['checkout duplicati-client'];
    '/etc/duplicati':
      ensure => directory,
      recurse => true,
      purge => true;
  }

  # patch branch for now until this lands
  $duplicati_client_sha = '0b5e29d43d0b25cd25c2f3877ea377a2d858c296'
  exec { 'clone duplicati-client':
    # command => '/usr/bin/git clone git://github.com/Pectojin/duplicati-client',
    command => '/usr/bin/git clone git://github.com/doy/duplicati-client',
    cwd => '/opt',
    creates => '/opt/duplicati-client/.git';
  }

  exec { 'checkout duplicati-client':
    provider => shell,
    command => "/usr/bin/git fetch && /usr/bin/git checkout $duplicati_client_sha",
    unless => "test \"\$(git rev-parse @)\" = \"$duplicati_client_sha\"",
    cwd => '/opt/duplicati-client',
    require => Exec['clone duplicati-client'];
  }

  exec { 'duplicati-client login':
    command => '/usr/local/bin/duplicati-client login',
    creates => '/root/.config/duplicati-client/config.yml',
    tries => 3,
    try_sleep => 10,
    require => [
      File['/usr/local/bin/duplicati-client'],
      Exec['checkout duplicati-client'],
      Service['duplicati'],
    ]
  }
}