summaryrefslogtreecommitdiff
path: root/puppet/modules/site_ca_daemon/manifests/init.pp
blob: 8ba9c506bbae9d8722d7735f1ab1736f2b630bd4 (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
class site_ca_daemon {
  tag 'leap_service'
  #$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['ca_key'];
      #notify  => Service['leap_ca_daemon']; <== no service yet for leap_ca_daemon
  }

  x509::cert {
    'leap_ca_daemon':
      content => $x509['ca_cert'];
      #notify  => Service['leap_ca_daemon'];  <== no service yet for leap_ca_daemon
  }

  #
  # Does CA need a server key/cert? I think not now.
  #
  # x509::key {
  #   'server':
  #     content => $x509['key'];
  # }
  #
  # x509::cert {
  #   'server':
  #     content => $x509['cert'];
  # }

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


  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',
    timeout => 600,
    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_daemon',
  }

  file { '/etc/cron.hourly/leap_ca':
    ensure  => present,
    content => "#/bin/sh\n/srv/leap_ca_daemon/bin/leap_ca_daemon --run-once > /dev/null",
    owner   => 'root',
    group   => 0,
    mode    => '0755',
  }


}