summaryrefslogtreecommitdiff
path: root/puppet/modules/tapicero/manifests/init.pp
blob: 743e8a84ee337babcf13bd39c1d87ac90a452af1 (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
class tapicero {
  tag 'leap_service'

  $couchdb                 = hiera('couch')
  $couchdb_port            = $couchdb['port']

  $couchdb_users           = $couchdb['users']

  $couchdb_admin_user      = $couchdb_users['admin']['username']
  $couchdb_admin_password  = $couchdb_users['admin']['password']

  $couchdb_soledad_user    = $couchdb_users['soledad']['username']
  $couchdb_leap_mx_user    = $couchdb_users['leap_mx']['username']


  Class['site_config::default'] -> Class['tapicero']

  include site_config::ruby::dev

  #
  # USER AND GROUP
  #

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

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

  #
  # TAPICERO FILES
  #

  file {

    ##
    ## TAPICERO DIRECTORIES
    ##

    '/srv/leap/tapicero':
      ensure  => directory,
      owner   => 'tapicero',
      group   => 'tapicero',
      require => User['tapicero'];

    '/var/lib/leap/tapicero':
      ensure  => directory,
      owner   => 'tapicero',
      group   => 'tapicero',
      require => User['tapicero'];

    ##
    ## TAPICERO CONFIG
    ##

    '/etc/leap/tapicero.yaml':
      content => template('tapicero/tapicero.yaml.erb'),
      owner   => 'tapicero',
      group   => 'tapicero',
      mode    => '0600',
      notify  => Service['tapicero'];

    ##
    ## TAPICERO INIT
    ##

    '/etc/init.d/tapicero':
      source  => 'puppet:///modules/tapicero/tapicero.init',
      owner   => root,
      group   => 0,
      mode    => '0755',
      require => Vcsrepo['/srv/leap/tapicero'];
  }

  #
  # TAPICERO CODE
  #

  vcsrepo { '/srv/leap/tapicero':
    ensure   => present,
    force    => true,
    revision => 'origin/master',
    provider => git,
    source   => 'https://leap.se/git/tapicero',
    owner    => 'tapicero',
    group    => 'tapicero',
    require  => [ User['tapicero'], Group['tapicero'] ],
    notify   => Exec['tapicero_bundler_update']
  }

  exec { 'tapicero_bundler_update':
    cwd     => '/srv/leap/tapicero',
    command => '/bin/bash -c "/usr/bin/bundle check || /usr/bin/bundle install --path vendor/bundle --without test development"',
    unless  => '/usr/bin/bundle check',
    user    => 'tapicero',
    timeout => 600,
    require => [
                Class['bundler::install'],
                Vcsrepo['/srv/leap/tapicero'],
                Class['site_config::ruby::dev'] ],
    notify  => Service['tapicero'];
  }

  #
  # TAPICERO DAEMON
  #

  service { 'tapicero':
    ensure     => running,
    enable     => true,
    hasstatus  => true,
    hasrestart => true,
    require    => File['/etc/init.d/tapicero'];
  }

}