summaryrefslogtreecommitdiff
path: root/puppet/modules/site_webapp/manifests
diff options
context:
space:
mode:
Diffstat (limited to 'puppet/modules/site_webapp/manifests')
-rw-r--r--puppet/modules/site_webapp/manifests/apache.pp62
-rw-r--r--puppet/modules/site_webapp/manifests/couchdb.pp16
-rw-r--r--puppet/modules/site_webapp/manifests/init.pp73
3 files changed, 151 insertions, 0 deletions
diff --git a/puppet/modules/site_webapp/manifests/apache.pp b/puppet/modules/site_webapp/manifests/apache.pp
new file mode 100644
index 00000000..8532cc38
--- /dev/null
+++ b/puppet/modules/site_webapp/manifests/apache.pp
@@ -0,0 +1,62 @@
+class site_webapp::apache {
+
+ $api_domain = hiera('api_domain')
+ $x509 = hiera('x509')
+ $commercial_key = $x509['commercial_key']
+ $commercial_cert = $x509['commercial_cert']
+ $commercial_root = $x509['commercial_ca_cert']
+ $api_key = $x509['key']
+ $api_cert = $x509['cert']
+ $api_root = $x509['ca_cert']
+
+ $apache_no_default_site = true
+ include apache::ssl
+
+ apache::module {
+ 'alias': ensure => present;
+ 'rewrite': ensure => present;
+ 'headers': ensure => present;
+ }
+
+ class { 'passenger': use_munin => false }
+
+ apache::vhost::file {
+ 'leap_webapp':
+ content => template('site_apache/vhosts.d/leap_webapp.conf.erb')
+ }
+
+ apache::vhost::file {
+ 'api':
+ content => template('site_apache/vhosts.d/api.conf.erb')
+ }
+
+ x509::key {
+ 'leap_webapp':
+ content => $commercial_key,
+ notify => Service[apache];
+
+ 'leap_api':
+ content => $api_key,
+ notify => Service[apache];
+ }
+
+ x509::cert {
+ 'leap_webapp':
+ content => $commercial_cert,
+ notify => Service[apache];
+
+ 'leap_api':
+ content => $api_cert,
+ notify => Service[apache];
+ }
+
+ x509::ca {
+ 'leap_webapp':
+ content => $commercial_root,
+ notify => Service[apache];
+
+ 'leap_api':
+ content => $api_root,
+ notify => Service[apache];
+ }
+}
diff --git a/puppet/modules/site_webapp/manifests/couchdb.pp b/puppet/modules/site_webapp/manifests/couchdb.pp
new file mode 100644
index 00000000..6cac666f
--- /dev/null
+++ b/puppet/modules/site_webapp/manifests/couchdb.pp
@@ -0,0 +1,16 @@
+class site_webapp::couchdb {
+
+ $webapp = hiera('webapp')
+ $couchdb_host = $webapp['couchdb_hosts']
+ $couchdb_user = $webapp['couchdb_user']['username']
+ $couchdb_password = $webapp['couchdb_user']['password']
+
+ file {
+ '/srv/leap-webapp/config/couchdb.yml':
+ content => template('site_webapp/couchdb.yml.erb'),
+ owner => leap-webapp,
+ group => leap-webapp,
+ mode => '0600';
+ }
+
+}
diff --git a/puppet/modules/site_webapp/manifests/init.pp b/puppet/modules/site_webapp/manifests/init.pp
new file mode 100644
index 00000000..c5f33b5a
--- /dev/null
+++ b/puppet/modules/site_webapp/manifests/init.pp
@@ -0,0 +1,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 => '' }
+
+ 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 => present,
+ 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':
+ content => $cert_root,
+ owner => leap-webapp, group => leap-webapp, mode => '0644';
+
+ '/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';
+ }
+
+}