Intial commit for web submodule 70/170/2
authorJosh Farwell <jfarwell@linuxfoundation.org>
Thu, 18 Jun 2015 03:45:47 +0000 (20:45 -0700)
committerJosh Farwell <jfarwell@linuxfoundation.org>
Thu, 18 Jun 2015 07:38:59 +0000 (07:38 +0000)
The web submodule will install, configure, initialize, and manage an
installation of Postorius and Hyperkitty in the same Django project.
Declared default values and built default options hash in params.pp,
pulled those variables into web.pp and validated their types.

Created skelton file for web::install.pp.

Change-Id: I5842df699cd8aa9c3cde5f5f8e1ceb365393115e
Signed-off-by: Josh Farwell <jfarwell@linuxfoundation.org>
manifests/params.pp
manifests/web.pp [new file with mode: 0644]
manifests/web/install.pp [new file with mode: 0644]
spec/classes/core__install_spec.rb
spec/classes/web_spec.rb [new file with mode: 0644]

index 61268eb..51c4838 100644 (file)
 #
 class mailman3::params {
 
-  # TODO: Strategy for organizing this manifest
-  # TODO: Secure_default_options hash
   # Mangement Booleans
+  # Core
   $core_manage_database = true
   $core_manage_firewall = true
   $core_refresh_service = true
   $core_service_enabled = true
   $install_core         = true
 
+  # Web
+  $install_web                = true
+  $web_manage_database        = true
+  $web_manage_django_packages = true
+  $web_manage_firewall        = true
+  $web_manage_searchengine    = true
+  $web_manage_proxy_config    = false
+  $web_manage_webserver       = true
+  $web_refresh_service        = true
+  $web_service_enabled        = true
+
   # Shared values
-  $rest_admin_user = 'restadmin'
-  $rest_admin_pass = 'restpass'
+  $hyperkitty_apikey  = 'SecretArchiverAPIKey'
+  $hyperkitty_baseurl = 'http://localhost:8000/archives'
+  $rest_admin_user    = 'restadmin'
+  $rest_admin_pass    = 'restpass'
 
   # Mailman Core values
   $core_db_tag  = 'mailman3-core'
@@ -64,8 +76,24 @@ class mailman3::params {
   $core_pid_file   = '/run/mailman3/master.pid'
   $core_site_owner = 'root@localhost'
 
-  $core_hyperkitty_baseurl = 'http://localhost:8000/archives'
-  $core_hyperkitty_apikey  = 'SecretArchiverAPIKey'
+  # Web Default Values
+  $web_allowed_hosts              = ['0.0.0.0']
+  $web_db_tag                     = 'mailman3-web'
+  $web_django_superadmin_username = 'mailmanadmin'
+  $web_django_superadmin_pass     = 'changeme'
+  $web_django_version             = '1.7'
+  $web_hyperkitty_version         = 'present'
+  $web_postorius_version          = 'present'
+  $web_searchengine_tag           = 'mailman3-web'
+  $web_user                       = 'mailman3-web'
+
+  $web_homedir             = '/opt/mailman3-web'
+  $web_vardir              = '/opt/mailman3-web/var'
+  $web_staticdir           = '/opt/mailman3-web/var/static'
+  $web_security_key        = 'GENERATE'
+  $web_browserid_audiences = [ 'http://localhost:8000', 'http://127.0.0.1:8000' ]
+  $web_database_engine     = 'django.db.backends.sqlite3'
+  $web_database_name       = "os.path.join(VAR_DIR, 'mailman-web', 'mailman-web.sqlite')"
 
   # Mailman Core default options hashes
   $core_default_allowed_hosts = {
@@ -75,8 +103,8 @@ class mailman3::params {
 
   $core_default_hyperkittycfg = {
     'general'    => {
-      'base_url' => $mailman3::params::core_hyperkitty_baseurl,
-      'api_key'  => $mailman3::params::core_hyperkitty_apikey,
+      'base_url' => $mailman3::params::hyperkitty_baseurl,
+      'api_key'  => $mailman3::params::hyperkitty_apikey,
     }
   }
 
@@ -96,11 +124,25 @@ class mailman3::params {
       'pid_file'  => $mailman3::params::core_pid_file,
     },
 
-    'webservice'    => {
-      'admin_user'  => $mailman3::params::rest_admin_user,
-      'admin_pass'  => $mailman3::params::rest_admin_pass,
+    'webservice'   => {
+      'admin_user' => $mailman3::params::rest_admin_user,
+      'admin_pass' => $mailman3::params::rest_admin_pass,
     }
   }
 
+  # Web options hashes
+  $web_default_options = {
+    'VAR_DIR'             => $mailman3::params::web_vardir,
+    'SECURITY_KEY'        => $mailman3::params::web_security_key,
+    'BROWSERID_AUDIENCES' => $mailman3::params::web_browserid_audiences,
+    'STATIC_ROOT'         => $mailman3::params::web_staticdir,
+    'DATABASES'           => {
+      'default'           => {
+        'ENGINE'          => $mailman3::params::web_database_engine,
+        'NAME'            => $mailman3::params::web_database_name,
+      },
+    },
+  }
+
 }
 # vim: ts=2 sw=2 sts=2 et :
diff --git a/manifests/web.pp b/manifests/web.pp
new file mode 100644 (file)
index 0000000..2b72e07
--- /dev/null
@@ -0,0 +1,105 @@
+# == Class: mailman3
+#
+# Full description of class mailman3 here.
+#
+# === Parameters
+#
+# Document parameters here.
+#
+# [*sample_parameter*]
+#   Explanation of what this parameter affects and what it defaults to.
+#   e.g. "Specify one or more upstream ntp servers as an array."
+#
+# === Variables
+#
+# Here you should define a list of variables that this module would require.
+#
+# [*sample_variable*]
+#   Explanation of how this variable affects the function of this class and if
+#   it has a default. e.g. "The parameter enc_ntp_servers must be set by the
+#   External Node Classifier as a comma separated list of hostnames." (Note,
+#   global variables should be avoided in favor of class parameters as
+#   of Puppet 2.6.)
+#
+# === Examples
+#
+#  class { 'mailman3':
+#    servers => [ 'pool.ntp.org', 'ntp.local.company.com' ],
+#  }
+#
+# === Authors
+#
+# Josh Farwell <jfarwell@linuxfoundation.org>
+#
+# === Copyright
+#
+# Copyright 2015 Josh Farwell, unless otherwise noted.
+#
+class mailman3::web (
+  $allowed_hosts          = $mailman3::params::web_allowed_hosts,
+  $db_tag                 = $mailman3::params::web_db_tag,
+  $django_superuser_name  = $mailman3::params::web_django_superuser_name,
+  $django_superadmin_pass = $mailman3::params::web_django_superadmin_pass,
+  $django_version         = $mailman3::params::web_django_version,
+  $hyperkitty_version     = $mailman3::params::web_hyperkitty_version,
+  $install_web            = $mailman3::params::install_web,
+  $manage_database        = $mailman3::params::web_manage_database,
+  $manage_django_packages = $mailman3::params::web_manage_django_packages,
+  $manage_firewall        = $mailman3::params::web_manage_firewall,
+  $manage_searchengine    = $mailman3::params::web_manage_searchengine,
+  $manage_proxy_config    = $mailman3::params::web_manage_proxy_config,
+  $manage_webserver       = $mailman3::params::web_manage_webserver,
+  $override_options       = {},
+  $postorius_version      = $mailman3::params::web_postorius_verions,
+  $refresh_service        = $mailman3::params::web_refresh_service,
+  $searchengine_tag       = $mailman3::params::web_searchengine_tag,
+  $service_enabled        = $mailman3::params::web_service_enabled,
+  $web_homedir            = $mailman3::params::web_homedir,
+  $web_user               = $mailman3::params::web_user,
+) inherits mailman3::params {
+
+  # Make sure all of our params are properly formatted
+  validate_array($allowed_hosts)
+  validate_string($db_tag)
+  validate_string($django_superuser_name)
+  validate_string($django_superadmin_pass)
+  validate_string($django_version)
+  validate_string($hyperkitty_version)
+  validate_bool($install_web)
+  validate_bool($manage_database)
+  validate_bool($manage_django_packages)
+  validate_bool($manage_firewall)
+  validate_bool($manage_searchengine)
+  validate_bool($manage_proxy_config)
+  validate_bool($manage_webserver)
+  validate_string($postorius_version)
+  validate_bool($refresh_service)
+  validate_string($searchengine_tag)
+  validate_bool($service_enabled)
+  validate_absolute_path($web_homedir)
+  validate_hash($override_options)
+  validate_string($web_user)
+
+  # Merge default options hash with hash from hiera
+  $options = merge($mailman3::params::web_default_options, $override_options)
+
+  anchor { 'mailman3::web::begin': }
+  anchor { 'mailman3::web::end': }
+
+  class { '::mailman3::web::install':
+    django_version         => $django_version,
+    hyperkitty_version     => $hyperkitty_version,
+    install_web            => $install_web,
+    manage_django_packages => $manage_django_packages,
+    manage_webserver       => $manage_webserver,
+    options                => $options,
+    postorius_version      => $postorius_version,
+    web_homedir            => $web_homedir,
+    web_user               => $web_user,
+  }
+
+  Anchor['mailman3::web::begin'] ->
+    Class['mailman3::web::install'] ->
+  Anchor['mailman3::web::end']
+
+}
diff --git a/manifests/web/install.pp b/manifests/web/install.pp
new file mode 100644 (file)
index 0000000..7cb55e1
--- /dev/null
@@ -0,0 +1,49 @@
+# == Class: mailman3
+#
+# Full description of class mailman3 here.
+#
+# === Parameters
+#
+# Document parameters here.
+#
+# [*sample_parameter*]
+#   Explanation of what this parameter affects and what it defaults to.
+#   e.g. "Specify one or more upstream ntp servers as an array."
+#
+# === Variables
+#
+# Here you should define a list of variables that this module would require.
+#
+# [*sample_variable*]
+#   Explanation of how this variable affects the function of this class and if
+#   it has a default. e.g. "The parameter enc_ntp_servers must be set by the
+#   External Node Classifier as a comma separated list of hostnames." (Note,
+#   global variables should be avoided in favor of class parameters as
+#   of Puppet 2.6.)
+#
+# === Examples
+#
+#  class { 'mailman3':
+#    servers => [ 'pool.ntp.org', 'ntp.local.company.com' ],
+#  }
+#
+# === Authors
+#
+# Josh Farwell <jfarwell@linuxfoundation.org>
+#
+# === Copyright
+#
+# Copyright 2015 Josh Farwell, unless otherwise noted.
+#
+class mailman3::web::install (
+  $django_version,
+  $hyperkitty_version,
+  $install_web,
+  $manage_django_packages,
+  $manage_webserver,
+  $options,
+  $postorius_version,
+  $web_homedir,
+  $web_user,
+)  {
+}
index d6322bb..baed0d2 100644 (file)
@@ -60,7 +60,7 @@ describe 'mailman3::core::install', :type => :class do
       }
     }
 
-    it { is_expected.to contain_package('python-psycopg2') }
+    it { is_expected.to contain_package('python34-psycopg2') }
   end
 
   context 'with a non-Postgresql database in config' do
@@ -77,6 +77,6 @@ describe 'mailman3::core::install', :type => :class do
       }
     }
 
-    it { is_expected.to_not contain_package('python-psycopg2') }
+    it { is_expected.to_not contain_package('python34-psycopg2') }
   end
 end
diff --git a/spec/classes/web_spec.rb b/spec/classes/web_spec.rb
new file mode 100644 (file)
index 0000000..422cf7a
--- /dev/null
@@ -0,0 +1,16 @@
+require 'spec_helper'
+
+describe 'mailman3::web', :type => :class do
+
+  context 'with defaults for all parameters' do
+    it { is_expected.to contain_class('mailman3::web') }
+    it { is_expected.to contain_class('mailman3::params') }
+    it { is_expected.to contain_anchor('mailman3::web::begin') }
+    it { is_expected.to contain_class('mailman3::web::install') }
+    #it { is_expected.to contain_class('mailman3::web::config') }
+    #it { is_expected.to contain_class('mailman3::web::service') }
+    it { is_expected.to contain_anchor('mailman3::web::end') }
+  end
+end
+
+# vim: ts=2 sw=2 sts=2 et :