From 53407489a8eab3d190c41e60e10ea766419497af Mon Sep 17 00:00:00 2001 From: unkin-agent Date: Sun, 18 Oct 2026 03:46:34 +1100 Subject: [PATCH] Add ansible remote, local and virtual --- config/config.hcl | 10 +++++++++ config/local_ansible/ansible-internal.yaml | 1 + config/remote_ansible/galaxy.yaml | 5 +++++ config/virtual/ansible.yaml | 5 +++++ .../terragrunt.hcl | 2 ++ modules/artifactapi/main.tf | 20 +++++++++++++++++ modules/artifactapi/variables.tf | 22 +++++++++++++++++++ 7 files changed, 65 insertions(+) create mode 100644 config/local_ansible/ansible-internal.yaml create mode 100644 config/remote_ansible/galaxy.yaml create mode 100644 config/virtual/ansible.yaml diff --git a/config/config.hcl b/config/config.hcl index 18f150d..6f12d24 100644 --- a/config/config.hcl +++ b/config/config.hcl @@ -12,6 +12,11 @@ locals { trimsuffix(basename(file_path), ".yaml") => content if startswith(file_path, "remote_alpine/") } + remote_ansible = { + for file_path, content in local.all_configs : + trimsuffix(basename(file_path), ".yaml") => content + if startswith(file_path, "remote_ansible/") + } remote_cargo = { for file_path, content in local.all_configs : trimsuffix(basename(file_path), ".yaml") => content @@ -92,6 +97,11 @@ locals { trimsuffix(basename(file_path), ".yaml") => content if startswith(file_path, "local_npm/") } + local_ansible = { + for file_path, content in local.all_configs : + trimsuffix(basename(file_path), ".yaml") => content + if startswith(file_path, "local_ansible/") + } local_gems = { for file_path, content in local.all_configs : trimsuffix(basename(file_path), ".yaml") => content diff --git a/config/local_ansible/ansible-internal.yaml b/config/local_ansible/ansible-internal.yaml new file mode 100644 index 0000000..9dfb4cb --- /dev/null +++ b/config/local_ansible/ansible-internal.yaml @@ -0,0 +1 @@ +description: "Internal Ansible collections" diff --git a/config/remote_ansible/galaxy.yaml b/config/remote_ansible/galaxy.yaml new file mode 100644 index 0000000..b3e6137 --- /dev/null +++ b/config/remote_ansible/galaxy.yaml @@ -0,0 +1,5 @@ +base_url: https://galaxy.ansible.com +description: "galaxy.ansible.com — public Ansible Galaxy collections" +immutable_ttl: 0 +mutable_ttl: 300 +stale_on_error: true diff --git a/config/virtual/ansible.yaml b/config/virtual/ansible.yaml new file mode 100644 index 0000000..f210562 --- /dev/null +++ b/config/virtual/ansible.yaml @@ -0,0 +1,5 @@ +package_type: ansible +description: "Virtual Ansible Galaxy over internal and public collections — member order is priority order for duplicate versions" +members: + - ansible-internal + - galaxy diff --git a/environments/artifactapi.k8s.syd1.au.unkin.net/terragrunt.hcl b/environments/artifactapi.k8s.syd1.au.unkin.net/terragrunt.hcl index b273433..a15f837 100644 --- a/environments/artifactapi.k8s.syd1.au.unkin.net/terragrunt.hcl +++ b/environments/artifactapi.k8s.syd1.au.unkin.net/terragrunt.hcl @@ -18,6 +18,7 @@ terraform { inputs = { remote_alpine = local.config.remote_alpine + remote_ansible = local.config.remote_ansible remote_cargo = local.config.remote_cargo remote_docker = local.config.remote_docker remote_generic = local.config.remote_generic @@ -35,6 +36,7 @@ inputs = { local_helm = local.config.local_helm local_npm = local.config.local_npm local_gems = local.config.local_gems + local_ansible = local.config.local_ansible local_docker = local.config.local_docker local_generic = local.config.local_generic virtual = local.config.virtual diff --git a/modules/artifactapi/main.tf b/modules/artifactapi/main.tf index 7f195e4..cf9c2d2 100644 --- a/modules/artifactapi/main.tf +++ b/modules/artifactapi/main.tf @@ -135,6 +135,19 @@ resource "artifactapi_remote_npm" "this" { stale_on_error = each.value.stale_on_error } +resource "artifactapi_remote_ansible" "this" { + for_each = var.remote_ansible + + name = each.key + base_url = each.value.base_url + description = each.value.description + immutable_ttl = each.value.immutable_ttl + mutable_ttl = each.value.mutable_ttl + patterns = each.value.patterns + mutable_patterns = each.value.mutable_patterns + stale_on_error = each.value.stale_on_error +} + resource "artifactapi_remote_gems" "this" { for_each = var.remote_gems @@ -203,6 +216,13 @@ resource "artifactapi_local_gems" "this" { description = each.value.description } +resource "artifactapi_local_ansible" "this" { + for_each = var.local_ansible + + name = each.key + description = each.value.description +} + resource "artifactapi_local_docker" "this" { for_each = var.local_docker diff --git a/modules/artifactapi/variables.tf b/modules/artifactapi/variables.tf index d26acf1..5074eac 100644 --- a/modules/artifactapi/variables.tf +++ b/modules/artifactapi/variables.tf @@ -141,6 +141,20 @@ variable "remote_npm" { default = {} } +variable "remote_ansible" { + description = "Map of Ansible Galaxy remote repositories" + type = map(object({ + base_url = string + description = optional(string, "") + immutable_ttl = optional(number, 0) + mutable_ttl = optional(number, 3600) + patterns = optional(list(string), []) + mutable_patterns = optional(list(string), []) + stale_on_error = optional(bool, true) + })) + default = {} +} + variable "remote_gems" { description = "Map of RubyGems remote repositories" type = map(object({ @@ -209,6 +223,14 @@ variable "local_gems" { default = {} } +variable "local_ansible" { + description = "Map of local Ansible Galaxy repositories" + type = map(object({ + description = optional(string, "") + })) + default = {} +} + variable "local_generic" { description = "Map of local generic (raw-file) repositories" type = map(object({