From 292c0aca5caf8c772882668445665ae6b03c5956 Mon Sep 17 00:00:00 2001 From: Ben Vincent Date: Sun, 28 Jun 2026 23:45:04 +1000 Subject: [PATCH] fix: align config with imported state for zero-drift plan Reorder quality_groups to match provider state (highest quality first), use correct group structure (omit id/name for single-quality entries), add lifecycle ignore_changes for sensitive fields (api_key, password), support explicit name override via YAML for display name mismatches, and add min_upgrade_format_score attribute. --- config/indexer/NZBgeek_Prowlarr.yaml | 1 + config/notification/Jellyfin.yaml | 1 + config/quality_profile/BestQuality_1080p.yaml | 66 +++++------ config/quality_profile/BestQuality_2160p.yaml | 111 ++++++++---------- config/quality_profile/SD_OLD_SHOWS.yaml | 18 ++- modules/sonarr/main.tf | 27 +++-- 6 files changed, 111 insertions(+), 113 deletions(-) diff --git a/config/indexer/NZBgeek_Prowlarr.yaml b/config/indexer/NZBgeek_Prowlarr.yaml index 07ad87d..0d8c5ed 100644 --- a/config/indexer/NZBgeek_Prowlarr.yaml +++ b/config/indexer/NZBgeek_Prowlarr.yaml @@ -1,3 +1,4 @@ +name: "NZBgeek (Prowlarr)" enable_automatic_search: true enable_interactive_search: true enable_rss: true diff --git a/config/notification/Jellyfin.yaml b/config/notification/Jellyfin.yaml index 073a801..491c727 100644 --- a/config/notification/Jellyfin.yaml +++ b/config/notification/Jellyfin.yaml @@ -1,3 +1,4 @@ +name: "Emby / Jellyfin" host: jellyfin.service.consul port: 443 use_ssl: true diff --git a/config/quality_profile/BestQuality_1080p.yaml b/config/quality_profile/BestQuality_1080p.yaml index 57e1360..d6b3ef0 100644 --- a/config/quality_profile/BestQuality_1080p.yaml +++ b/config/quality_profile/BestQuality_1080p.yaml @@ -3,54 +3,48 @@ cutoff: 7 cutoff_format_score: 5000 min_format_score: 0 quality_groups: - - id: 4 - qualities: - - id: 4 - name: HDTV-720p - source: television - resolution: 720 - - id: 9 - qualities: - - id: 9 - name: HDTV-1080p - source: television - resolution: 1080 - - id: 14 - qualities: - - id: 14 - name: WEBRip-720p - source: webRip - resolution: 720 - - id: 5 - qualities: - - id: 5 - name: WEBDL-720p - source: web - resolution: 720 - - id: 6 - qualities: - - id: 6 - name: Bluray-720p + - qualities: + - id: 7 + name: Bluray-1080p source: bluray - resolution: 720 - - id: 15 + resolution: 1080 + - id: 1002 + name: "WEB 1080p" qualities: - id: 15 name: WEBRip-1080p source: webRip resolution: 1080 - - id: 3 - qualities: - id: 3 name: WEBDL-1080p source: web resolution: 1080 - - id: 7 - qualities: - - id: 7 - name: Bluray-1080p + - qualities: + - id: 6 + name: Bluray-720p source: bluray + resolution: 720 + - id: 1001 + name: "WEB 720p" + qualities: + - id: 14 + name: WEBRip-720p + source: webRip + resolution: 720 + - id: 5 + name: WEBDL-720p + source: web + resolution: 720 + - qualities: + - id: 9 + name: HDTV-1080p + source: television resolution: 1080 + - qualities: + - id: 4 + name: HDTV-720p + source: television + resolution: 720 format_items: - name: release_AsmoFuscated format: release_AsmoFuscated diff --git a/config/quality_profile/BestQuality_2160p.yaml b/config/quality_profile/BestQuality_2160p.yaml index e49cf94..f377ab7 100644 --- a/config/quality_profile/BestQuality_2160p.yaml +++ b/config/quality_profile/BestQuality_2160p.yaml @@ -3,78 +3,69 @@ cutoff: 19 cutoff_format_score: 5000 min_format_score: 0 quality_groups: - - id: 4 - qualities: - - id: 4 - name: HDTV-720p - source: television - resolution: 720 - - id: 9 - qualities: - - id: 9 - name: HDTV-1080p - source: television - resolution: 1080 - - id: 14 - qualities: - - id: 14 - name: WEBRip-720p - source: webRip - resolution: 720 - - id: 5 - qualities: - - id: 5 - name: WEBDL-720p - source: web - resolution: 720 - - id: 6 - qualities: - - id: 6 - name: Bluray-720p + - qualities: + - id: 19 + name: Bluray-2160p source: bluray - resolution: 720 - - id: 15 - qualities: - - id: 15 - name: WEBRip-1080p - source: webRip - resolution: 1080 - - id: 3 - qualities: - - id: 3 - name: WEBDL-1080p - source: web - resolution: 1080 - - id: 7 - qualities: - - id: 7 - name: Bluray-1080p - source: bluray - resolution: 1080 - - id: 16 - qualities: - - id: 16 - name: HDTV-2160p - source: television resolution: 2160 - - id: 17 + - id: 1003 + name: "WEB 2160p" qualities: - id: 17 name: WEBRip-2160p source: webRip resolution: 2160 - - id: 18 - qualities: - id: 18 name: WEBDL-2160p source: web resolution: 2160 - - id: 19 - qualities: - - id: 19 - name: Bluray-2160p - source: bluray + - qualities: + - id: 16 + name: HDTV-2160p + source: television resolution: 2160 + - qualities: + - id: 7 + name: Bluray-1080p + source: bluray + resolution: 1080 + - id: 1002 + name: "WEB 1080p" + qualities: + - id: 15 + name: WEBRip-1080p + source: webRip + resolution: 1080 + - id: 3 + name: WEBDL-1080p + source: web + resolution: 1080 + - qualities: + - id: 6 + name: Bluray-720p + source: bluray + resolution: 720 + - id: 1001 + name: "WEB 720p" + qualities: + - id: 14 + name: WEBRip-720p + source: webRip + resolution: 720 + - id: 5 + name: WEBDL-720p + source: web + resolution: 720 + - qualities: + - id: 9 + name: HDTV-1080p + source: television + resolution: 1080 + - qualities: + - id: 4 + name: HDTV-720p + source: television + resolution: 720 format_items: - name: hdr10 format: hdr10 diff --git a/config/quality_profile/SD_OLD_SHOWS.yaml b/config/quality_profile/SD_OLD_SHOWS.yaml index ffdfdbc..f663913 100644 --- a/config/quality_profile/SD_OLD_SHOWS.yaml +++ b/config/quality_profile/SD_OLD_SHOWS.yaml @@ -3,11 +3,10 @@ cutoff: 1 cutoff_format_score: 0 min_format_score: 0 quality_groups: - - id: 1 - qualities: - - id: 1 - name: SDTV - source: television + - qualities: + - id: 2 + name: DVD + source: dvd resolution: 480 - id: 1000 name: "WEB 480p" @@ -20,10 +19,9 @@ quality_groups: name: WEBDL-480p source: web resolution: 480 - - id: 2 - qualities: - - id: 2 - name: DVD - source: dvd + - qualities: + - id: 1 + name: SDTV + source: television resolution: 480 format_items: [] diff --git a/modules/sonarr/main.tf b/modules/sonarr/main.tf index 6e61c55..46b83ab 100644 --- a/modules/sonarr/main.tf +++ b/modules/sonarr/main.tf @@ -19,9 +19,10 @@ resource "sonarr_quality_profile" "this" { name = each.key upgrade_allowed = lookup(each.value, "upgrade_allowed", false) cutoff = each.value.cutoff - cutoff_format_score = lookup(each.value, "cutoff_format_score", 0) - min_format_score = lookup(each.value, "min_format_score", 0) - quality_groups = each.value.quality_groups + cutoff_format_score = lookup(each.value, "cutoff_format_score", 0) + min_format_score = lookup(each.value, "min_format_score", 0) + min_upgrade_format_score = lookup(each.value, "min_upgrade_format_score", 0) + quality_groups = each.value.quality_groups format_items = [ for fi in lookup(each.value, "format_items", []) : { @@ -34,7 +35,7 @@ resource "sonarr_quality_profile" "this" { resource "sonarr_download_client_nzbget" "this" { for_each = var.download_clients - name = each.key + name = lookup(each.value, "name", each.key) enable = lookup(each.value, "enable", true) priority = lookup(each.value, "priority", 1) host = each.value.host @@ -45,11 +46,15 @@ resource "sonarr_download_client_nzbget" "this" { tv_category = lookup(each.value, "tv_category", "") remove_completed_downloads = lookup(each.value, "remove_completed_downloads", true) remove_failed_downloads = lookup(each.value, "remove_failed_downloads", true) + + lifecycle { + ignore_changes = [password] + } } resource "sonarr_indexer_newznab" "this" { for_each = var.indexers - name = each.key + name = lookup(each.value, "name", each.key) enable_automatic_search = lookup(each.value, "enable_automatic_search", true) enable_interactive_search = lookup(each.value, "enable_interactive_search", true) enable_rss = lookup(each.value, "enable_rss", true) @@ -59,15 +64,19 @@ resource "sonarr_indexer_newznab" "this" { api_key = lookup(each.value, "api_key", "") categories = lookup(each.value, "categories", []) anime_categories = lookup(each.value, "anime_categories", []) + + lifecycle { + ignore_changes = [api_key] + } } resource "sonarr_notification_emby" "this" { for_each = var.notifications - name = each.key + name = lookup(each.value, "name", each.key) host = each.value.host port = each.value.port use_ssl = lookup(each.value, "use_ssl", false) - api_key = each.value.api_key + api_key = lookup(each.value, "api_key", "") notify = lookup(each.value, "notify", false) update_library = lookup(each.value, "update_library", true) @@ -80,6 +89,10 @@ resource "sonarr_notification_emby" "this" { on_episode_file_delete = lookup(each.value, "on_episode_file_delete", true) on_episode_file_delete_for_upgrade = lookup(each.value, "on_episode_file_delete_for_upgrade", true) on_application_update = lookup(each.value, "on_application_update", true) + + lifecycle { + ignore_changes = [api_key] + } } resource "sonarr_delay_profile" "this" {