Use && in between the shell commands in the exects so that if any of the commands inside fail, the entire exec resource will fail.
With ; in between each shell command, the command chain would continue on even if one of the commands returned a non-0 exit status. Because this would make Puppet think the entire exec resource succeeded, Puppet would continue on configuring the rest of the resources in icinga2::server and all of its subclasses. With && in between each subcommand, the execs will fail if any of the subcommands fail and Puppet will skip the rest of the module's resources, not leaving things in a bad state.
This commit is contained in:
parent
2879c0c2cd
commit
f9f7cc5ad9
1 changed files with 4 additions and 4 deletions
|
@ -115,7 +115,7 @@ class icinga2::server::install::execs inherits icinga2::server {
|
|||
exec { 'mysql_schema_load':
|
||||
user => 'root',
|
||||
path => '/usr/bin:/usr/sbin:/bin/:/sbin',
|
||||
command => "mysql -u ${db_user} -p${db_password} ${db_name} < ${server_db_schema_path}; touch /etc/icinga2/mysql_schema_loaded.txt",
|
||||
command => "mysql -u ${db_user} -p${db_password} ${db_name} < ${server_db_schema_path} && touch /etc/icinga2/mysql_schema_loaded.txt",
|
||||
creates => "/etc/icinga2/mysql_schema_loaded.txt",
|
||||
require => Class['icinga2::server::install::packages'],
|
||||
}
|
||||
|
@ -123,7 +123,7 @@ class icinga2::server::install::execs inherits icinga2::server {
|
|||
exec { 'mysql_module_enable':
|
||||
user => 'root',
|
||||
path => '/usr/bin:/usr/sbin:/bin/:/sbin',
|
||||
command => "/usr/sbin/icinga2-enable-feature ido-mysql; touch /etc/icinga2/mysql_module_loaded.txt",
|
||||
command => "/usr/sbin/icinga2-enable-feature ido-mysql && touch /etc/icinga2/mysql_module_loaded.txt",
|
||||
creates => "/etc/icinga2/mysql_module_loaded.txt",
|
||||
require => Exec['mysql_schema_load'],
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ class icinga2::server::install::execs inherits icinga2::server {
|
|||
exec { 'postgres_schema_load':
|
||||
user => 'root',
|
||||
path => '/usr/bin:/usr/sbin:/bin/:/sbin',
|
||||
command => "su postgres -c 'export PGPASSWORD='${db_password}'; psql -U ${db_user} -h localhost -d ${db_name} < ${server_db_schema_path}'; export PGPASSWORD=''; touch /etc/icinga2/postgres_schema_loaded.txt",
|
||||
command => "su postgres -c 'export PGPASSWORD='${db_password}' && psql -U ${db_user} -h localhost -d ${db_name} < ${server_db_schema_path}' && export PGPASSWORD='' && touch /etc/icinga2/postgres_schema_loaded.txt",
|
||||
creates => "/etc/icinga2/postgres_schema_loaded.txt",
|
||||
require => Class['icinga2::server::install::packages'],
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ class icinga2::server::install::execs inherits icinga2::server {
|
|||
exec { 'postgres_module_enable':
|
||||
user => 'root',
|
||||
path => '/usr/bin:/usr/sbin:/bin/:/sbin',
|
||||
command => "/usr/sbin/icinga2-enable-feature ido-pgsql; touch /etc/icinga2/postgres_module_loaded.txt",
|
||||
command => "/usr/sbin/icinga2-enable-feature ido-pgsql && touch /etc/icinga2/postgres_module_loaded.txt",
|
||||
creates => "/etc/icinga2/postgres_module_loaded.txt",
|
||||
require => Exec['postgres_schema_load'],
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue