Puppet Class: alkivi_backup::hubic

Defined in:
manifests/hubic.pp

Overview

Parameters:

  • hostname (Any)
  • include_dir (Any)
  • exclude_dir (Any)
  • hubic_client_id (Any)
  • hubic_client_secret (Any)
  • hubic_refresh_token (Any)
  • encryption (Any) (defaults to: 'yes')
  • root (Any) (defaults to: '/')
  • static_options (Any) (defaults to: '')
  • clean_up_type (Any) (defaults to: 'remove-all-but-n-full')
  • clean_up_variable (Any) (defaults to: '2')
  • logdir (Any) (defaults to: '/home/alkivi/logs/hubic/')
  • log_file (Any) (defaults to: 'backup-`date +%Y-%m-%d`.txt')
  • log_owner (Any) (defaults to: 'alkivi:alkivi')
  • verbosity (Any) (defaults to: '-v3')
  • email (Any) (defaults to: 'monitoring@alkivi.fr')
  • email_from (Any) (defaults to: '')
  • email_subject (Any) (defaults to: 'Backup')
  • mail_command (Any) (defaults to: 'sendmail')
  • container (Any) (defaults to: 'default')


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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'manifests/hubic.pp', line 1

class alkivi_backup::hubic (
  $hostname,

  $include_dir,
  $exclude_dir,

  $hubic_client_id,
  $hubic_client_secret,
  $hubic_refresh_token,

  $encryption        = 'yes',
  $root              = '/',

  $static_options    = '',
  $clean_up_type     = 'remove-all-but-n-full',
  $clean_up_variable = '2',

  $logdir            = '/home/alkivi/logs/hubic/',
  $log_file          = 'backup-`date +%Y-%m-%d`.txt',
  $log_owner         = 'alkivi:alkivi',
  $verbosity         = '-v3',

  $email             = 'monitoring@alkivi.fr',
  $email_from        = '',
  $email_subject     = 'Backup',

  $mail_command      = 'sendmail',
  $container         = 'default',


) {

  validate_string($encryption)
  validate_string($hubic_client_id)
  validate_string($hubic_client_secret)
  validate_string($hubic_refresh_token)
  validate_string($root)
  validate_array($include_dir)
  validate_array($exclude_dir)
  validate_string($static_options)


  $dest = "hubic://${container}"

  if($encryption == 'yes')
  {
  
    $passphrase = generate('/usr/bin/sudo', '/root/alkivi-scripts/genpwd', '--save', "hubic-${hostname}", '--savedir', '/root/.passwd/alkivi-backup', '--print', '--length', '45')
  }
  elsif($encryption == 'no')
  {
  }
  else
  {
    fail("Wrong parameter encryption ${encryption}")
  }

  if(!defined(Class['alkivi_backup::install']))
  {
    class { 'alkivi_backup::install': }
  }

  # declare relationships
  Class['alkivi_base'] ->
  Class['alkivi_backup::install'] ->
  Class['alkivi_backup::hubic']

  File {
    ensure => present,
    owner  => 'root',
    group  => 'root',
    mode   => '0644',
  }

  # Add file to the right places
  file { '/usr/share/pyshared/duplicity/backends/hubicbackend.py':
    source => 'puppet:///modules/alkivi_backup/hubic/hubicbackend.py',
  }

  file { '/usr/lib/python2.7/dist-packages/duplicity/backends/hubicbackend.py':
    ensure => link,
    target => '/usr/share/pyshared/duplicity/backends/hubicbackend.py',
  }

  if(!defined(File['/root/alkivi-scripts/alkivi-backup']))
  {
    file { '/root/alkivi-scripts/alkivi-backup':
      source  => 'puppet:///modules/alkivi_backup/alkivi-backup',
      require => File['/root/alkivi-scripts/'],
    }
  }

  file { '/etc/alkivi.conf.d/hubic-backup.conf':
    content => template('alkivi_backup/backup.conf.erb'),
    require =>  File['/etc/alkivi.conf.d/'],
    mode    => '0640',
  }

  cron { 'hubic-backup':
    command => '/root/alkivi-scripts/alkivi-backup --backup -c /etc/alkivi.conf.d/hubic-backup.conf',
    user    => root,
    hour    => 20,
    minute  => 42,
    weekday => ['5'],
  }


  package { 'python-swift':
    ensure => installed
  }


}