From 214b798a7d54cc1476c72f4b01f9e7c4f96ac24e Mon Sep 17 00:00:00 2001 From: Xavier Rakotomamonjy Date: Mon, 30 Jan 2023 14:14:11 +0100 Subject: [PATCH] feat: add variable to configure Argo CD auto sync (#27) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(main): introduce a variable to set autosync * feat(main): add variable for target_revision in argocd app * fix(main): set optional attribut in app_autosync * fix(aks-eks): propagate target_revision * fix: rename var resource group name and document its purpose * ci: add central workflows including release-please (#17) * chore: add CODEOWNERS file * ci: add linters and terraform-docs workflows * ci: add release-please workflow and associated modifications * test: test corrected workflow * docs(terraform-docs): generate docs and write to README.adoc * revert: "test: test corrected workflow" This reverts commit 609d8c45b71805a02185260e76d4b25c6b03e776. Co-authored-by: lentidas Release-As: v1.0.0-alpha.1 * chore(main): release 1.0.0-alpha.1 (#20) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(aks): add azure main * chore(aks): add version file * fix(aks): eof * fix: do not expose values as secret * fix: wait for app, else provider says app is not existent on destroy * chore(azure)!: delete useless resource group variable and clean up * docs(terraform-docs): generate docs and write to README.adoc * refactor: delete leftover from legacy code (#25) * docs(terraform-docs): generate docs and write to README.adoc * fix(main): remove duplicated target_revision attribut * docs(terraform-docs): generate docs and write to README.adoc * Update variable autosync description Co-authored-by: Gonçalo Heleno <33546359+lentidas@users.noreply.github.com> * docs(terraform-docs): generate docs and write to README.adoc * feat: add kind variant and improve activation of thanos on all the variants (#21) * feat(eks): use proper variable to receive metrics storage config * feat: generate bucket config in variant then pass to main mod * feat: add kind variant * docs(terraform-docs): generate docs and write to README.adoc * refactor: refactor conditions * fix: add sensitive flag to sensitive variables * refactor: rename local.tf to locals.tf * revert: "fix: add sensitive flag to sensitive variables" This reverts commit f816f1f865a08f772ad4105c2c88517e591e60e9. * docs: fix typo * fix: fix the error on deployment because the count depended on value * docs(terraform-docs): generate docs and write to README.adoc * fix: remove enabled flag in the kind variant * fix: remove sensitive flag from bucket variables because it breaks conditions * feat: further enhance Thanos activation across all variants Co-authored-by: Mohamed Amine Dridi * chore: merge main to branch * fix(aks): correct merge errors * refactor: rename kube secret object in terraform * feat: add symbolic links for the versions.tf * fix: add forgotten required provider * docs(terraform-docs): generate docs and write to README.adoc * chore: terraform fmt Co-authored-by: lentidas Co-authored-by: Mohamed Amine Dridi Release-As: v1.0.0-alpha.2 * chore(main): release 1.0.0-alpha.2 (#28) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat(Azure): add missing ID output (#30) * feat(Azure): add missing ID output * docs(terraform-docs): generate docs and write to README.adoc Co-authored-by: modridi Release-As: v1.0.0-alpha.3 * chore(main): release 1.0.0-alpha.3 (#31) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat: add variable passthrough for variants and dependency on var.app_autosync * docs(terraform-docs): generate docs and write to README.adoc * fix: add tobool function --------- Co-authored-by: Xavier Rakotomamonjy Co-authored-by: Federico Sismondi Co-authored-by: Gonçalo Heleno <33546359+lentidas@users.noreply.github.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Jérémy Barascut Co-authored-by: modridi Co-authored-by: modridi Co-authored-by: Xaving Co-authored-by: lentidas Co-authored-by: Mohamed Amine Dridi <78367821+modridi@users.noreply.github.com> Co-authored-by: Gonçalo Heleno Release-As: v1.0.0-alpha.4 --- README.adoc | 54 +++++++++++++++++++++++++++++++++++++++++++++++-- aks/README.adoc | 54 +++++++++++++++++++++++++++++++++++++++++++++++-- aks/main.tf | 4 +++- eks/README.adoc | 54 +++++++++++++++++++++++++++++++++++++++++++++++-- eks/main.tf | 4 +++- kind/main.tf | 4 +++- main.tf | 8 ++------ variables.tf | 14 +++++++++++++ 8 files changed, 181 insertions(+), 15 deletions(-) diff --git a/README.adoc b/README.adoc index ffbf54d4..4c30f640 100644 --- a/README.adoc +++ b/README.adoc @@ -68,6 +68,30 @@ Type: `any` Default: `{}` +==== [[input_app_autosync]] <> + +Description: Automated sync options for the Argo CD Application resource. + +Type: +[source,hcl] +---- +object({ + allow_empty = optional(bool) + prune = optional(bool) + self_heal = optional(bool) + }) +---- + +Default: +[source,json] +---- +{ + "allow_empty": false, + "prune": true, + "self_heal": true +} +---- + ==== [[input_cluster_issuer]] <> Description: n/a @@ -130,7 +154,7 @@ Description: Override of target revision of the application chart. Type: `string` -Default: `"v1.0.0-alpha.2"` +Default: `"v1.0.0-alpha.3"` === Outputs @@ -201,6 +225,32 @@ Description: n/a |`{}` |no +|[[input_app_autosync]] <> +|Automated sync options for the Argo CD Application resource. +| + +[source] +---- +object({ + allow_empty = optional(bool) + prune = optional(bool) + self_heal = optional(bool) + }) +---- + +| + +[source] +---- +{ + "allow_empty": false, + "prune": true, + "self_heal": true +} +---- + +|no + |[[input_argocd_namespace]] <> |n/a |`string` @@ -264,7 +314,7 @@ Description: n/a |[[input_target_revision]] <> |Override of target revision of the application chart. |`string` -|`"v1.0.0-alpha.2"` +|`"v1.0.0-alpha.3"` |no |=== diff --git a/aks/README.adoc b/aks/README.adoc index 647949e7..a156f453 100644 --- a/aks/README.adoc +++ b/aks/README.adoc @@ -66,6 +66,30 @@ Type: `any` Default: `{}` +==== [[input_app_autosync]] <> + +Description: Automated sync options for the Argo CD Application resource. + +Type: +[source,hcl] +---- +object({ + allow_empty = optional(bool) + prune = optional(bool) + self_heal = optional(bool) + }) +---- + +Default: +[source,json] +---- +{ + "allow_empty": false, + "prune": true, + "self_heal": true +} +---- + ==== [[input_cluster_issuer]] <> Description: n/a @@ -144,7 +168,7 @@ Description: Override of target revision of the application chart. Type: `string` -Default: `"v1.0.0-alpha.2"` +Default: `"v1.0.0-alpha.3"` === Outputs @@ -193,6 +217,32 @@ Description: n/a |`{}` |no +|[[input_app_autosync]] <> +|Automated sync options for the Argo CD Application resource. +| + +[source] +---- +object({ + allow_empty = optional(bool) + prune = optional(bool) + self_heal = optional(bool) + }) +---- + +| + +[source] +---- +{ + "allow_empty": false, + "prune": true, + "self_heal": true +} +---- + +|no + |[[input_argocd_namespace]] <> |n/a |`string` @@ -278,7 +328,7 @@ object({ |[[input_target_revision]] <> |Override of target revision of the application chart. |`string` -|`"v1.0.0-alpha.2"` +|`"v1.0.0-alpha.3"` |no |=== diff --git a/aks/main.tf b/aks/main.tf index cce24d00..d4f5d909 100644 --- a/aks/main.tf +++ b/aks/main.tf @@ -12,10 +12,12 @@ module "kube-prometheus-stack" { source = "../" cluster_name = var.cluster_name - argocd_namespace = var.argocd_namespace base_domain = var.base_domain + argocd_namespace = var.argocd_namespace + target_revision = var.target_revision cluster_issuer = var.cluster_issuer namespace = var.namespace + app_autosync = var.app_autosync dependency_ids = var.dependency_ids prometheus = var.prometheus diff --git a/eks/README.adoc b/eks/README.adoc index 8e151592..da7cd341 100644 --- a/eks/README.adoc +++ b/eks/README.adoc @@ -55,6 +55,30 @@ Type: `any` Default: `{}` +==== [[input_app_autosync]] <> + +Description: Automated sync options for the Argo CD Application resource. + +Type: +[source,hcl] +---- +object({ + allow_empty = optional(bool) + prune = optional(bool) + self_heal = optional(bool) + }) +---- + +Default: +[source,json] +---- +{ + "allow_empty": false, + "prune": true, + "self_heal": true +} +---- + ==== [[input_cluster_issuer]] <> Description: n/a @@ -133,7 +157,7 @@ Description: Override of target revision of the application chart. Type: `string` -Default: `"v1.0.0-alpha.2"` +Default: `"v1.0.0-alpha.3"` === Outputs @@ -181,6 +205,32 @@ Description: n/a |`{}` |no +|[[input_app_autosync]] <> +|Automated sync options for the Argo CD Application resource. +| + +[source] +---- +object({ + allow_empty = optional(bool) + prune = optional(bool) + self_heal = optional(bool) + }) +---- + +| + +[source] +---- +{ + "allow_empty": false, + "prune": true, + "self_heal": true +} +---- + +|no + |[[input_argocd_namespace]] <> |n/a |`string` @@ -260,7 +310,7 @@ object({ |[[input_target_revision]] <> |Override of target revision of the application chart. |`string` -|`"v1.0.0-alpha.2"` +|`"v1.0.0-alpha.3"` |no |=== diff --git a/eks/main.tf b/eks/main.tf index 0d803669..d5d9a8a8 100644 --- a/eks/main.tf +++ b/eks/main.tf @@ -2,10 +2,12 @@ module "kube-prometheus-stack" { source = "../" cluster_name = var.cluster_name - argocd_namespace = var.argocd_namespace base_domain = var.base_domain + argocd_namespace = var.argocd_namespace + target_revision = var.target_revision cluster_issuer = var.cluster_issuer namespace = var.namespace + app_autosync = var.app_autosync dependency_ids = var.dependency_ids prometheus = var.prometheus diff --git a/kind/main.tf b/kind/main.tf index 39ecda12..535a7340 100644 --- a/kind/main.tf +++ b/kind/main.tf @@ -2,10 +2,12 @@ module "kube-prometheus-stack" { source = "../" cluster_name = var.cluster_name - argocd_namespace = var.argocd_namespace base_domain = var.base_domain + argocd_namespace = var.argocd_namespace + target_revision = var.target_revision cluster_issuer = var.cluster_issuer namespace = var.namespace + app_autosync = var.app_autosync dependency_ids = var.dependency_ids prometheus = var.prometheus diff --git a/main.tf b/main.tf index 9b1fbb67..1a41158b 100644 --- a/main.tf +++ b/main.tf @@ -79,7 +79,7 @@ resource "argocd_application" "this" { delete = "15m" } - wait = true + wait = var.app_autosync == { "allow_empty" = tobool(null), "prune" = tobool(null), "self_heal" = tobool(null) } ? false : true spec { project = argocd_project.this.metadata.0.name @@ -103,11 +103,7 @@ resource "argocd_application" "this" { } sync_policy { - automated = { - allow_empty = false - prune = true - self_heal = true - } + automated = var.app_autosync retry { backoff = { diff --git a/variables.tf b/variables.tf index db642a7a..cd9c44f9 100644 --- a/variables.tf +++ b/variables.tf @@ -36,6 +36,20 @@ variable "helm_values" { default = [] } +variable "app_autosync" { + description = "Automated sync options for the Argo CD Application resource." + type = object({ + allow_empty = optional(bool) + prune = optional(bool) + self_heal = optional(bool) + }) + default = { + allow_empty = false + prune = true + self_heal = true + } +} + variable "dependency_ids" { type = map(string) default = {}