diff --git a/Modulefile b/Modulefile index bd80419..633cc1e 100644 --- a/Modulefile +++ b/Modulefile @@ -1,10 +1,10 @@ -name 'kreczko-apelpublisher' +name 'heppuppet-apelpublisher' version '0.0.2' -author 'kreczko' +author 'HEP-Puppet' license 'Apache License, Version 2.0' project_page 'https://github.com/HEP-Puppet' source 'git@github.com:HEP-Puppet/puppet-apelpublisher.git' summary 'A Puppet module for the installation and setup of a Apel publisher' description 'A Puppet module for the installation and setup of a Apel publisher' -dependency 'puppetlabs/mysql', '>=0.6.1' +dependency 'puppetlabs/mysql', '>=2.0.0' diff --git a/manifests/config.pp b/manifests/config.pp old mode 100644 new mode 100755 index 0a74d56..5ec8bbb --- a/manifests/config.pp +++ b/manifests/config.pp @@ -17,16 +17,16 @@ $logging_logfile = $apelpublisher::params::logging_logfile, $logging_level = $apelpublisher::params::logging_level, $logging_console = $apelpublisher::params::logging_console, - ) inherits apelpublisher::params { - +) inherits apelpublisher::params { + file { '/etc/apel/client.cfg': - owner => "root", - group => "root", - ensure => "present", + owner => 'root', + group => 'root', + ensure => 'present', content => template("${module_name}/client.cfg.erb"), require => [Package['apel-client'],Package['apel-ssm']], - mode => 600, + mode => '0600', } - + include apelpublisher::ssm::sender } diff --git a/manifests/config/mysql.pp b/manifests/config/mysql.pp index 491bc82..db51d75 100644 --- a/manifests/config/mysql.pp +++ b/manifests/config/mysql.pp @@ -4,29 +4,29 @@ $mysql_backup_folder = $apelpublisher::params::mysql_backup_folder, $mysql_apel_password = $apelpublisher::params::mysql_apel_password, ) inherits apelpublisher::params { - + if !$mysql_root_password { - notify { "Using empty ROOT password. Please fix.": } + notify { 'Using empty ROOT password. Please fix.': } } - + ############################ # MySQL server and settings ############################ class { 'mysql::server': - config_hash => { - 'root_password' => $mysql_root_password, + root_password => $mysql_root_password, + override_options => { + mysqld => { 'bind_address' => '0.0.0.0' } } } - class { 'mysql': - } - if $mysql_configure_backup { class { 'mysql::backup': - backupuser => 'root', + # it always tries to create the backup user, + # using 'root' here causes a 'duplicate declaration' error + backupuser => 'mysqlbackup', backuppassword => $mysql_root_password, backupdir => $mysql_backup_folder, } } - + } diff --git a/manifests/create_database.pp b/manifests/create_database.pp index c10af6c..96de41a 100644 --- a/manifests/create_database.pp +++ b/manifests/create_database.pp @@ -3,7 +3,9 @@ $mysql_user = $apelpublisher::params::mysql_user, $mysql_root_password = $apelpublisher::params::mysql_root_password, $mysql_apel_password = $apelpublisher::params::mysql_apel_password, - $list_of_apel_parser_hosts = $apelpublisher::params::list_of_apel_parser_hosts,) inherits apelpublisher::params { + $list_of_apel_parser_hosts = $apelpublisher::params::list_of_apel_parser_hosts, +) inherits apelpublisher::params { + mysql::db { $mysql_database: user => $mysql_user, password => $mysql_apel_password @@ -19,13 +21,17 @@ } exec { 'create-apel-mysql-tables': - command => '/usr/bin/mysql --defaults-file=/root/.my.cnf apelclient < /usr/share/apel/client.sql', + command => "/usr/bin/mysql --defaults-file=/root/.my.cnf ${mysql_database} < /usr/share/apel/client.sql", require => [ Class["apelpublisher::install"], - Database[$mysql_database]], + Mysql_database[$mysql_database] + ], # needs check if already exists, otherwise will wipe the tables! onlyif => [ - '/usr/bin/test `/usr/bin/mysql --defaults-file=/root/.my.cnf -e "use apelclient; show tables;SELECT FOUND_ROWS();" 2>&1 | cut -f1 | egrep "^(0|[1-9][0-9]*)$"` -eq 0', - '/usr/bin/test -f /usr/share/apel/client.sql'], + # only run if the database exists and does not contain any tables (found rows == 0), don't run in all other cases + "/usr/bin/mysql --defaults-file=/root/.my.cnf -BNe 'show tables; SELECT FOUND_ROWS();' ${mysql_database} | /bin/grep '^0$'", + '/usr/bin/test -f /usr/share/apel/client.sql' + ], + logoutput => 'on_failure', } -} \ No newline at end of file +} diff --git a/manifests/db_permissions.pp b/manifests/db_permissions.pp index 5737a7f..e51edc8 100644 --- a/manifests/db_permissions.pp +++ b/manifests/db_permissions.pp @@ -2,6 +2,9 @@ $host = $title, $mysql_user = $apelpublisher::params::mysql_user, $mysql_database = $apelpublisher::params::mysql_database,) { - database_grant { "'${mysql_user}'@'${host}'/${mysql_database}": privileges => [ - 'all'], } -} \ No newline at end of file + mysql_grant { "'${mysql_user}@${host}'/${mysql_database}": + privileges => ['all'], + table => "${mysql_database}.*", + user => "${mysql_user}@${host}" + } +} diff --git a/manifests/params.pp b/manifests/params.pp index 08806aa..3ba1a7b 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -17,7 +17,6 @@ $joiner_local_jobs = false $joiner_enabled = true - $unloader_enabled = true $unloader_dir_location = "/var/spool/apel/" $unloader_send_summaries = false diff --git a/manifests/repositories.pp b/manifests/repositories.pp index 604a84e..aa82c4f 100644 --- a/manifests/repositories.pp +++ b/manifests/repositories.pp @@ -1,4 +1,5 @@ -class apelpublisher::repositories { +class apelpublisher::repositories inherits apelpublisher::params { + yumrepo { 'epel': descr => 'Extra Packages for Enterprise Linux 6 - $basearch', enabled => 1, @@ -47,4 +48,5 @@ enabled => 1, priority => 40, } -} \ No newline at end of file + +} diff --git a/manifests/service.pp b/manifests/service.pp index 0f8483b..058f3fe 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -1,12 +1,17 @@ class apelpublisher::service ( $runboot = false, - $runcron = true,) { + $runcron = true, +) { if $::osfamily == 'RedHat' and $::operatingsystemversion =~ /^5\..*/ { - $pkgname = fetch-crl3 + $pkgname = 'fetch-crl3' } else { - $pkgname = fetch-crl + $pkgname = 'fetch-crl' } + package { $pkgname : + ensure => 'present', + } + service { "${pkgname}-boot": ensure => $runboot, enable => $runboot, @@ -19,6 +24,6 @@ enable => $runcron, hasstatus => true, hasrestart => true, - require => Class["fetchcrl::install"]; + require => Package[$pkgname]; } -} \ No newline at end of file +} diff --git a/manifests/ssm/sender.pp b/manifests/ssm/sender.pp index e10da0f..6e6502c 100644 --- a/manifests/ssm/sender.pp +++ b/manifests/ssm/sender.pp @@ -1,6 +1,6 @@ /** * This sets up the SSM sender - * + * * The erb curently is not using any option */ class apelpublisher::ssm::sender( @@ -9,11 +9,11 @@ $ldap_host = $apelpublisher::params::ldap_host, $use_ssl = $apelpublisher::params::use_ssl, ) inherits apelpublisher::params { - + file { '/etc/apel/sender.cfg': - owner => "root", - group => "root", - ensure => "present", + owner => 'root', + group => 'root', + ensure => 'present', content => template("${module_name}/sender.cfg.erb"), require => Package['apel-ssm'], } diff --git a/metadata.json b/metadata.json index 743df19..806bfe2 100644 --- a/metadata.json +++ b/metadata.json @@ -1,8 +1,8 @@ { - "name": "kreczko-apelpublisher", + "name": "heppuppet-apelpublisher", "version": "0.0.2", "summary": "A Puppet module for the installation and setup of a Apel publisher", - "author": "kreczko", + "author": "HEP-Puppet", "description": "A Puppet module for the installation and setup of a Apel publisher", "dependencies": [ { @@ -15,4 +15,4 @@ "source": "git@github.com:HEP-Puppet/puppet-apelpublisher.git", "project_page": "https://github.com/HEP-Puppet", "license": "Apache License, Version 2.0" -} \ No newline at end of file +} diff --git a/templates/sender.cfg.erb b/templates/sender.cfg.erb index 754bbae..e8b00e7 100644 --- a/templates/sender.cfg.erb +++ b/templates/sender.cfg.erb @@ -4,7 +4,7 @@ [broker] -# The SSM will query a BDII to find brokers available. These details are for the +# The SSM will query a BDII to find brokers available. These details are for the # EGI production broker network bdii: ldap://<%= @ldap_host %>:2170 network: <%= @msg_network %> @@ -13,7 +13,7 @@ network: <%= @msg_network %> #port: 6163 # broker authentication. If use_ssl is set, the certificates configured -# in the mandatory [certificates] section will be used. +# in the mandatory [certificates] section will be used. use_ssl: <%= @use_ssl %>