diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bf84ec..66daa05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,8 +6,16 @@ and this module adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0. ## [Unreleased] +## [2.0.3] - 2024-05-10 + +### Fixed + +- Fixed issue that all schedules were created with a start date after the planned date + ## [2.0.2] - 2024-02-19 +### Fixed + - Fixed wrong variable name in azure query creation - fixed typo in regex - added errorCounter to actualle let the runbook status be "failed" if error occur diff --git a/README.md b/README.md index fb1ffb0..d35ace7 100644 --- a/README.md +++ b/README.md @@ -82,31 +82,32 @@ module "update_management" { No outputs. -## Resource types + ## Resource types -| Type | Used | -|------|-------| -| [azurerm_automation_job_schedule](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/automation_job_schedule) | 1 | -| [azurerm_automation_runbook](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/automation_runbook) | 1 | -| [azurerm_automation_schedule](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/automation_schedule) | 1 | -| [time_static](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/static) | 1 | - -**`Used` only includes resource blocks.** `for_each` and `count` meta arguments, as well as resource blocks of modules are not considered. + | Type | Used | + |------|-------| + | [azurerm_automation_job_schedule](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/automation_job_schedule) | 1 | + | [azurerm_automation_runbook](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/automation_runbook) | 1 | + | [azurerm_automation_schedule](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/automation_schedule) | 1 | + | [time_static](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/static) | 1 | + **`Used` only includes resource blocks.** `for_each` and `count` meta arguments, as well as resource blocks of modules are not considered. + ## Modules No modules. -## Resources by Files + ## Resources by Files -### main.tf + ### main.tf -| Name | Type | -|------|------| -| [azurerm_automation_job_schedule.set_deployment_schedules](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/automation_job_schedule) | resource | -| [azurerm_automation_runbook.set_deployment_schedules](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/automation_runbook) | resource | -| [azurerm_automation_schedule.every_12h_starting_7am](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/automation_schedule) | resource | -| [time_static.schedule_start_tomorrow_7am](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/static) | resource | + | Name | Type | + |------|------| + | [azurerm_automation_job_schedule.set_deployment_schedules](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/automation_job_schedule) | resource | + | [azurerm_automation_runbook.set_deployment_schedules](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/automation_runbook) | resource | + | [azurerm_automation_schedule.every_12h_starting_7am](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/automation_schedule) | resource | + | [time_static.schedule_start_tomorrow_7am](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/static) | resource | + # Contribute diff --git a/runbooks/Set-DeploymentSchedules.ps1 b/runbooks/Set-DeploymentSchedules.ps1 index 6bf858b..060866e 100644 --- a/runbooks/Set-DeploymentSchedules.ps1 +++ b/runbooks/Set-DeploymentSchedules.ps1 @@ -111,7 +111,15 @@ foreach ($severityGroup in $severityGroups) { $dayInterval = [int]$splitSeverityGroup[0] $weekdayRepetition = $splitSeverityGroup[1] $weekday = $splitSeverityGroup[2] - $startTime = (get-date ($splitSeverityGroup[3].Substring(0, 2) + ":" + $splitSeverityGroup[3].Substring(2, 2))).AddDays(1) + $plannedTime = get-date ($splitSeverityGroup[3].Substring(0, 2) + ":" + $splitSeverityGroup[3].Substring(2, 2)) + if ($plannedTime -lt (get-date).AddHours(2)) { + $startTime = $plannedTime.AddDays(1) + } + else { + $startTime = $plannedTime + } + + Write-Output "StartTime of $severityGroup is $startTime" $rebootSetting = $rebootOptions[$splitSeverityGroup[5]] $queryTags = @{ "Severity Group Monthly" = "$($severityGroup)" @@ -137,7 +145,7 @@ foreach ($severityGroup in $severityGroups) { } catch { Write-Error -Exception ($_.Exception) -Message "Could not create schedule for $severityGroup." -ErrorAction Continue - $errorCounter +=1 + $errorCounter += 1 continue } @@ -151,7 +159,7 @@ foreach ($severityGroup in $severityGroups) { } catch { Write-Error -Exception ($_.Exception) -Message "Could not create azure for $severityGroup." -ErrorAction Continue - $errorCounter +=1 + $errorCounter += 1 continue } @@ -169,7 +177,7 @@ foreach ($severityGroup in $severityGroups) { } catch { Write-Error -Exception ($_.Exception) -Message "Could not create Update configuration for $severityGroup" -ErrorAction Continue - $errorCounter +=1 + $errorCounter += 1 continue }