diff options
author | varac <varacanero@zeromail.org> | 2013-03-10 18:33:55 +0100 |
---|---|---|
committer | varac <varacanero@zeromail.org> | 2013-03-10 18:33:55 +0100 |
commit | 659e3604a310029000c9db8774c7caba70a3e291 (patch) | |
tree | 9e21cf4d4e69e4b7b104ec8afbd908161429b930 | |
parent | 7793c80224dbe0f1baf33075bf7396b11aeb229d (diff) |
mostly finished bigcouch support
-rw-r--r-- | bigcouch.pp | 12 | ||||
-rw-r--r-- | manifests/base.pp | 64 | ||||
-rw-r--r-- | manifests/bigcouch.pp | 52 | ||||
-rw-r--r-- | manifests/bigcouch/debian.pp | 9 | ||||
-rw-r--r-- | manifests/init.pp | 6 |
5 files changed, 124 insertions, 19 deletions
diff --git a/bigcouch.pp b/bigcouch.pp deleted file mode 100644 index ecf7c90..0000000 --- a/bigcouch.pp +++ /dev/null @@ -1,12 +0,0 @@ -class couchdb::bigcouch { - package { 'bigcouch': - ensure => installed, - } - file { '/opt/bigcouch/etc/vm.args': - source => template('couchdb/bigcouch/vm.args'), - mode => '0644', - owner => 'bigcouch', - group => 'bigcouch', - require => Package['bigcouch'] - } -} diff --git a/manifests/base.pp b/manifests/base.pp index d4d50d1..45d991b 100644 --- a/manifests/base.pp +++ b/manifests/base.pp @@ -1,5 +1,13 @@ class couchdb::base { + if $::couchdb::bigcouch == true { + $couchdb_user = 'bigcouch' + include couchdb::bigcouch + } else { + $couchdb_user = 'couchdb' + } + + package {'couchdb': ensure => present, } @@ -18,12 +26,56 @@ class couchdb::base { } File['/usr/local/bin/couch-doc-update'] -> Couchdb::Update <| |> - file { '/usr/local/bin/couch-doc-update': - source => 'puppet:///modules/couchdb/couch-doc-update', - mode => '0755', - owner => 'root', - group => 'root', - require => Package['couchrest'], + + file { + '/usr/local/bin/couch-doc-update': + source => 'puppet:///modules/couchdb/couch-doc-update', + mode => '0755', + owner => 'root', + group => 'root', + require => Package['couchrest']; + + '/etc/couchdb/local.ini': + source => [ "puppet:///modules/site_couchdb/${::fqdn}/local.ini", + 'puppet:///modules/site_couchdb/local.ini', + 'puppet:///modules/couchdb/local.ini' ], + notify => Service[couchdb], + owner => $couchdb_user, + group => $couchdb_user, + mode => '0660', + require => Package['couchdb']; + + '/etc/couchdb/local.d': + ensure => directory, + require => Package['couchdb']; } + # salt and encrypt admin pw + $sha1_and_salt = str2sha1_and_salt($::couchdb::admin_pw) + $sha1 = $sha1_and_salt[0] + $salt = $sha1_and_salt[1] + + file {'/etc/couchdb/local.d/admin.ini': + content => "[admins] +admin = -hashed-${sha1},${salt} +", + mode => '0600', + owner => $couchdb_user, + group => $couchdb_user, + notify => Service[couchdb], + require => File ['/etc/couchdb/local.d']; + } + + exec { 'couchdb_restart': + command => $::couchdb::bigcouch ? { + true => '/etc/init.d/bigcouch restart; sleep 6', + default => '/etc/init.d/couchdb restart; sleep 6', + }, + path => ['/bin', '/usr/bin',], + subscribe => File['/etc/couchdb/local.d/admin.ini', + '/etc/couchdb/local.ini'], + refreshonly => true + } + + } diff --git a/manifests/bigcouch.pp b/manifests/bigcouch.pp new file mode 100644 index 0000000..67d8691 --- /dev/null +++ b/manifests/bigcouch.pp @@ -0,0 +1,52 @@ +class couchdb::bigcouch inherits couchdb::base { + + case $::operatingsystem { + Debian: { + case $::lsbdistcodename { + /squeeze|wheezy/: { #include couchdb::bigcouch::debian + } + default: { fail "bigcouch not available for ${::operatingsystem}/${::lsbdistcodename}" } + } + } + default: { fail "bigcouch not available for ${::operatingsystem}/${::lsbdistcodename}" } + } + + apt::sources_list {'bigcouch-cloudant.list': + content => "deb http://packages.cloudant.com/debian $::lsbdistcodename main" + } + + # currently, there's no other way with puppet to install unauthenticated + # pacakges: http://projects.puppetlabs.com/issues/556 + # so we need to globally allow apt to install unauthenticated + # packages. + + apt::apt_conf { 'allow_unauthenticated': + content => 'APT::Get::AllowUnauthenticated yes;', + } + + file {'/etc/couchdb': + ensure => link, + target => '/opt/bigcouch/etc' + } + + Package ['couchdb'] { + name => 'bigcouch', + require => [ Apt::Sources_list ['bigcouch-cloudant.list'], + Apt::Apt_conf ['allow_unauthenticated'], File['/etc/couchdb'], + Exec[refresh_apt] ] + } + + file { '/opt/bigcouch/etc/vm.args': + content => template('couchdb/bigcouch/vm.args'), + mode => '0640', + owner => 'bigcouch', + group => 'bigcouch', + require => Package['couchdb'] + } + + Service ['couchdb'] { + provider => 'runit', + name => 'bigcouch' + } + +} diff --git a/manifests/bigcouch/debian.pp b/manifests/bigcouch/debian.pp new file mode 100644 index 0000000..54ca882 --- /dev/null +++ b/manifests/bigcouch/debian.pp @@ -0,0 +1,9 @@ +class couchdb::bigcouch::debian inherits couchdb::debian { + File ['/etc/init.d/couchdb'] { + ensure => absent + } + file {'/etc/init.d/bigcouch': + ensure => link, + target => '/usr/bin/sv' + } +} diff --git a/manifests/init.pp b/manifests/init.pp index 1a1646d..25a0cde 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,4 +1,7 @@ -class couchdb { +class couchdb ( + $admin_pw, + $bigcouch = false, + $bigcouch_cookie = '' ) { case $::operatingsystem { Debian: { case $::lsbdistcodename { @@ -8,4 +11,5 @@ class couchdb { } RedHat: { include couchdb::redhat } } + } |