From e81d9f95a773301137d0395b9bc9b2ba55e9d8fe Mon Sep 17 00:00:00 2001 From: John McCall Date: Sun, 8 Dec 2024 10:56:20 -0500 Subject: [PATCH] fix: dont error with enable on create (#288) * fix: dont error with enable on create * Create 288-fix-agent-schedule.yml * chore: release info --- CHANGELOG.rst | 13 +++++++++++++ changelogs/changelog.yaml | 8 ++++++++ galaxy.yml | 2 +- plugins/modules/agent_job_schedule.ps1 | 6 +++--- .../targets/agent_job_schedule/tasks/main.yml | 1 + 5 files changed, 26 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 815c783c..23bc1fda 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,19 @@ lowlydba.sqlserver Release Notes .. contents:: Topics +v2.3.6 +====== + +Release Summary +--------------- + +Bugfix for creating agent job schedules as explicitly enabled. + +Bugfixes +-------- + +- Fix error when creating an agent job schedule with `enabled` as true. (https://github.com/lowlydba/lowlydba.sqlserver/pull/288) + v2.3.5 ====== diff --git a/changelogs/changelog.yaml b/changelogs/changelog.yaml index a876885b..9e945bfa 100644 --- a/changelogs/changelog.yaml +++ b/changelogs/changelog.yaml @@ -523,3 +523,11 @@ releases: fragments: - 287-login-bugfix.yml release_date: '2024-12-08' + 2.3.6: + changes: + bugfixes: + - Fix error when creating an agent job schedule with `enabled` as true. (https://github.com/lowlydba/lowlydba.sqlserver/pull/288) + release_summary: Bugfix for creating agent job schedules as explicitly enabled. + fragments: + - 288-fix-agent-schedule.yml + release_date: '2024-12-08' diff --git a/galaxy.yml b/galaxy.yml index a36d18d2..84b1eb80 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -2,7 +2,7 @@ namespace: lowlydba name: sqlserver -version: 2.3.4 +version: 2.3.6 readme: README.md authors: - John McCall (github.com/lowlydba) diff --git a/plugins/modules/agent_job_schedule.ps1 b/plugins/modules/agent_job_schedule.ps1 index 62b22591..1df3592a 100644 --- a/plugins/modules/agent_job_schedule.ps1 +++ b/plugins/modules/agent_job_schedule.ps1 @@ -101,11 +101,11 @@ if ($null -ne $frequencyRecurrenceFactor) { try { $existingSchedule = Get-DbaAgentSchedule -SqlInstance $SqlInstance -SqlCredential $sqlCredential -Schedule $schedule if ($state -eq "present") { - if ($enabled -eq $true) { - $scheduleParams.Add("Enabled", $true) - } # Update schedule if ($null -ne $existingSchedule) { + if ($enabled -eq $true) { + $scheduleParams.Add("Enabled", $true) + } # Need to serialize to prevent SMO auto refreshing $old = ConvertTo-SerializableObject -InputObject $existingSchedule -UseDefaultProperty $false $output = Set-DbaAgentSchedule @scheduleParams diff --git a/tests/integration/targets/agent_job_schedule/tasks/main.yml b/tests/integration/targets/agent_job_schedule/tasks/main.yml index 8f0e367a..c18666fb 100644 --- a/tests/integration/targets/agent_job_schedule/tasks/main.yml +++ b/tests/integration/targets/agent_job_schedule/tasks/main.yml @@ -49,6 +49,7 @@ lowlydba.sqlserver.agent_job_schedule: schedule: "{{ forced_schedule_name }}" force: true + enabled: true state: present register: result - assert: