summaryrefslogtreecommitdiff
path: root/manifests/ssl/generate_cert.pp
blob: 3d500ac5534dc73bd3a4c33829ac25035270d9f5 (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
class couchdb::ssl::generate_cert {

  package { ['openssl']:
    ensure => 'installed',
  }

  file { $couchdb::cert_path:
    ensure => 'directory',
    mode   => '0600',
    owner  => 'couchdb',
    group  => 'couchdb';
  }

exec { 'generate-certs':
    command => "/usr/bin/openssl req -new -inform PEM -x509 -nodes -days 150 -subj \
'/C=ZZ/ST=AutoSign/O=AutoSign/localityName=AutoSign/commonName=${::hostname}/organizationalUnitName=AutoSign/emailAddress=AutoSign/' \
-newkey rsa:2048 -out ${couchdb::cert_path}/couchdb_cert.pem -keyout ${couchdb::cert_path}/couchdb_key.pem",
    unless  => "/usr/bin/test -f ${couchdb::cert_path}/couchdb_cert.pem &&
/usr/bin/test -f ${couchdb::params::cert_path}/couchdb_key.pem",
    require => [
      File[$couchdb::params::cert_path],
      Exec['make-install']
    ],
    notify  => Service['couchdb'],
  }
}