Initial commit

This commit is contained in:
2014-11-23 19:45:01 +00:00
commit 3b1b23732e
19 changed files with 625 additions and 0 deletions

8
.fixtures.yml Normal file
View File

@@ -0,0 +1,8 @@
---
fixtures:
symlinks:
dokuwiki: "#{source_dir}"
repositories:
webapp_config: "https://github.com/optiz0r/puppet-webapp-config.git"
stdlib: "git://github.com/puppetlabs/puppetlabs-stdlib.git"

3
.puppet-lint.rc Normal file
View File

@@ -0,0 +1,3 @@
--no-autoloader_layout-check
--no-class_inherits_from_params_class-check
--no-80chars-check

7
Gemfile Normal file
View File

@@ -0,0 +1,7 @@
source 'https://rubygems.org'
puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 3.3']
gem 'puppet', puppetversion
gem 'puppetlabs_spec_helper', '>= 0.1.0'
gem 'puppet-lint', '>= 0.3.2'
gem 'facter', '>= 1.7.0'

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2014 Ben Roberts
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

97
README.md Normal file
View File

@@ -0,0 +1,97 @@
# dokuwiki
#### Table of Contents
1. [Overview](#overview)
2. [Module Description - What the module does and why it is useful](#module-description)
3. [Setup - The basics of getting started with dokuwiki](#setup)
* [What dokuwiki affects](#what-dokuwiki-affects)
* [Setup requirements](#setup-requirements)
* [Beginning with dokuwiki](#beginning-with-dokuwiki)
4. [Usage - Configuration options and additional functionality](#usage)
5. [Reference - An under-the-hood peek at what the module is doing and how](#reference)
5. [Limitations - OS compatibility, etc.](#limitations)
6. [Development - Guide for contributing to the module](#development)
## Overview
This module installs and configures dokuwiki (https://www.dokuwiki.org/dokuwiki).
## Module Description
The dokuwiki module sets up dokuwiki including package installation, configuration
of both the application and apache.
Under gentoo-based systems it makes use of the `webapp_config` tool.
## Setup
### What dokuwiki affects
* dokiwiki package.
* dokuwiki configuration file.
* apache vhost configuration.
### Setup Requirements
This module assumes apache is already configured and that it can just drop a vhost
definition file into an apache configuration directory.
### Beginning with dokuwiki
```
include '::dokuwiki'
```
## Usage
All options and configuration can be done through interacting with the parameters
on the main dokuwiki class. These are documented below
### dokuwiki class
```
class {
'::dokuwiki':
}
```
## Reference
### Classes
* dokuwiki: Main class for installation,
* dokuwiki::config: Main class for dokuwiki configuration/management.
* dokuwiki::install: Handles package installation.
* dokuwiki::params: Different configuration data for different systems.
### Parameters
## Limitations
This module has been built on and tested against puppet 3.7 and higher.
This module has been tested on:
* Sabayon 2014.12
### Module dependencies
To be able to install multiple instances of dokuwiki on a single host
this module makes use of the `webapp_config` tool on Gentoo-based systems.
It makes use of the `optiz0r-webapp_config` module to manage this, and
you will need to arrange to have a copy of this available on your puppet
master using `r10k`, `librarian-puppet`.
Note, this module is not currently available on the module forge, and can
instead be retrieved from https://github.com/optiz0r/puppet-webapp-config.
## Development
This module is opensource and contributions are welcome. Please feel free
to submit a pull request with any enhancements.
## Authors
* Ben Roberts <me@benroberts.net>

19
Rakefile Normal file
View File

@@ -0,0 +1,19 @@
require 'rubygems'
require 'puppetlabs_spec_helper/rake_tasks'
require 'puppet-lint/tasks/puppet-lint'
PuppetLint.configuration.send('disable_80chars')
PuppetLint.configuration.send('disable_class_inherits_from_params_class')
PuppetLint.configuration.ignore_paths = ["spec/**/*.pp", "pkg/**/*.pp"]
desc "Validate manifests, templates, and ruby files"
task :validate do
Dir['manifests/**/*.pp'].each do |manifest|
sh "puppet parser validate --noop #{manifest}"
end
Dir['spec/**/*.rb','lib/**/*.rb'].each do |ruby_file|
sh "ruby -c #{ruby_file}" unless ruby_file =~ /spec\/fixtures/
end
Dir['templates/**/*.erb'].each do |template|
sh "erb -P -x -T '-' #{template} | ruby -c"
end
end

82
manifests/config.pp Normal file
View File

@@ -0,0 +1,82 @@
# == Class: dokuwiki::config
#
# See the README.md for documentation
#
class dokuwiki::config (
$manage_vhost = $dokuwiki::manage_vhost,
$vhost = $dokuwiki::vhost,
$base_path = $dokuwiki::base_path,
$apache_confdir = $dokuwiki::apache_confdir,
$apache_user = $dokuwiki::apache_user,
$apache_group = $dokuwiki::apache_group,
$install_dir = $dokuwiki::install_dir,
$data_dir = $dokuwiki::data_dir,
$local_conf_template = $dokuwiki::local_conf_template,
$protected_conf_template = $dokuwiki::protected_conf_template,
$wiki_title = $dokuwiki::wiki_title,
$userewrite = $dokuwiki::userewrite,
$use_acl = $dokuwiki::use_acl,
$breadcrumbs = $dokuwiki::breadcrumbs,
$youarehere = $dokuwiki::youarehere,
$updatecheck = $dokuwiki::updatecheck,
$content_license = $dokuwiki::content_license,
$locktime = $dokuwiki::locktime,
$auth_type = $dokuwiki::auth_type,
$ldap_version = $dokuwiki::ldap_version,
$ldap_servers = $dokuwiki::ldap_servers,
$ldap_user_tree = $dokuwiki::ldap_user_tree,
$ldap_user_filter = $dokuwiki::ldap_user_filter,
$ldap_user_scope = $dokuwiki::ldap_user_scope,
$ldap_user_account_attr = $dokuwiki::ldap_user_account_attr,
$ldap_group_tree = $dokuwiki::ldap_group_tree,
$ldap_group_filter = $dokuwiki::ldap_group_filter,
$ldap_group_scope = $dokuwiki::ldap_group_scope,
$ldap_starttls = $dokuwiki::ldap_starttls,
$ldap_use_sso = $dokuwiki::ldap_use_sso,
$ldap_recursive_search = $dokuwiki::ldap_recursive_search,
$ldap_binddn = $dokuwiki::ldap_binddn,
$ldap_bindpw = $dokuwiki::ldap_bindpw,
$use_referrals = $dokuwiki::use_referrals,
$ldap_mapping_name = $dokuwiki::ldap_mapping_name,
$ldap_mapping_groups = $dokuwiki::ldap_mapping_groups,
) {
if $base_path == '' or $base_path =~ /\/$/ {
$base_path_suffix = ''
} else {
$base_path_suffix = '/'
}
file {
"${install_dir}/${base_path}${base_path_suffix}conf/local.php":
content => template($local_conf_template),
owner => 'root',
group => 'root',
mode => '0444',
replace => false;
"${install_dir}/${base_path}${base_path_suffix}conf/local.protected.php":
content => template($protected_conf_template),
owner => 'root',
group => 'root',
mode => '0444';
$data_dir:
ensure => directory,
owner => $apache_user,
group => $apache_group,
mode => '0664';
}
if $manage_vhost {
file {
"${apache_confdir}/${vhost}.conf":
content => template('dokuwiki/vhost.conf.erb'),
owner => 'root',
group => 'root',
mode => '0444';
}
}
}

80
manifests/init.pp Normal file
View File

@@ -0,0 +1,80 @@
# == Class: dokuwiki
#
# See the README.md for documentation
#
class dokuwiki (
$version = $dokuwiki::params::version,
$package_category = $dokuwiki::params::package_category,
$package_name = $dokuwiki::params::package_name,
$use_webapp_config = $dokuwiki::params::use_webapp_config,
$manage_vhost = $dokuwiki::params::manage_vhost,
$vhost = $dokuwiki::params::vhost,
$base_path = $dokuwiki::params::base_path,
$apache_confdir = $dokuwiki::params::apache_confdir,
$apache_user = $dokuwiki::params::apache_user,
$apache_group = $dokuwiki::params::apache_group,
$vhost_conf_template = $dokuwiki::params::vhost_conf_template,
$install_dir = $dokuwiki::params::install_dir,
$data_dir = $dokuwiki::params::data_dir,
$local_conf_template = $dokuwiki::params::local_conf_template,
$protected_conf_template = $dokuwiki::params::protected_conf_template,
$wiki_title = $dokuwiki::params::wiki_title,
$userewrite = $dokuwiki::params::userewrite,
$use_acl = $dokuwiki::params::use_acl,
$breadcrumbs = $dokuwiki::params::breadcrumbs,
$youarehere = $dokuwiki::params::youarehere,
$updatecheck = $dokuwiki::params::updatecheck,
$content_license = $dokuwiki::params::content_license,
$locktime = $dokuwiki::params::locktime,
$auth_type = $dokuwiki::params::auth_type,
$ldap_version = $dokuwiki::params::ldap_version,
$ldap_servers = $dokuwiki::params::ldap_servers,
$ldap_user_tree = $dokuwiki::params::ldap_user_tree,
$ldap_user_filter = $dokuwiki::params::ldap_user_filter,
$ldap_user_scope = $dokuwiki::params::ldap_user_scope,
$ldap_user_account_attr = $dokuwiki::params::ldap_user_account_attr,
$ldap_group_tree = $dokuwiki::params::ldap_group_tree,
$ldap_group_filter = $dokuwiki::params::ldap_group_filter,
$ldap_group_scope = $dokuwiki::params::ldap_group_scope,
$ldap_starttls = $dokuwiki::params::ldap_starttls,
$ldap_use_sso = $dokuwiki::params::ldap_use_sso,
$ldap_recursive_search = $dokuwiki::params::ldap_recursive_search,
$ldap_binddn = $dokuwiki::params::ldap_binddn,
$ldap_bindpw = $dokuwiki::params::ldap_bindpw,
$use_referrals = $dokuwiki::params::use_referrals,
$ldap_mapping_name = $dokuwiki::params::ldap_mapping_name,
$ldap_mapping_groups = $dokuwiki::params::ldap_mapping_groups,
) inherits dokuwiki::params {
# Allow a big-endian date format with optional letter suffix
validate_re($version, '^\d{8}[a-z]?$')
validate_string($package_category)
validate_string($package_name)
validate_bool($use_webapp_config)
validate_bool($manage_vhost)
validate_string($vhost)
validate_string($base_path)
validate_string($apache_confdir)
validate_string($vhost_conf_template)
validate_absolute_path($install_dir)
validate_absolute_path($data_dir)
validate_string($local_conf_template)
validate_string($protected_conf_template)
include '::dokuwiki::install'
include '::dokuwiki::config'
# Anchor this as per #8040 - this ensures that classes won't float off and
# mess everything up. You can read about this at:
# http://docs.puppetlabs.com/puppet/2.7/reference/lang_containment.html#known-issues
anchor {
'dokuwiki::begin': ;
'dokuwiki::end': ;
}
Anchor['dokuwiki::begin']
-> Class['::dokuwiki::install']
-> Class['::dokuwiki::config']
-> Anchor['dokuwiki::end']
}

34
manifests/install.pp Normal file
View File

@@ -0,0 +1,34 @@
# == Class: dokuwiki::install
#
# See the README.md for documentation
#
class dokuwiki::install (
$version = $dokuwiki::version,
$package_category = $dokuwiki::package_category,
$package_name = $dokuwiki::package_name,
$use_webapp_config = $dokuwiki::use_webapp_config,
$vhost = $dokuwiki::vhost,
$base_path = $dokuwiki::base_path,
) {
package {
'www-apps/dokuwiki':
ensure => $version,
category => $package_category,
name => $package_name;
}
if $use_webapp_config {
webapp_config {
"dokuwiki-${version}":
action => 'install',
vhost => $vhost,
base => $base_path,
app => 'dokuwiki',
version => $version,
depends => Package['www-apps/dokuwiki'];
}
}
}

61
manifests/params.pp Normal file
View File

@@ -0,0 +1,61 @@
# == Class: dokuwiki::params
#
# See the README.md for documentation
#
class dokuwiki::params {
case $::osfamily {
'Gentoo': {
$package_category = 'www-apps'
$package_name = 'dokuwiki'
$version = '20140929a'
$use_webapp_config = true
$apache_confdir = '/etc/apache/vhosts.d'
$apache_user = 'apache'
$apache_group = 'apache'
}
default: {
fail("The ${module_name} module is not supported on an ${::osfamily} based system.")
}
}
$manage_vhost = true
$vhost = 'dokuwiki.example.com'
$base_path = 'dokuwiki'
$install_dir = '/var/www/localhost/htdocs'
$data_dir = '/var/www/localhost/htdocs/data'
$vhost_conf_template = 'dokuwiki/vhost.conf.erb'
$local_conf_template = 'dokuwiki/local.php.erb'
$protected_conf_template = 'dokuwiki/local.protected.php.erb'
# Configuration directives
$wiki_title = 'dokuwiki'
$userewrite = true
$use_acl = true
$breadcrumbs = false
$youarehere = true
$updatecheck = false
$content_license = 'CC-BY-SA'
$locktime = 30*60
$auth_type = 'ldap'
$ldap_version = 3
$ldap_servers = ['ldap']
$ldap_user_tree = 'ou=People,dc=local'
$ldap_user_filter = '(&(uid=%{user})(objectClass=posixAccount))'
$ldap_user_scope = 'sub'
$ldap_user_account_attr = 'uid'
$ldap_group_tree = 'ou=Group,dc=local'
$ldap_group_filter = '(&(objectClass=posixGroup)(|(gidNumber=%{gid})(memberUid=%{user})))'
$ldap_group_scope = 'sub'
$ldap_starttls = true
$ldap_use_sso = true
$ldap_recursive_search = true
$ldap_binddn = 'cn=admin,dc=local'
$ldap_bindpw = 'changeme'
$use_referrals = true
$ldap_mapping_name = 'name'
$ldap_mapping_groups = []
}

14
metadata.json Normal file
View File

@@ -0,0 +1,14 @@
{
"name": "optiz0r-dokuwiki",
"version": "0.1.0",
"author": "Ben Roberts",
"summary": "Installs and configures dokuwiki",
"license": "MIT",
"source": "https://gitlab.sihnon.net/ben/puppet-dokuwiki.git",
"project_page": "https://gitlab.sihnon.net/ben/puppet-dokuwiki",
"issues_url": "https://gitlab.sihnon.net/ben/puppet-dokuwiki/issues",
"dependencies": [
{"name":"puppetlabs-stdlib","version_requirement":">= 1.0.0"}
]
}

View File

@@ -0,0 +1,23 @@
require 'spec_helper'
describe 'dokuwiki::config' do
context 'with defaults for all parameters' do
let(:params) {{
:manage_vhost => true,
:vhost => 'dokuwiki.example.com',
:base_path => 'dokuwiki',
:apache_confdir => '/etc/apache2/vhosts.d',
:install_dir => '/var/www/localhost/htdocs',
:local_conf_template => 'dokuwiki/local.php.erb',
:protected_conf_template => 'dokuwiki/local.protected.php.erb',
:ldap_servers => ['ldap'],
}}
it { should contain_file('/var/www/localhost/htdocs/dokuwiki/conf/local.php') }
it {
should contain_file('/var/www/localhost/htdocs/dokuwiki/conf/local.protected.php')
.with_content(/Managed by puppet/)
}
end
end

23
spec/classes/init_spec.rb Normal file
View File

@@ -0,0 +1,23 @@
require 'spec_helper'
describe 'dokuwiki' do
context 'on unsupported distributions' do
let(:facts) {{
:osfamily => 'Unsupported',
}}
it 'we fail' do
expect { subject }.to raise_error(/not supported on an Unsupported/)
end
end
context 'with defaults for all parameters' do
let(:facts) {{
:osfamily => 'Gentoo',
}}
it { should contain_class('dokuwiki') }
it { should contain_class('dokuwiki::install') }
it { should contain_class('dokuwiki::config') }
end
end

View File

@@ -0,0 +1,17 @@
require 'spec_helper'
describe 'dokuwiki::install' do
context 'with defaults for all parameters' do
it { should contain_package('www-apps/dokuwiki') }
end
context 'on Gentoo' do
let(:params) {{
:use_webapp_config => true,
:version => '123'
}}
it { should contain_webapp_config('dokuwiki-123') }
end
end

2
spec/spec_helper.rb Normal file
View File

@@ -0,0 +1,2 @@
require 'puppetlabs_spec_helper/module_spec_helper'
require 'hiera'

13
templates/local.php.erb Normal file
View File

@@ -0,0 +1,13 @@
<?php
/**
* This initial file was deployed via puppet but will not be replaced
* and can be modified using the dokuwiki admin interface. Settings
* that should be continually managed by puppet should be put into the
* local.protected.php file instead.
*
* This is an example of how a local.php could look like.
* Simply copy the options you want to change from dokuwiki.php
* to this file and change them.
*/

View File

@@ -0,0 +1,49 @@
<?php
# Managed by puppet
# Local modifications to this file will be lost
$conf['title'] = '<%= @wiki_title %>';
$conf['savedir'] = '<%= @data_dir %>';
$conf['useacl'] = <%= @use_acl ? 1 : 0 %>;
$conf['userewrite'] = <%= @use_rewrite ? 1 : 0 %>;
# Disable use of any standard content licenses, e.g. CC
$conf['license'] = '<%= @content_license %>';
# Override the page lock timer
$conf['locktime'] = <%= @locktime %>; # 30*60
# User interface tweaks
$conf['breadcrumbs'] = <%= @breadcrumbs ? 1 : 0 %>;
$conf['youarehere'] = <%= @youarehere ? 1 : 0 %>;
$conf['updatecheck'] = <%= @updatecheck ? 1 : 0 %>;
# Authentication
$conf['openregister'] =
$conf['authtype'] = '<%= @auth_type %>';
<%- if @auth_type == 'ldap' -%>
$conf['auth']['ldap']['version'] = '<%= @ldap_version %>';
$conf['auth']['ldap']['server'] = 'ldap://<%= @ldap_servers.join(" ") %>:389';
$conf['auth']['ldap']['usertree'] = '<%= @ldap_user_tree %>';
$conf['auth']['ldap']['userfilter'] = '<%= @ldap_user_filter %>';
$conf['auth']['ldap']['userscope'] = '<%= @ldap_user_scope %>';
$conf['auth']['ldap']['grouptree'] = '<%= @ldap_group_tree %>';
$conf['auth']['ldap']['groupfilter'] = '<%= @ldap_group_filter %>';
$conf['auth']['ldap']['groupscope'] = '<%= @ldap_group_scope %>';
$conf['auth']['ldap']['starttls'] = <%= @ldap_starttls ? 1 : 0 %>;
$conf['auth']['ldap']['sso'] = <%= @ldap_use_sso ? 1 : 0 %>;
$conf['auth']['ldap']['recursive'] = <%= @ldap_recursive_search ? 1 : 0 %>;
$conf['auth']['ldap']['binddn'] = '<%= @ldap_binddn %>';
$conf['auth']['ldap']['bindpw'] = '<%= @ldap_bindpw %>';
$conf['auth']['ldap']['referrals'] = <%= @use_referrals ? 1 : 0 %>;
$conf['auth']['ldap']['mapping']['name'] = '<%= @ldap_mapping_name %>';
$conf['auth']['ldap']['mapping']['grps'] = array();
<%- @ldap_mapping_groups.each do |key, value| -%>
$conf['auth']['ldap']['mapping']['grps']['<%= key %>'] = '<%= value %>';
<%- end -%>
$conf['auth']['ldap']['debug'] = 1;
<%- end -%>
$conf['manager'] = '<%= @management_group %>';
$conf['superuser'] = '<%= @management_group %>';

60
templates/vhost.conf.erb Normal file
View File

@@ -0,0 +1,60 @@
<VirtualHost *:80>
ServerName <%= @vhost %>
DocumentRoot <%= @install_dir %>/<%= @base_path %>
# Permit larger file uploads
php_value upload_max_filesize 20M
# Must be at least as large as upload_max_filesize, plus a bit
# for the form metadata
php_value post_max_size 24M
<Directory "<%= @install_dir %>/<%= @base_path %><%= @base_path_suffix %>">
AllowOverride None
Options +FollowSymLinks
Order Allow,Deny
Allow from All
<%- if @auth_type == 'ldap' -%>
AuthType Basic
AuthName "LDAP Auth"
AuthBasicProvider "ldap"
AuthLDAPUrl "ldap://<%= @ldap_servers.join(" ") %>:389/<%= @ldap_usertree %>?<%= @ldap_user_account_attr %>?<%= @ldap_user_scope %>"
Require valid-user
<%- end -%>
RewriteEngine on
RewriteBase /<%= @base_path %><%= @base_path_suffix %>
RewriteRule ^_media/(.*) lib/exe/fetch.php?media=$1 [QSA,L]
RewriteRule ^_detail/(.*) lib/exe/detail.php?media=$1 [QSA,L]
RewriteRule ^_export/([^/]+)/(.*) doku.php?do=export_$1&id=$2 [QSA,L]
RewriteRule ^$ doku.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) doku.php?id=$1 [QSA,L]
RewriteRule ^index.php$ doku.php
</Directory>
# Explicitly deny access to all code and configuration directories
<Directory "<%= @install_dir %>/<%= @base_path %><%= @base_path_suffix %>/inc">
Order Deny,Allow
Deny from all
</Directory>
<Directory "<%= @install_dir %>/<%= @base_path %><%= @base_path_suffix %>/inc/lang">
Order Deny,Allow
Deny from all
</Directory>
<Directory "<%= @install_dir %>/<%= @base_path %><%= @base_path_suffix %>/lib/_fla">
## no access to the fla directory
Order allow,deny
Deny from all
</Directory>
<Directory /etc/dokuwiki>
Order Deny,Allow
Deny from all
</Directory>
</VirtualHost>

12
tests/init.pp Normal file
View File

@@ -0,0 +1,12 @@
# The baseline for module testing used by Puppet Labs is that each manifest
# should have a corresponding test manifest that declares that class or defined
# type.
#
# Tests are then run by using puppet apply --noop (to check for compilation
# errors and view a log of events) or by fully applying the test in a virtual
# environment (to compare the resulting system state to the desired state).
#
# Learn more about module testing here:
# http://docs.puppetlabs.com/guides/tests_smoke.html
#
include dokuwiki