summaryrefslogtreecommitdiff
path: root/puppet/modules/site_ca_daemon/manifests/init.pp
blob: 34b2c52252d14a839f8a71e40ddf2085f4da70f6 (plain)
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
class site_ca_daemon {

  #$definition_files = hiera('definition_files')
  #$provider         = $definition_files['provider']
  #$eip_service      = $definition_files['eip_service']
  $x509             = hiera('x509')

  Class[Ruby] -> Class[rubygems] -> Class[bundler::install]

  class { 'ruby': ruby_version => '1.9.3' }

  class { 'bundler::install': install_method => 'package' }

  include rubygems
  #include site_ca_daemon::apache
  include site_ca_daemon::couchdb

  group { 'leap_ca_daemon':
    ensure    => present,
    allowdupe => false;
  }

  user { 'leap_ca_daemon':
    ensure    => present,
    allowdupe => false,
    gid       => 'leap_ca_daemon',
    home      => '/srv/leap_ca_daemon',
    require   => [ Group['leap_ca_daemon'] ];
  }


  x509::key {
    'leap_ca_daemon':
      content => $x509['key'],
      #notify  => Service[apache];
  }

  x509::cert {
    'leap_ca_daemon':
      content => $x509['cert'],
      #notify  => Service[apache];
  }

  x509::ca {
    'leap_ca_daemon':
      content => $x509['ca_cert'],
      #notify  => Service[apache];
  }


  file { '/srv/leap_ca_daemon':
    ensure  => directory,
    owner   => 'leap_ca_daemon',
    group   => 'leap_ca_daemon',
    require => User['leap_ca_daemon'];
  }

  vcsrepo { '/srv/leap_ca_daemon':
    ensure   => present,
    revision => 'origin/master',
    provider => git,
    source   => 'git://code.leap.se/leap_ca',
    owner    => 'leap_ca_daemon',
    group    => 'leap_ca_daemon',
    require  => [ User['leap_ca_daemon'], Group['leap_ca_daemon'] ],
    notify   => Exec['bundler_update']
  }

  exec { 'bundler_update':
    cwd     => '/srv/leap_ca_daemon',
    command => '/bin/bash -c "/usr/bin/bundle check || /usr/bin/bundle install"',
    unless  => '/usr/bin/bundle check',
    require => [ Class['bundler::install'], Vcsrepo['/srv/leap_ca_daemon'] ];
  }

  file { '/usr/local/bin/leap_ca_daemon':
    ensure => link,
    target => '/srv/leap_ca_daemon/bin/leap_ca',
  }
}