diff --git a/bacula/Makefile b/bacula/Makefile new file mode 100644 index 0000000..31d7ff9 --- /dev/null +++ b/bacula/Makefile @@ -0,0 +1,17 @@ +include $(CURDIR)/../Makefile.inc + +VERSION = 5.2.13-1 +BASEURL = http://www.bacula-web.org/tl_files/downloads/ +PACKAGE = bacula-web-$(VERSION).tar.gz + +all: manifest $(PACKAGES)/$(PACKAGE) + +manifest: $(MANIFESTS)/bacula.pp + +$(PACKAGES)/$(PACKAGE): + @umask 022 ; echo $@ ; \ + curl -o $@ $(BASEURL)/$(PACKAGE) + +$(MANIFESTS)/bacula.pp: + @umask 022 ; echo $@ ; \ + echo '$$bacula_package_latest = "$(PACKAGE)"' > $@ diff --git a/bacula/manifests/init.pp b/bacula/manifests/init.pp index 9920fa5..7c4ca6d 100644 --- a/bacula/manifests/init.pp +++ b/bacula/manifests/init.pp @@ -145,7 +145,7 @@ class bacula::director($password=undef, } "mysql": { if !$dbpassword { - fail("\$dbpassword is required for bacula::director") + fail("\$dbpassword is required for bacula::director when using '${dbadapter} database") } } default: { @@ -422,3 +422,108 @@ define bacula::device($device, $media) { } + +# Install Bacula web interface +# +# === Parameters +# +# $htaccess: +# Source path for htaccess file used for authentication and +# authorization. +# $webhosts: +# Array containing virtual host names where bacula web will +# will be installed. +# $dbadapter: +# Database type for catalog. Only sqlite and mysql are +# supported. Defaults to sqlite. +# $dbserver: +# Database server address. Defaults to "localhost". Not needed +# for sqlite. +# $dbname: +# Database name. Defaults to "bacula". Not needed for sqlite. +# $dbuser: +# Database user name. Defaults to "bacula". Not needed for sqlite. +# $dbpassword: +# Database password. Not needed for sqlite. +# +class bacula::web($htaccess, + $webhosts=undef, + $dbadapter="sqlite", + $dbserver="localhost", + $dbname="bacula", + $dbuser="bacula", + $dbpassword=undef) { + + if $dbadapter != "sqlite" and !$dbpassword { + fail("\$dbpassword is required for bacula::web when using '${dbadapter}' database") + } + + case $dbadapter { + "mysql": { + class { "php::mysql": + before => File["/usr/local/src/bacula-web.tar.gz"], + } + } + "sqlite": { } + default: { + fail("Invalid \$dbadapter '${dbadapter}' in bacula::web") + } + } + + include php::gd + include php::pdo + + file { "/usr/local/src/bacula-web.tar.gz": + ensure => present, + source => "puppet:///files/packages/${bacula_package_latest}", + mode => "0644", + owner => "root", + group => "root", + require => [ Class["php::gd"], Class["php::pdo"], ], + } + util::extract::tar { "/usr/local/share/bacula-web": + ensure => latest, + source => "/usr/local/src/bacula-web.tar.gz", + require => File["/usr/local/src/bacula-web.tar.gz"], + } + + file { "/usr/local/share/bacula-web/.htaccess": + ensure => present, + source => $htaccess, + mode => "0644", + owner => "root", + group => "root", + require => Util::Extract::Tar["/usr/local/share/bacula-web"], + } + + file { "/usr/local/share/bacula-web/application/config/config.php": + ensure => present, + content => template("bacula/bacula-web.conf.erb"), + mode => "0644", + owner => "root", + group => "root", + require => File["/usr/local/share/bacula-web/.htaccess"], + } + + file { "/usr/local/share/bacula-web/application/view/cache": + ensure => directory, + mode => "0770", + owner => $apache::sslserver::group, + group => $apache::sslserver::group, + require => Util::Extract::Tar["/usr/local/share/bacula-web"], + } + + define configwebhost() { + file { "/srv/www/https/${name}/bacula": + ensure => link, + target => "/usr/local/share/bacula-web", + owner => "root", + group => "root", + require => File["/srv/www/https/${name}"], + } + } + if $webhosts { + configwebhost { $webhosts: } + } + +} diff --git a/bacula/templates/bacula-web.conf.erb b/bacula/templates/bacula-web.conf.erb new file mode 100644 index 0000000..c4c7660 --- /dev/null +++ b/bacula/templates/bacula-web.conf.erb @@ -0,0 +1,25 @@ + +$config[0]['db_type'] = 'sqlite'; +$config[0]['db_name'] = '/srv/bacula/bacula.db'; +<% else -%> +$config[0]['host'] = '<%= @dbserver %>'; +$config[0]['login'] = '<%= @dbuser %>'; +$config[0]['password'] = '<%= @dbpassword %>'; +$config[0]['db_name'] = '<%= @dbname %>'; +$config[0]['db_type'] = 'mysql'; +<% end -%> + +?>