summaryrefslogtreecommitdiff
path: root/puppet/modules/site_couchdb/manifests/setup.pp
blob: 7477d24ccf89773d8efdeddd1f90345ff997657d (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
#
# An initial setup class. All the other classes depend on this
#
class site_couchdb::setup {

  $user = $site_couchdb::couchdb_admin_user

  # setup /etc/couchdb/couchdb-admin.netrc for couchdb admin access
  couchdb::query::setup { 'localhost':
    user => $user,
    pw   => $site_couchdb::couchdb_admin_pw
  }

  # We symlink /etc/couchdb/couchdb-admin.netrc to /etc/couchdb/couchdb.netrc
  # for puppet commands, and to to /root/.netrc for couchdb_scripts
  # (eg. backup) and to makes life easier for the admin on the command line
  # (i.e. using curl/wget without passing credentials)
  file {
    '/etc/couchdb/couchdb.netrc':
      ensure  => link,
      target  => "/etc/couchdb/couchdb-${user}.netrc";
    '/root/.netrc':
      ensure  => link,
      target  => '/etc/couchdb/couchdb.netrc';
  }

  # setup /etc/couchdb/couchdb-soledad-admin.netrc file for couchdb admin
  # access, accessible only for the soledad-admin user to create soledad
  # userdbs
  if member(hiera('services', []), 'soledad') {
    file { '/etc/couchdb/couchdb-soledad-admin.netrc':
      content => "machine localhost login ${user} password ${site_couchdb::couchdb_admin_pw}",
      mode    => '0400',
      owner   => 'soledad-admin',
      group   => 'root',
      require => [ Package['couchdb'], User['soledad-admin'] ];
    }
  }

  # Checkout couchdb_scripts repo
  file {
    '/srv/leap/couchdb':
      ensure => directory
  }

  vcsrepo { '/srv/leap/couchdb/scripts':
    ensure   => present,
    provider => git,
    source   => 'https://leap.se/git/couchdb_scripts',
    revision => 'origin/master',
    require  => File['/srv/leap/couchdb']
  }

}