Permalink
Browse files

Added link metamodule and POF psick web interface for automatic links…

…-portals generation. Work at very early stages.
  • Loading branch information...
root
root committed Dec 8, 2010
1 parent 76ba354 commit 8ac216898d04ebcabdc0aa4a7274f06051f95729
View
@@ -0,0 +1,32 @@
+define link (
+ $title,
+ $description='',
+ $url,
+ $host,
+ $priority='50',
+ $type='admin',
+ $private='no',
+ $linktags='',
+ $login='',
+ $password='',
+ $enable='true',
+ $tool=''
+ ) {
+
+ if ($tool =~ /psick/) {
+ link::psick { "$name":
+ title => $title,
+ description => $description,
+ url => $url,
+ host => $host,
+ priority => $priority,
+ type => $type,
+ private => $private,
+ linktags => $linktags,
+ login => $login,
+ password => $password,
+ enable => $enable,
+ }
+ }
+
+}
View
@@ -0,0 +1,38 @@
+define link::psick (
+ $title,
+ $description='',
+ $url,
+ $host,
+ $priority,
+ $type='admin',
+ $private='no',
+ $linktags='',
+ $login='',
+ $password='',
+ $enable='true'
+ ) {
+
+ $ensure = $enable ? {
+ "false" => "absent",
+ false => "absent",
+ "no" => "absent",
+ "true" => "present",
+ true => "present",
+ "yes" => "present",
+ }
+
+ include psick::params
+ include psick::node
+
+ @@file { "${psick::params::workdir}/${host}/${priority}-${name}":
+ mode => "644",
+ owner => "${psick::params::user}",
+ group => "${psick::params::user}",
+ ensure => "${ensure}",
+ require => File["${psick::params::workdir}"],
+ content => template('psick/link.erb'),
+ tag => 'psick_link',
+ notify => Exec["psick-build.sh"],
+ }
+
+}
View
@@ -0,0 +1,34 @@
+#!/bin/bash
+# Very basic, very alpha, Psick IndexPage builder
+
+configfile="/etc/psick/psick.conf"
+
+# Load general configurations
+if [ ! -f $configfile ] ; then
+ echo "Config file: $configfile not found"
+ exit 1
+else
+ . $configfile
+fi
+
+# Main functions
+build_index () {
+ for host in $(ls -v1 $workdir) ; do
+ echo "<h2>$host</h2>" >> $indexfile
+ for link in $(ls -v1 $workdir/$host) ; do
+ cat $workdir/$host/$link >> $indexfile
+ done
+ done
+}
+
+build_header () {
+ cat $confdir/templates/header.html > $indexfile
+}
+
+build_footer () {
+ cat $confdir/templates/footer.html >> $indexfile
+}
+
+build_header
+build_index
+build_footer
@@ -0,0 +1,2 @@
+</body>
+</html>
@@ -0,0 +1,7 @@
+<html>
+<head>
+<title>Puppet Systems Intranet Contruction Kit - Pre-pre-pre-alpha</title>
+</head>
+<body>
+<h1>Puppet Systems Intranet Contruction Kit</h1>
+
View
@@ -0,0 +1,71 @@
+class psick {
+
+ require psick::params
+
+ # Main configuration file
+ file { "psick.conf":
+ path => "${psick::params::confdir}/psick.conf",
+ mode => "644",
+ owner => "${psick::params::user}",
+ group => "${psick::params::user}",
+ ensure => present,
+ content => template("psick/psick.conf.erb"),
+ require => File["psick_confdir"],
+ }
+
+ # psick static page build command
+ file { "psick-build.sh":
+ path => "/usr/sbin/psick-build.sh",
+ mode => "750",
+ owner => "${psick::params::user}",
+ group => "${psick::params::user}",
+ ensure => present,
+ source => "${psick::params::general_base_source}/psick/psick-build.sh",
+ }
+
+ exec { "psick-build.sh":
+ command => "/usr/sbin/psick-build.sh",
+ unless => "ls ${psick::params::outputdir}/index.html",
+ }
+
+ # psick templatedis
+ file { "psick_templatesdir":
+ path => "${psick::params::confdir}/templates",
+ mode => "755",
+ owner => "${psick::params::user}",
+ group => "${psick::params::user}",
+ ensure => present,
+ source => "${psick::params::general_base_source}/psick/templates/",
+ recurse => true,
+ # purge => true,
+ ignore => ".svn",
+ require => File["psick_confdir"],
+ }
+
+ file { "psick_confdir":
+ path => "${psick::params::confdir}",
+ mode => "755",
+ owner => "${psick::params::user}",
+ group => "${psick::params::user}",
+ ensure => directory,
+ }
+
+ file { "psick_workdir":
+ path => "${psick::params::workdir}",
+ mode => "755",
+ owner => "${psick::params::user}",
+ group => "${psick::params::user}",
+ ensure => directory,
+ }
+
+ file { "psick_outputdir":
+ path => "${psick::params::outputdir}",
+ mode => "755",
+ owner => "${psick::params::user}",
+ group => "${psick::params::user}",
+ ensure => directory,
+ }
+
+ File <<| tag == 'psick_link' |>>
+
+}
View
@@ -0,0 +1,9 @@
+class psick::node {
+ @@file { "${psick::params::workdir}/${host}":
+ mode => "755",
+ owner => "${psick::params::user}",
+ group => "${psick::params::user}",
+ ensure => directory,
+ tag => 'psick_link',
+ }
+}
View
@@ -0,0 +1,42 @@
+# Class: psick::params
+#
+# Sets internal variables and defaults for psick module
+# This class is automatically loaded in all the classes that use the values set here
+#
+class psick::params {
+
+ include apache::params
+
+## DEFAULTS FOR VARIABLES USERS CAN SET
+# (Here are set the defaults, provide your custom variables externally)
+# (The default used is in the line with '')
+
+ $workdir = "/var/tmp/psick"
+ $confdir = "/etc/psick"
+ $user = "www-data"
+ $outputdir = $operatingsystem ? {
+ debian => "/var/www/psick",
+ ubuntu => "/var/www/psick",
+ suse => "/srv/www/psick",
+ default => "/var/www/html/psick",
+ }
+
+## FILE SERVING SOURCE
+# Sets the correct source for static files
+# In order to provide files from different sources without modifying the module
+# you can override the default source path setting the variable $base_source
+# Ex: $base_source="puppet://ip.of.fileserver" or $base_source="puppet://$servername/myprojectmodule"
+# What follows automatically manages the new source standard (with /modules/) from 0.25
+
+ case $base_source {
+ '': {
+ $general_base_source = $puppetversion ? {
+ /(^0.25)/ => "puppet:///modules",
+ /(^0.)/ => "puppet://$servername",
+ default => "puppet:///modules",
+ }
+ }
+ default: { $general_base_source=$base_source }
+ }
+
+}
View
@@ -0,0 +1 @@
+<a href="<%= url %>"><%= title %></a> (<%= login %>:<%= password %>) - <%= description %></br>
@@ -0,0 +1,8 @@
+# General configuration file for psick
+# This file is managed by Puppet
+
+# Directory locations
+confdir="<%= scope.lookupvar('psick::params::confdir') %>"
+outputdir="<%= scope.lookupvar('psick::params::outputdir') %>"
+workdir="<%= scope.lookupvar('psick::params::workdir') %>"
+indexfile="$outputdir/index.html"

0 comments on commit 8ac2168

Please sign in to comment.