diff --git a/CHANGELOG.md b/CHANGELOG.md index c3e1640..67e86ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [v1.8.2] - 2022-11-05 + +### Changed +* Run all app commands on the specified host when `$update_host` is set + ## [v1.8.1] - 2022-11-05 ### Changed diff --git a/REFERENCE.md b/REFERENCE.md index e087b30..5a7ab17 100644 --- a/REFERENCE.md +++ b/REFERENCE.md @@ -344,8 +344,8 @@ Data type: `Optional[String]` Optional parameter to specify the FQDN of the host where all critical operations should be performed. This includes operations such as the -initial installation and consecutive update installations. Limiting these -operations to a single host should prevent (rare) race conditions. +initial installation, update installations and all app commands. +Limiting these operations to a single host should prevent race conditions. Default value: ``undef`` diff --git a/manifests/app_command.pp b/manifests/app_command.pp index 2d2791d..33e2ab7 100644 --- a/manifests/app_command.pp +++ b/manifests/app_command.pp @@ -10,45 +10,49 @@ Enum['install','remove','enable','disable','install_disable','post_update'] $command, String $app = $title, ) { - # Handle special app commands. - case $command { - # Install an app but keep it disabled. - 'install_disable': { - $real_command = 'install --keep-disabled' - $pre_command = '' + # Check if this is the designated update/install host. + if (($nextcloud::update_host == undef or empty($nextcloud::update_host)) + or ($nextcloud::update_host == $facts['networking']['fqdn'])) { + # Handle special app commands. + case $command { + # Install an app but keep it disabled. + 'install_disable': { + $real_command = 'install --keep-disabled' + $pre_command = '' + } + # Ensure that an app is installed after updating Nextcloud. + 'post_update': { + $real_command = 'install' + # First try to update the app. If this command returns a non-zero + # exit code, then try to install the app. + $pre_command = "php occ app:update ${app} ||" + } + default: { + $real_command = $command + $pre_command = '' + } } - # Ensure that an app is installed after updating Nextcloud. - 'post_update': { - $real_command = 'install' - # First try to update the app. If this command returns a non-zero - # exit code, then try to install the app. - $pre_command = "php occ app:update ${app} ||" - } - default: { - $real_command = $command - $pre_command = '' - } - } - # Commands and files required for app installation/removal. - $app_lock = "${nextcloud::datadir}/.puppet_app.lock" - $app_cmd = join([ - "touch ${app_lock};", - $pre_command, - "php occ app:${real_command} ${app}", - '; _exit=$?', # record exit code - "; rm -f ${app_lock}", # always remove lock - '; test $_exit -lt 1 && true', # pass failures to puppet - ], ' ') + # Commands and files required for app installation/removal. + $app_lock = "${nextcloud::datadir}/.puppet_app.lock" + $app_cmd = join([ + "touch ${app_lock};", + $pre_command, + "php occ app:${real_command} ${app}", + '; _exit=$?', # record exit code + "; rm -f ${app_lock}", # always remove lock + '; test $_exit -lt 1 && true', # pass failures to puppet + ], ' ') - # Run the app command. - # NOTE: The command will not run if an update of Nextcloud is running. - exec { "occ app:${command} ${app}": - command => $app_cmd, - path => $nextcloud::path, - cwd => $nextcloud::symlink, - onlyif => "test ! -f ${app_lock} -a ! -f ${nextcloud::update::update_lock}", - user => $nextcloud::system_user, - logoutput => $nextcloud::debug, + # Run the app command. + # NOTE: The command will not run if an update of Nextcloud is running. + exec { "occ app:${command} ${app}": + command => $app_cmd, + path => $nextcloud::path, + cwd => $nextcloud::symlink, + onlyif => "test ! -f ${app_lock} -a ! -f ${nextcloud::update::update_lock}", + user => $nextcloud::system_user, + logoutput => $nextcloud::debug, + } } } diff --git a/manifests/init.pp b/manifests/init.pp index 65179d9..b0f3d41 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -168,8 +168,8 @@ # @param update_host # Optional parameter to specify the FQDN of the host where all critical # operations should be performed. This includes operations such as the -# initial installation and consecutive update installations. Limiting these -# operations to a single host should prevent (rare) race conditions. +# initial installation, update installations and all app commands. +# Limiting these operations to a single host should prevent race conditions. # # @param version # Specifies the version of Nextcloud that should be installed.