From f3bb78fdfff1eb7cfd67565d7aba7bfec2404734 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 1 Dec 2025 03:11:28 +0000 Subject: [PATCH 1/4] Initial plan From cb98561b712a07bbe592b377b5bbd4c5e03607e9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 1 Dec 2025 03:21:06 +0000 Subject: [PATCH 2/4] Add netbox_deploy Ansible role for deploying NetBox via Argo CD Co-authored-by: SRF-Audio <16975040+SRF-Audio@users.noreply.github.com> --- ansible/roles/netbox_deploy/defaults/main.yml | 29 ++++++ .../netbox_deploy/meta/argument_specs.yml | 87 ++++++++++++++++ ansible/roles/netbox_deploy/tasks/main.yml | 98 +++++++++++++++++++ .../templates/netbox-application.yml.j2 | 91 +++++++++++++++++ .../templates/netbox-homepage-ingress.yml.j2 | 24 +++++ 5 files changed, 329 insertions(+) create mode 100644 ansible/roles/netbox_deploy/defaults/main.yml create mode 100644 ansible/roles/netbox_deploy/meta/argument_specs.yml create mode 100644 ansible/roles/netbox_deploy/tasks/main.yml create mode 100644 ansible/roles/netbox_deploy/templates/netbox-application.yml.j2 create mode 100644 ansible/roles/netbox_deploy/templates/netbox-homepage-ingress.yml.j2 diff --git a/ansible/roles/netbox_deploy/defaults/main.yml b/ansible/roles/netbox_deploy/defaults/main.yml new file mode 100644 index 0000000..988ae62 --- /dev/null +++ b/ansible/roles/netbox_deploy/defaults/main.yml @@ -0,0 +1,29 @@ +netbox_deploy_kubeconfig: "{{ k3s_kubeconfig_path | default('', true) }}" +netbox_deploy_cluster_name: "{{ k3s_cluster_name | default('', true) }}" +netbox_deploy_context: "{{ k3s_context_name | default('', true) }}" + +netbox_deploy_namespace: netbox +netbox_deploy_argo_namespace: argocd +netbox_deploy_argo_project: coachlight-k3s-infra + +netbox_deploy_helm_repo_url: https://netbox-community.github.io/netbox-chart +netbox_deploy_helm_chart_name: netbox +netbox_deploy_helm_chart_version: 5.0.0-beta.145 + +netbox_deploy_values_overrides: {} + +netbox_deploy_hostname: netbox +netbox_deploy_ingress_enabled: true +netbox_deploy_tailscale_annotations: + tailscale.com/expose: "true" + tailscale.com/hostname: "netbox" + tailscale.com/tags: "tag:k8s,tag:infra-monitoring" + +netbox_deploy_storage_class_longhorn: longhorn +netbox_deploy_storage_class_synology: "" + +netbox_deploy_media_storage_config: {} + +netbox_deploy_apply_application: true + +netbox_deploy_superuser_email: admin@example.com diff --git a/ansible/roles/netbox_deploy/meta/argument_specs.yml b/ansible/roles/netbox_deploy/meta/argument_specs.yml new file mode 100644 index 0000000..40614bb --- /dev/null +++ b/ansible/roles/netbox_deploy/meta/argument_specs.yml @@ -0,0 +1,87 @@ +argument_specs: + main: + description: | + Deploy NetBox Argo CD Application into a Kubernetes cluster using the official + NetBox Helm chart, integrating with Tailscale for ingress, Longhorn/Synology for + storage, and exposing the application to Homepage for discovery. + options: + netbox_deploy_kubeconfig: + type: raw + required: true + description: Path to kubeconfig file or configuration dict. + netbox_deploy_context: + type: str + required: true + description: Kubernetes context name to use for deployment. + netbox_deploy_cluster_name: + type: str + required: false + description: Logical cluster name used for artifact recording. + netbox_deploy_namespace: + type: str + required: false + description: Namespace where NetBox will be deployed. + netbox_deploy_argo_namespace: + type: str + required: false + description: Namespace where Argo CD is deployed. + netbox_deploy_argo_project: + type: str + required: false + description: Argo CD project to associate the NetBox application with. + netbox_deploy_helm_repo_url: + type: str + required: false + description: URL of the NetBox Helm chart repository. + netbox_deploy_helm_chart_name: + type: str + required: false + description: Name of the NetBox Helm chart. + netbox_deploy_helm_chart_version: + type: str + required: false + description: Version of the NetBox Helm chart to deploy. + netbox_deploy_values_overrides: + type: dict + required: false + description: Dictionary of Helm values to override in the NetBox chart. + netbox_deploy_hostname: + type: str + required: false + description: Hostname for NetBox UI access via Tailscale. + netbox_deploy_ingress_enabled: + type: bool + required: false + description: Whether to enable ingress for NetBox UI. + netbox_deploy_tailscale_annotations: + type: dict + required: false + description: Annotations applied to NetBox service for Tailscale integration. + netbox_deploy_storage_class_longhorn: + type: str + required: false + description: Longhorn storage class name for database and Redis PVCs. + netbox_deploy_storage_class_synology: + type: str + required: false + description: Synology NFS storage class name for media storage. + netbox_deploy_media_storage_config: + type: dict + required: false + description: Configuration for NetBox media storage using Synology. + netbox_deploy_apply_application: + type: bool + required: false + description: Whether to apply the rendered Application manifest to the cluster. + netbox_deploy_superuser_email: + type: str + required: false + description: Email address for the NetBox superuser account. + netbox_deploy_superuser_password: + type: str + required: true + description: Password for the NetBox superuser account. + netbox_deploy_secret_key: + type: str + required: true + description: Django secret key for NetBox. diff --git a/ansible/roles/netbox_deploy/tasks/main.yml b/ansible/roles/netbox_deploy/tasks/main.yml new file mode 100644 index 0000000..ac369e9 --- /dev/null +++ b/ansible/roles/netbox_deploy/tasks/main.yml @@ -0,0 +1,98 @@ +--- +- name: Assert required NetBox deployment inputs are defined + ansible.builtin.assert: + that: + - netbox_deploy_kubeconfig is defined + - netbox_deploy_context is defined + - netbox_deploy_superuser_password is defined + - netbox_deploy_secret_key is defined + - netbox_deploy_kubeconfig | string | length > 0 + - netbox_deploy_context | length > 0 + - netbox_deploy_superuser_password | length > 0 + - netbox_deploy_secret_key | length > 0 + fail_msg: | + netbox_deploy_kubeconfig + netbox_deploy_context + netbox_deploy_superuser_password + netbox_deploy_secret_key + ...must be defined for netbox_deploy. + +- name: Set NetBox deployment paths + ansible.builtin.set_fact: + netbox_deploy_tmp_dir: "/tmp/netbox_deploy" + netbox_deploy_application_template: "{{ role_path }}/templates/netbox-application.yml.j2" + netbox_deploy_homepage_ingress_template: "{{ role_path }}/templates/netbox-homepage-ingress.yml.j2" + +- name: Ensure NetBox deployment tmp directory exists + ansible.builtin.file: + path: "{{ netbox_deploy_tmp_dir }}" + state: directory + mode: "0755" + +- name: Render NetBox Argo CD Application manifest + ansible.builtin.template: + src: "{{ netbox_deploy_application_template }}" + dest: "{{ netbox_deploy_tmp_dir }}/netbox-application.yml" + mode: "0644" + register: netbox_deploy_application_file + +- name: Render NetBox Homepage ingress manifest + ansible.builtin.template: + src: "{{ netbox_deploy_homepage_ingress_template }}" + dest: "{{ netbox_deploy_tmp_dir }}/netbox-homepage-ingress.yml" + mode: "0644" + register: netbox_deploy_homepage_ingress_file + +- name: Apply NetBox Argo CD Application manifest + ansible.builtin.include_role: + name: k8s_object_manager + vars: + k8s_object_manager_kubeconfig: "{{ netbox_deploy_kubeconfig }}" + k8s_object_manager_context: "{{ netbox_deploy_context }}" + k8s_object_manager_state: present + k8s_object_manager_src: "{{ netbox_deploy_application_file.dest }}" + k8s_object_manager_apply: true + when: netbox_deploy_apply_application | default(true) | bool + register: netbox_deploy_application_result + +- name: Capture NetBox Argo CD Application apply result + ansible.builtin.set_fact: + netbox_deploy_application_apply_result: "{{ k8s_object_manager_result }}" + when: netbox_deploy_application_result is succeeded + +- name: Apply NetBox Homepage ingress manifest + ansible.builtin.include_role: + name: k8s_object_manager + vars: + k8s_object_manager_kubeconfig: "{{ netbox_deploy_kubeconfig }}" + k8s_object_manager_context: "{{ netbox_deploy_context }}" + k8s_object_manager_state: present + k8s_object_manager_src: "{{ netbox_deploy_homepage_ingress_file.dest }}" + k8s_object_manager_apply: true + when: netbox_deploy_apply_application | default(true) | bool + register: netbox_deploy_homepage_ingress_result + +- name: Capture NetBox Homepage ingress apply result + ansible.builtin.set_fact: + netbox_deploy_homepage_ingress_apply_result: "{{ k8s_object_manager_result }}" + when: netbox_deploy_homepage_ingress_result is succeeded + +- name: Clean up NetBox deployment tmp directory + ansible.builtin.file: + path: "{{ netbox_deploy_tmp_dir }}" + state: absent + +- name: Persist netbox_deploy artifacts + ansible.builtin.include_role: + name: role_artifacts + vars: + # noqa: var-naming + calling_role_name: "netbox_deploy" + calling_role_artifacts_inputs: + k3s_cluster_name: "{{ netbox_deploy_cluster_name | default(k3s_cluster_name | default('', true), true) }}" + application_name: "netbox" + argocd_namespace: "{{ netbox_deploy_argo_namespace }}" + namespace: "{{ netbox_deploy_namespace }}" + helm_chart_version: "{{ netbox_deploy_helm_chart_version }}" + application_result: "{{ netbox_deploy_application_apply_result | default({}, true) }}" + homepage_ingress_result: "{{ netbox_deploy_homepage_ingress_apply_result | default({}, true) }}" diff --git a/ansible/roles/netbox_deploy/templates/netbox-application.yml.j2 b/ansible/roles/netbox_deploy/templates/netbox-application.yml.j2 new file mode 100644 index 0000000..98e1faf --- /dev/null +++ b/ansible/roles/netbox_deploy/templates/netbox-application.yml.j2 @@ -0,0 +1,91 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: netbox + namespace: {{ netbox_deploy_argo_namespace }} +spec: + project: {{ netbox_deploy_argo_project }} + source: + repoURL: {{ netbox_deploy_helm_repo_url }} + chart: {{ netbox_deploy_helm_chart_name }} + targetRevision: "{{ netbox_deploy_helm_chart_version }}" + helm: + valuesObject: + superuser: + email: "{{ netbox_deploy_superuser_email }}" + password: "{{ netbox_deploy_superuser_password }}" + + secretKey: "{{ netbox_deploy_secret_key }}" + + persistence: + enabled: true + storageClass: "{{ netbox_deploy_storage_class_longhorn }}" + + postgresql: + enabled: true + primary: + persistence: + enabled: true + storageClass: "{{ netbox_deploy_storage_class_longhorn }}" + + redis: + enabled: true + master: + persistence: + enabled: true + storageClass: "{{ netbox_deploy_storage_class_longhorn }}" + replica: + persistence: + enabled: true + storageClass: "{{ netbox_deploy_storage_class_longhorn }}" + + service: + annotations: +{% for key, value in netbox_deploy_tailscale_annotations.items() %} + {{ key }}: "{{ value }}" +{% endfor %} +{% if netbox_deploy_ingress_enabled %} + + ingress: + enabled: true + className: tailscale + hosts: + - host: {{ netbox_deploy_hostname }} + paths: + - path: / + pathType: Prefix +{% endif %} +{% if netbox_deploy_media_storage_config and netbox_deploy_storage_class_synology %} + + extraVolumes: + - name: netbox-media + persistentVolumeClaim: + claimName: netbox-media + + extraVolumeMounts: + - name: netbox-media + mountPath: /opt/netbox/netbox/media + + extraInitContainers: + - name: init-media-permissions + image: busybox:1.36 + command: + - sh + - "-c" + - "chown -R 1000:1000 /opt/netbox/netbox/media" + volumeMounts: + - name: netbox-media + mountPath: /opt/netbox/netbox/media +{% endif %} +{% if netbox_deploy_values_overrides %} + +{{ netbox_deploy_values_overrides | to_nice_yaml | indent(8, first=true) }}{% endif %} + destination: + server: https://kubernetes.default.svc + namespace: {{ netbox_deploy_namespace }} + syncPolicy: + automated: + prune: true + selfHeal: true + syncOptions: + - CreateNamespace=true diff --git a/ansible/roles/netbox_deploy/templates/netbox-homepage-ingress.yml.j2 b/ansible/roles/netbox_deploy/templates/netbox-homepage-ingress.yml.j2 new file mode 100644 index 0000000..64cac64 --- /dev/null +++ b/ansible/roles/netbox_deploy/templates/netbox-homepage-ingress.yml.j2 @@ -0,0 +1,24 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: netbox-homepage + namespace: {{ netbox_deploy_namespace }} + annotations: + gethomepage.dev/enabled: "true" + gethomepage.dev/name: "NetBox" + gethomepage.dev/description: "Network Source of Truth" + gethomepage.dev/group: "Infrastructure" + gethomepage.dev/icon: "netbox.png" +spec: + ingressClassName: tailscale + rules: + - host: {{ netbox_deploy_hostname }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: netbox + port: + number: 80 From 18ca7dac8c32a7c4972e000f38d6887b2d3d3321 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 1 Dec 2025 03:22:52 +0000 Subject: [PATCH 3/4] Improve values_overrides validation in netbox_deploy template Co-authored-by: SRF-Audio <16975040+SRF-Audio@users.noreply.github.com> --- ansible/roles/netbox_deploy/templates/netbox-application.yml.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ansible/roles/netbox_deploy/templates/netbox-application.yml.j2 b/ansible/roles/netbox_deploy/templates/netbox-application.yml.j2 index 98e1faf..3407ff3 100644 --- a/ansible/roles/netbox_deploy/templates/netbox-application.yml.j2 +++ b/ansible/roles/netbox_deploy/templates/netbox-application.yml.j2 @@ -77,7 +77,7 @@ spec: - name: netbox-media mountPath: /opt/netbox/netbox/media {% endif %} -{% if netbox_deploy_values_overrides %} +{% if netbox_deploy_values_overrides and netbox_deploy_values_overrides | length > 0 %} {{ netbox_deploy_values_overrides | to_nice_yaml | indent(8, first=true) }}{% endif %} destination: From f32981e3a38e5651fe1a461fc199150306d3a3de Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 5 Dec 2025 04:45:48 +0000 Subject: [PATCH 4/4] Simplify netbox_deploy role: reduce parameters and use local-path storage Co-authored-by: SRF-Audio <16975040+SRF-Audio@users.noreply.github.com> --- ansible/roles/netbox_deploy/defaults/main.yml | 30 +------ .../netbox_deploy/meta/argument_specs.yml | 88 +++---------------- ansible/roles/netbox_deploy/tasks/main.yml | 61 ++++--------- .../templates/netbox-application.yml.j2 | 56 ++++-------- .../templates/netbox-homepage-ingress.yml.j2 | 4 +- 5 files changed, 47 insertions(+), 192 deletions(-) diff --git a/ansible/roles/netbox_deploy/defaults/main.yml b/ansible/roles/netbox_deploy/defaults/main.yml index 988ae62..8341bb3 100644 --- a/ansible/roles/netbox_deploy/defaults/main.yml +++ b/ansible/roles/netbox_deploy/defaults/main.yml @@ -1,29 +1 @@ -netbox_deploy_kubeconfig: "{{ k3s_kubeconfig_path | default('', true) }}" -netbox_deploy_cluster_name: "{{ k3s_cluster_name | default('', true) }}" -netbox_deploy_context: "{{ k3s_context_name | default('', true) }}" - -netbox_deploy_namespace: netbox -netbox_deploy_argo_namespace: argocd -netbox_deploy_argo_project: coachlight-k3s-infra - -netbox_deploy_helm_repo_url: https://netbox-community.github.io/netbox-chart -netbox_deploy_helm_chart_name: netbox -netbox_deploy_helm_chart_version: 5.0.0-beta.145 - -netbox_deploy_values_overrides: {} - -netbox_deploy_hostname: netbox -netbox_deploy_ingress_enabled: true -netbox_deploy_tailscale_annotations: - tailscale.com/expose: "true" - tailscale.com/hostname: "netbox" - tailscale.com/tags: "tag:k8s,tag:infra-monitoring" - -netbox_deploy_storage_class_longhorn: longhorn -netbox_deploy_storage_class_synology: "" - -netbox_deploy_media_storage_config: {} - -netbox_deploy_apply_application: true - -netbox_deploy_superuser_email: admin@example.com +netbox_deploy_tmp_dir: "{{ artifacts_path }}/netbox_deploy" diff --git a/ansible/roles/netbox_deploy/meta/argument_specs.yml b/ansible/roles/netbox_deploy/meta/argument_specs.yml index 40614bb..3c946ab 100644 --- a/ansible/roles/netbox_deploy/meta/argument_specs.yml +++ b/ansible/roles/netbox_deploy/meta/argument_specs.yml @@ -1,82 +1,10 @@ argument_specs: main: - description: | - Deploy NetBox Argo CD Application into a Kubernetes cluster using the official - NetBox Helm chart, integrating with Tailscale for ingress, Longhorn/Synology for - storage, and exposing the application to Homepage for discovery. + short_description: Deploy NetBox Argo CD Application into the k3s cluster + description: > + Renders and applies an Argo CD Application manifest for the NetBox Helm + chart, using environment-scoped paths and inventory-driven configuration. options: - netbox_deploy_kubeconfig: - type: raw - required: true - description: Path to kubeconfig file or configuration dict. - netbox_deploy_context: - type: str - required: true - description: Kubernetes context name to use for deployment. - netbox_deploy_cluster_name: - type: str - required: false - description: Logical cluster name used for artifact recording. - netbox_deploy_namespace: - type: str - required: false - description: Namespace where NetBox will be deployed. - netbox_deploy_argo_namespace: - type: str - required: false - description: Namespace where Argo CD is deployed. - netbox_deploy_argo_project: - type: str - required: false - description: Argo CD project to associate the NetBox application with. - netbox_deploy_helm_repo_url: - type: str - required: false - description: URL of the NetBox Helm chart repository. - netbox_deploy_helm_chart_name: - type: str - required: false - description: Name of the NetBox Helm chart. - netbox_deploy_helm_chart_version: - type: str - required: false - description: Version of the NetBox Helm chart to deploy. - netbox_deploy_values_overrides: - type: dict - required: false - description: Dictionary of Helm values to override in the NetBox chart. - netbox_deploy_hostname: - type: str - required: false - description: Hostname for NetBox UI access via Tailscale. - netbox_deploy_ingress_enabled: - type: bool - required: false - description: Whether to enable ingress for NetBox UI. - netbox_deploy_tailscale_annotations: - type: dict - required: false - description: Annotations applied to NetBox service for Tailscale integration. - netbox_deploy_storage_class_longhorn: - type: str - required: false - description: Longhorn storage class name for database and Redis PVCs. - netbox_deploy_storage_class_synology: - type: str - required: false - description: Synology NFS storage class name for media storage. - netbox_deploy_media_storage_config: - type: dict - required: false - description: Configuration for NetBox media storage using Synology. - netbox_deploy_apply_application: - type: bool - required: false - description: Whether to apply the rendered Application manifest to the cluster. - netbox_deploy_superuser_email: - type: str - required: false - description: Email address for the NetBox superuser account. netbox_deploy_superuser_password: type: str required: true @@ -85,3 +13,11 @@ argument_specs: type: str required: true description: Django secret key for NetBox. + k8s_validator_kubeconfig: + type: raw + required: true + description: Kubeconfig path or dict used to connect to the target cluster. + k8s_validator_context: + type: str + required: true + description: Kubernetes context name to use with the provided kubeconfig. diff --git a/ansible/roles/netbox_deploy/tasks/main.yml b/ansible/roles/netbox_deploy/tasks/main.yml index ac369e9..018c808 100644 --- a/ansible/roles/netbox_deploy/tasks/main.yml +++ b/ansible/roles/netbox_deploy/tasks/main.yml @@ -2,27 +2,21 @@ - name: Assert required NetBox deployment inputs are defined ansible.builtin.assert: that: - - netbox_deploy_kubeconfig is defined - - netbox_deploy_context is defined + - k8s_validator_kubeconfig is defined + - k8s_validator_context is defined - netbox_deploy_superuser_password is defined - netbox_deploy_secret_key is defined - - netbox_deploy_kubeconfig | string | length > 0 - - netbox_deploy_context | length > 0 + - k8s_validator_kubeconfig | string | length > 0 + - k8s_validator_context | length > 0 - netbox_deploy_superuser_password | length > 0 - netbox_deploy_secret_key | length > 0 fail_msg: | - netbox_deploy_kubeconfig - netbox_deploy_context + k8s_validator_kubeconfig + k8s_validator_context netbox_deploy_superuser_password netbox_deploy_secret_key ...must be defined for netbox_deploy. -- name: Set NetBox deployment paths - ansible.builtin.set_fact: - netbox_deploy_tmp_dir: "/tmp/netbox_deploy" - netbox_deploy_application_template: "{{ role_path }}/templates/netbox-application.yml.j2" - netbox_deploy_homepage_ingress_template: "{{ role_path }}/templates/netbox-homepage-ingress.yml.j2" - - name: Ensure NetBox deployment tmp directory exists ansible.builtin.file: path: "{{ netbox_deploy_tmp_dir }}" @@ -31,51 +25,34 @@ - name: Render NetBox Argo CD Application manifest ansible.builtin.template: - src: "{{ netbox_deploy_application_template }}" + src: netbox-application.yml.j2 dest: "{{ netbox_deploy_tmp_dir }}/netbox-application.yml" mode: "0644" register: netbox_deploy_application_file - name: Render NetBox Homepage ingress manifest ansible.builtin.template: - src: "{{ netbox_deploy_homepage_ingress_template }}" + src: netbox-homepage-ingress.yml.j2 dest: "{{ netbox_deploy_tmp_dir }}/netbox-homepage-ingress.yml" mode: "0644" register: netbox_deploy_homepage_ingress_file - name: Apply NetBox Argo CD Application manifest - ansible.builtin.include_role: + ansible.builtin.import_role: name: k8s_object_manager vars: - k8s_object_manager_kubeconfig: "{{ netbox_deploy_kubeconfig }}" - k8s_object_manager_context: "{{ netbox_deploy_context }}" - k8s_object_manager_state: present k8s_object_manager_src: "{{ netbox_deploy_application_file.dest }}" + k8s_object_manager_state: present k8s_object_manager_apply: true - when: netbox_deploy_apply_application | default(true) | bool - register: netbox_deploy_application_result - -- name: Capture NetBox Argo CD Application apply result - ansible.builtin.set_fact: - netbox_deploy_application_apply_result: "{{ k8s_object_manager_result }}" - when: netbox_deploy_application_result is succeeded + k8s_object_manager_wait: true - name: Apply NetBox Homepage ingress manifest - ansible.builtin.include_role: + ansible.builtin.import_role: name: k8s_object_manager vars: - k8s_object_manager_kubeconfig: "{{ netbox_deploy_kubeconfig }}" - k8s_object_manager_context: "{{ netbox_deploy_context }}" - k8s_object_manager_state: present k8s_object_manager_src: "{{ netbox_deploy_homepage_ingress_file.dest }}" + k8s_object_manager_state: present k8s_object_manager_apply: true - when: netbox_deploy_apply_application | default(true) | bool - register: netbox_deploy_homepage_ingress_result - -- name: Capture NetBox Homepage ingress apply result - ansible.builtin.set_fact: - netbox_deploy_homepage_ingress_apply_result: "{{ k8s_object_manager_result }}" - when: netbox_deploy_homepage_ingress_result is succeeded - name: Clean up NetBox deployment tmp directory ansible.builtin.file: @@ -83,16 +60,12 @@ state: absent - name: Persist netbox_deploy artifacts - ansible.builtin.include_role: + ansible.builtin.import_role: name: role_artifacts vars: # noqa: var-naming calling_role_name: "netbox_deploy" calling_role_artifacts_inputs: - k3s_cluster_name: "{{ netbox_deploy_cluster_name | default(k3s_cluster_name | default('', true), true) }}" - application_name: "netbox" - argocd_namespace: "{{ netbox_deploy_argo_namespace }}" - namespace: "{{ netbox_deploy_namespace }}" - helm_chart_version: "{{ netbox_deploy_helm_chart_version }}" - application_result: "{{ netbox_deploy_application_apply_result | default({}, true) }}" - homepage_ingress_result: "{{ netbox_deploy_homepage_ingress_apply_result | default({}, true) }}" + kubeconfig: "{{ k8s_validator_kubeconfig }}" + context: "{{ k8s_validator_context }}" + application_file: "{{ netbox_deploy_application_file.dest }}" diff --git a/ansible/roles/netbox_deploy/templates/netbox-application.yml.j2 b/ansible/roles/netbox_deploy/templates/netbox-application.yml.j2 index 3407ff3..746c7bc 100644 --- a/ansible/roles/netbox_deploy/templates/netbox-application.yml.j2 +++ b/ansible/roles/netbox_deploy/templates/netbox-application.yml.j2 @@ -2,87 +2,61 @@ apiVersion: argoproj.io/v1alpha1 kind: Application metadata: name: netbox - namespace: {{ netbox_deploy_argo_namespace }} + namespace: argocd spec: - project: {{ netbox_deploy_argo_project }} + project: coachlight-k3s-infra source: - repoURL: {{ netbox_deploy_helm_repo_url }} - chart: {{ netbox_deploy_helm_chart_name }} - targetRevision: "{{ netbox_deploy_helm_chart_version }}" + repoURL: https://netbox-community.github.io/netbox-chart + chart: netbox + targetRevision: "5.0.0-beta.145" helm: valuesObject: superuser: - email: "{{ netbox_deploy_superuser_email }}" + email: "admin@netbox.local" password: "{{ netbox_deploy_superuser_password }}" secretKey: "{{ netbox_deploy_secret_key }}" persistence: enabled: true - storageClass: "{{ netbox_deploy_storage_class_longhorn }}" + storageClass: "local-path" postgresql: enabled: true primary: persistence: enabled: true - storageClass: "{{ netbox_deploy_storage_class_longhorn }}" + storageClass: "local-path" redis: enabled: true master: persistence: enabled: true - storageClass: "{{ netbox_deploy_storage_class_longhorn }}" + storageClass: "local-path" replica: persistence: enabled: true - storageClass: "{{ netbox_deploy_storage_class_longhorn }}" + storageClass: "local-path" service: annotations: -{% for key, value in netbox_deploy_tailscale_annotations.items() %} - {{ key }}: "{{ value }}" -{% endfor %} -{% if netbox_deploy_ingress_enabled %} + tailscale.com/expose: "true" + tailscale.com/hostname: "netbox" + tailscale.com/tags: "tag:k8s,tag:infra-monitoring" ingress: enabled: true className: tailscale hosts: - - host: {{ netbox_deploy_hostname }} + - host: netbox paths: - path: / pathType: Prefix -{% endif %} -{% if netbox_deploy_media_storage_config and netbox_deploy_storage_class_synology %} - extraVolumes: - - name: netbox-media - persistentVolumeClaim: - claimName: netbox-media - - extraVolumeMounts: - - name: netbox-media - mountPath: /opt/netbox/netbox/media - - extraInitContainers: - - name: init-media-permissions - image: busybox:1.36 - command: - - sh - - "-c" - - "chown -R 1000:1000 /opt/netbox/netbox/media" - volumeMounts: - - name: netbox-media - mountPath: /opt/netbox/netbox/media -{% endif %} -{% if netbox_deploy_values_overrides and netbox_deploy_values_overrides | length > 0 %} - -{{ netbox_deploy_values_overrides | to_nice_yaml | indent(8, first=true) }}{% endif %} destination: server: https://kubernetes.default.svc - namespace: {{ netbox_deploy_namespace }} + namespace: netbox syncPolicy: automated: prune: true diff --git a/ansible/roles/netbox_deploy/templates/netbox-homepage-ingress.yml.j2 b/ansible/roles/netbox_deploy/templates/netbox-homepage-ingress.yml.j2 index 64cac64..cd05ddd 100644 --- a/ansible/roles/netbox_deploy/templates/netbox-homepage-ingress.yml.j2 +++ b/ansible/roles/netbox_deploy/templates/netbox-homepage-ingress.yml.j2 @@ -2,7 +2,7 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: name: netbox-homepage - namespace: {{ netbox_deploy_namespace }} + namespace: netbox annotations: gethomepage.dev/enabled: "true" gethomepage.dev/name: "NetBox" @@ -12,7 +12,7 @@ metadata: spec: ingressClassName: tailscale rules: - - host: {{ netbox_deploy_hostname }} + - host: netbox http: paths: - path: /