From 6ea8ddca1d0756323b84648786d58079410be945 Mon Sep 17 00:00:00 2001 From: JohnEricson Date: Wed, 16 Sep 2015 19:09:28 +0200 Subject: [PATCH] FEAT: Ported to Windows. --- manifests/config.pp | 85 +++++++++++++++++-------- manifests/database.pp | 13 +++- manifests/init.pp | 8 +++ manifests/params.pp | 20 +++++- manifests/setup.pp | 17 +++-- manifests/webapp.pp | 78 +++++++++++++---------- templates/context/mysql/context.xml.erb | 2 +- templates/context/pgsql/context.xml.erb | 2 +- 8 files changed, 156 insertions(+), 69 deletions(-) diff --git a/manifests/config.pp b/manifests/config.pp index fcd9565..7c160c0 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -1,31 +1,56 @@ # == Class: pentaho::config + + class pentaho::config { + # JOE + if $::osfamily == 'Windows' { + $exec_provider = 'cygwin' + } else { + $exec_provider = 'posix' + } + if $caller_module_name != $module_name { fail("Use of private class ${name} by ${caller_module_name}") } exec { "/bin/mkdir -p ${pentaho::pentaho_solutions_path}" : + # TODO: I added command when I error trialed. JOE + command => "/bin/mkdir -p ${pentaho::pentaho_solutions_path}", unless => "/usr/bin/stat ${pentaho::pentaho_solutions_path}", + provider => $exec_provider, } -> - exec { "/bin/cp -r ${pentaho::temp_folder}/biserver-ce/pentaho-solutions ${pentaho::pentaho_solutions_path}" : - unless => "/usr/bin/stat ${pentaho::pentaho_solutions_path}/pentaho-solutions", + # I get this errors for some reason on one Windows server: + # Notice: /Stage[main]/Pentaho::Config/Exec[/bin/cp -r 'c:/Temp/biserver-ce/pentaho-solutions' 'e:/Fast2/pentaho']/returns: /bin/cp: cannot stat ΓÇÿc:/Temp/biserver-ce/pentaho-solutionsΓÇÖ: No such file or directory + exec { "/bin/cp -r '${pentaho::temp_folder}/biserver-ce/pentaho-solutions' '${pentaho::pentaho_solutions_path}'": + unless => "/usr/bin/stat '${pentaho::pentaho_solutions_path}/pentaho-solutions'", + provider => $exec_provider, } - + + if !$pentaho::install_samples { + # Remove samples. + file { "${pentaho::pentaho_solutions_path}/pentaho-solutions/system/default-content/samples.zip": + ensure => absent, + subscribe => Exec["/bin/cp -r '${pentaho::temp_folder}/biserver-ce/pentaho-solutions' '${pentaho::pentaho_solutions_path}'"], + } + } + Augeas { - require => Exec["/bin/cp -r ${pentaho::temp_folder}/biserver-ce/pentaho-solutions ${pentaho::pentaho_solutions_path}"], + require => Exec["/bin/cp -r '${pentaho::temp_folder}/biserver-ce/pentaho-solutions' '${pentaho::pentaho_solutions_path}'"], } # Specify the hibernate file to use $hibernate_file = $pentaho::db_type ? { 'mysql' => 'mysql5.hibernate.cfg.xml', 'pgsql' => 'postgresql.hibernate.cfg.xml', } - augeas { 'config_file' : - lens => 'Xml.lns', - incl => "${pentaho::pentaho_solutions_path}/pentaho-solutions/system/hibernate/hibernate-settings.xml", - changes => [ - "set settings/config-file/#text system/hibernate/${hibernate_file}", - ], + unless $::osfamily == 'Windows' { + augeas { 'config_file' : + lens => 'Xml.lns', + incl => "${pentaho::pentaho_solutions_path}/pentaho-solutions/system/hibernate/hibernate-settings.xml", + changes => [ + "set settings/config-file/#text system/hibernate/${hibernate_file}", + ], + } } # Specify delegate class @@ -34,16 +59,18 @@ 'pgsql' => 'org.quartz.impl.jdbcjobstore.PostgreSQLDelegate', } - augeas { 'quartz_properties' : - lens => 'simplevars.lns', - incl => "${pentaho::pentaho_solutions_path}/pentaho-solutions/system/quartz/quartz.properties", - changes => [ - "set org.quartz.jobStore.driverDelegateClass ${delegate_class}", - ], + unless $::osfamily == 'Windows' { + augeas { 'quartz_properties' : + lens => 'simplevars.lns', + incl => "${pentaho::pentaho_solutions_path}/pentaho-solutions/system/quartz/quartz.properties", + changes => [ + "set org.quartz.jobStore.driverDelegateClass ${delegate_class}", + ], + } } - + File { - require => Exec["/bin/cp -r ${pentaho::temp_folder}/biserver-ce/pentaho-solutions ${pentaho::pentaho_solutions_path}"], + require => Exec["/bin/cp -r '${pentaho::temp_folder}/biserver-ce/pentaho-solutions' '${pentaho::pentaho_solutions_path}'"], } file { "${pentaho::pentaho_solutions_path}/pentaho-solutions/system/jackrabbit/repository.xml" : @@ -59,14 +86,20 @@ content => template('pentaho/log4j/log4j_osgi.xml.erb'), } - # Fixing incorrect permissions - $directories = ["${pentaho::pentaho_solutions_path}/pentaho-solutions/system/osgi", "${pentaho::pentaho_solutions_path}/pentaho-solutions/system/logs", "${pentaho::pentaho_solutions_path}/pentaho-solutions/system/logs/audit", "${pentaho::pentaho_solutions_path}/pentaho-solutions/system/jackrabbit", $pentaho::log_directory] - - file { $directories : - ensure => directory, - owner => $pentaho::applicationserver_user, - group => $pentaho::applicationserver_group, - mode => '0755', + unless $::osfamily == 'Windows' { + # Fixing incorrect permissions + $directories = ["${pentaho::pentaho_solutions_path}/pentaho-solutions/system/osgi", "${pentaho::pentaho_solutions_path}/pentaho-solutions/system/logs", "${pentaho::pentaho_solutions_path}/pentaho-solutions/system/logs/audit", "${pentaho::pentaho_solutions_path}/pentaho-solutions/system/jackrabbit", $pentaho::log_directory] + + # For settings advanced Windows permissions you need the acl module. http://stackoverflow.com/questions/25087069/puppet-and-windows-directory-permissions + file { $directories : + ensure => directory, + owner => $pentaho::applicationserver_user, + group => $pentaho::applicationserver_group, + # Group need write support because else the Puppet agent wont be able to create subdirectories. JOE + # mode => '0775', + mode => '0755', + + } } } diff --git a/manifests/database.pp b/manifests/database.pp index df426e1..776be62 100644 --- a/manifests/database.pp +++ b/manifests/database.pp @@ -84,10 +84,21 @@ $db_collate = $pentaho::params::db_collate, ) inherits pentaho::params { + # JOE* + /* + if $::osfamily == 'Windows' { + $mysql_service = Service['MySQL'] + } else { + $mysql_service = Class['mysql::server'] + } + */ + $mysql_service = Class['mysql::server'] + file { "${pentaho::temp_folder}/quartz.sql" : ensure => file, source => "puppet:///modules/pentaho/${pentaho::version}/${pentaho::db_type}/create_quartz.sql", before => Mysql::Db['quartz'], + source_permissions => ignore, } case $pentaho::db_type { @@ -98,7 +109,7 @@ charset => $db_charset, collate => $db_collate, sql => "${pentaho::temp_folder}/quartz.sql", - require => Class['mysql::server'], + require => $mysql_service, } -> mysql::db { 'repository' : user => $hibernate_db_user, diff --git a/manifests/init.pp b/manifests/init.pp index b22af8e..7213f19 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -84,6 +84,11 @@ # (string) The log directory # Default: /var/log/pentaho # +# [*install_samples*] +# (boolean) If to install samples reports and mondrian datasources in /public. Controls if samples.zip is copied to default-content. +# Default: true +# +# # === Examples # # include pentaho @@ -124,9 +129,12 @@ $jackrabbit_db_password = $pentaho::params::jackrabbit_db_password, $pentaho_solutions_path = $pentaho::params::pentaho_solutions_path, $pentaho_source_url = $pentaho::params::pentaho_source_url, + $pentaho_source_checksum = $pentaho::params::pentaho_source_checksum, $h2driver_source_url = $pentaho::params::h2driver_source_url, $temp_folder = $pentaho::params::temp_folder, $log_directory = $pentaho::params::log_directory, + $manage_tomcat_web_xml = $pentaho::params::manage_tomcat_web_xml, + $install_samples = $pentaho::params::install_samples, ) inherits pentaho::params { include ::stdlib diff --git a/manifests/params.pp b/manifests/params.pp index 0482ed9..1743be5 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -1,8 +1,15 @@ # == Class: pentaho::params class pentaho::params { + # JOE + if $::osfamily == 'Windows' { + $default_temp_folder = 'c:/Temp' + } else { + $default_temp_folder = '/var/tmp' + } + $version = '5.1' - + # Application Server $applicationserver_base = '/usr/share/tomcat' $applicationserver_user = 'tomcat' @@ -30,8 +37,14 @@ $country = 'US' $pentaho_solutions_path = '/opt/pentaho' $pentaho_source_url = 'http://downloads.sourceforge.net/project/pentaho/Business%20Intelligence%20Server/5.1/biserver-ce-5.1.0.0-752.zip?r=&ts=1410402175&use_mirror=iweb' - $temp_folder = '/var/tmp' + $pentaho_source_checksum = false + $temp_folder = $default_temp_folder $log_directory = '/var/log/pentaho' + + # Tomcat + $manage_tomcat_web_xml = true + + $install_samples = true case $::osfamily { 'RedHat' : { @@ -40,6 +53,9 @@ 'Debian' : { $postgresql_jdbc_driver_package = 'libpostgresql-jdbc-java' } + 'Windows' : { + warning('Experimental support for Windows.') + } default : { fail("The ${::osfamily} operating system is not supported with the pentaho module") } } diff --git a/manifests/setup.pp b/manifests/setup.pp index 0037ac2..b7761f6 100644 --- a/manifests/setup.pp +++ b/manifests/setup.pp @@ -7,14 +7,21 @@ if 'mysql' in $pentaho::manage_jdbc_drivers { - package { 'mysql-connector-java' : - ensure => installed, + # Ubuntu fix -JOE + # http://stackoverflow.com/questions/18128966/where-is-the-mysql-jdbc-jar-file-in-ubuntu + case $::osfamily { + 'RedHat' : { + package { 'mysql-connector-java': ensure => installed, } + } + 'Debian' : { + package { 'libmysql-java' : ensure => installed, } + } + default : { fail("Installation of MySQL JDBC drivert for ${::osfamily} not implemented.") } }-> file { "${pentaho::applicationserver_base}/lib/mysql-connector-java.jar" : ensure => 'link', target => '/usr/share/java/mysql-connector-java.jar', } - } if 'pgsql' in $pentaho::manage_jdbc_drivers { @@ -40,15 +47,15 @@ } + # Comment away this to improve speed. -JOE archive { 'pentaho' : ensure => present, extension => 'zip', - checksum => false, + checksum => $pentaho::pentaho_source_checksum, follow_redirects => true, url => $pentaho::pentaho_source_url, target => $pentaho::temp_folder, src_target => $pentaho::temp_folder, timeout => 0, } - } diff --git a/manifests/webapp.pp b/manifests/webapp.pp index f681e0d..5f6da85 100644 --- a/manifests/webapp.pp +++ b/manifests/webapp.pp @@ -1,49 +1,61 @@ # == Class: pentaho::webapp class pentaho::webapp { + # JOE + if $::osfamily == 'Windows' { + $exec_provider = 'cygwin' + } else { + $exec_provider = 'posix' + } + if $caller_module_name != $module_name { fail("Use of private class ${name} by ${caller_module_name}") } - exec { "/bin/cp -r ${pentaho::temp_folder}/biserver-ce/tomcat/webapps/pentaho* ${pentaho::applicationserver_base}/webapps/" : + exec { "/bin/cp -r ${pentaho::temp_folder}/biserver-ce/tomcat/webapps/pentaho* '${pentaho::applicationserver_base}/webapps/'" : unless => "/usr/bin/stat ${pentaho::applicationserver_base}/webapps/pentaho", + provider => $exec_provider, } -> file { "${pentaho::applicationserver_base}/webapps/pentaho/META-INF/context.xml" : ensure => file, - content => template("pentaho/context/${pentaho::db_type}/context.xml.erb"), + content => template("pentaho/context/${pentaho::db_type}/context.xml.erb"), } - Augeas { - require => File["${pentaho::applicationserver_base}/webapps/pentaho/META-INF/context.xml"], - } - augeas { 'base_solution' : - lens => 'Xml.lns', - incl => "${pentaho::applicationserver_base}/webapps/pentaho/WEB-INF/web.xml", - changes => [ - "set web-app/context-param[1]/param-value/#text ${pentaho::pentaho_solutions_path}/pentaho-solutions", - ], - } - augeas { 'listen_address' : - lens => 'Xml.lns', - incl => "${pentaho::applicationserver_base}/webapps/pentaho/WEB-INF/web.xml", - changes => [ - "set web-app/context-param[3]/param-value/#text http://${pentaho::listen_ip}:8080/pentaho", - ], - } - augeas { 'rm_hsqldb_autostartup' : - lens => 'Xml.lns', - incl => "${pentaho::applicationserver_base}/webapps/pentaho/WEB-INF/web.xml", - changes => [ - "rm /files${pentaho::applicationserver_base}/webapps/pentaho/WEB-INF/web.xml/web-app/context-param[10]", - ], - } - augeas { 'rm_hsqldb_listener' : - lens => 'Xml.lns', - incl => "${pentaho::applicationserver_base}/webapps/pentaho/WEB-INF/web.xml", - changes => [ - "rm /files${pentaho::applicationserver_base}/webapps/pentaho/WEB-INF/web.xml/web-app/listener[3]", - ], - } + unless $::osfamily == 'Windows' { + Augeas { + require => File["${pentaho::applicationserver_base}/webapps/pentaho/META-INF/context.xml"], + } + if $pentaho::manage_tomcat_web_xml { + augeas { 'base_solution' : + lens => 'Xml.lns', + incl => "${pentaho::applicationserver_base}/webapps/pentaho/WEB-INF/web.xml", + changes => [ + "set web-app/context-param[1]/param-value/#text ${pentaho::pentaho_solutions_path}/pentaho-solutions", + ], + } + augeas { 'listen_address' : + lens => 'Xml.lns', + incl => "${pentaho::applicationserver_base}/webapps/pentaho/WEB-INF/web.xml", + changes => [ + "set web-app/context-param[3]/param-value/#text http://${pentaho::listen_ip}:8080/pentaho", + ], + } + augeas { 'rm_hsqldb_autostartup' : + lens => 'Xml.lns', + incl => "${pentaho::applicationserver_base}/webapps/pentaho/WEB-INF/web.xml", + changes => [ + "rm /files${pentaho::applicationserver_base}/webapps/pentaho/WEB-INF/web.xml/web-app/context-param[10]", + ], + } + augeas { 'rm_hsqldb_listener' : + lens => 'Xml.lns', + incl => "${pentaho::applicationserver_base}/webapps/pentaho/WEB-INF/web.xml", + changes => [ + "rm /files${pentaho::applicationserver_base}/webapps/pentaho/WEB-INF/web.xml/web-app/listener[3]", + ], + } + } + } file { "${pentaho::applicationserver_base}/webapps/pentaho/WEB-INF/classes/log4j.xml" : ensure => file, diff --git a/templates/context/mysql/context.xml.erb b/templates/context/mysql/context.xml.erb index 3bbad08..44424a2 100644 --- a/templates/context/mysql/context.xml.erb +++ b/templates/context/mysql/context.xml.erb @@ -1,5 +1,5 @@ - + - +