Skip to content

Commit

Permalink
fix $install_enabled=false, closes #11
Browse files Browse the repository at this point in the history
  • Loading branch information
fraenki committed Jul 31, 2023
1 parent 1446143 commit adaae52
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 11 deletions.
22 changes: 11 additions & 11 deletions manifests/update.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
class nextcloud::update {
assert_private()

# Only perform update tasks if this feature is enabled.
if ($nextcloud::update_enabled =~ Boolean) {
# Commands and files required when performing an update.
$update_lock = "${nextcloud::datadir}/.puppet_update.lock"
$update_done = "${nextcloud::datadir}/.puppet_update_${nextcloud::version_normalized}.done"
$update_cmd = join([
"touch ${update_lock}",
'&& php occ upgrade --no-interaction',
"&& touch ${update_done}",
"; rm -f ${update_lock}", # always remove lock
], ' ')
# Commands and files required when performing an update.
$update_lock = "${nextcloud::datadir}/.puppet_update.lock"
$update_done = "${nextcloud::datadir}/.puppet_update_${nextcloud::version_normalized}.done"
$update_cmd = join([
"touch ${update_lock}",
'&& php occ upgrade --no-interaction',
"&& touch ${update_done}",
"; rm -f ${update_lock}", # always remove lock
], ' ')

# Only perform update tasks if this feature is enabled.
if ($nextcloud::install_enabled and $nextcloud::update_enabled =~ Boolean) {
# 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'])) {
Expand Down
39 changes: 39 additions & 0 deletions spec/classes/nextcloud_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

it { is_expected.to contain_file('/opt/nextcloud-data').with_ensure('directory') }
it { is_expected.to contain_file('Create install dir: initial install').with_ensure('directory') }
it { is_expected.to contain_archive('Extract archive: initial install') }

it {
is_expected.to contain_cron('Nextcloud background job').with(
Expand All @@ -51,6 +52,44 @@

it { is_expected.not_to contain_nextcloud__install__distribution('initial install') }
it { is_expected.not_to contain_file('Create install dir: initial install').with_ensure('directory') }
it { is_expected.not_to contain_archive('Extract archive: update to 20.0.4') }
end
context 'when install_enabled=false' do
let(:params) do
{
admin_password: 'secret',
db_password: 'secret',
install_enabled: false,
version: '20.0.4',
}
end

it { is_expected.to compile }

it { is_expected.not_to contain_nextcloud__install__distribution('initial install') }
it { is_expected.not_to contain_file('Create install dir: initial install').with_ensure('directory') }

it { is_expected.not_to contain_nextcloud__install__distribution('update to 20.0.4') }
it { is_expected.not_to contain_archive('Extract archive: update to 20.0.4') }
it { is_expected.not_to contain_exec('occ upgrade') }
end
context 'when update_enabled=false' do
let(:params) do
{
admin_password: 'secret',
db_password: 'secret',
update_enabled: false,
version: '20.0.4',
}
end

it { is_expected.to compile }

it { is_expected.to contain_nextcloud__install__distribution('initial install') }
it { is_expected.to contain_file('Create install dir: initial install').with_ensure('directory') }
it { is_expected.to contain_nextcloud__install__distribution('update to 20.0.4') }

it { is_expected.not_to contain_exec('occ upgrade') }
end
end
end
Expand Down

0 comments on commit adaae52

Please sign in to comment.