summaryrefslogtreecommitdiff
path: root/puppet/modules/site_webapp/manifests/init.pp
blob: 6a60ab15a1e979bd6547ae6ebab9b2ac353a545b (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
class site_webapp {

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

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

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

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

  include rubygems
  include site_webapp::apache
  include site_webapp::couchdb

  group { 'leap-webapp':
    ensure    => present,
    allowdupe => false;
  }

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

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

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

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

  file {
    '/srv/leap-webapp/public/provider.json':
      content => $provider,
      owner   => leap-webapp, group => leap-webapp, mode => '0644';

    '/srv/leap-webapp/public/ca.crt':
      ensure  => link,
      target  => '/usr/local/share/ca-certificates/leap_api.crt';

    '/srv/leap-webapp/public/config':
      ensure => directory,
      owner  => leap-webapp, group => leap-webapp, mode => '0755';

    '/srv/leap-webapp/public/config/eip-service.json':
      content => $eip_service,
      owner   => leap-webapp, group => leap-webapp, mode => '0644';
  }

}