---
# deployment task for backstage portal
# https://github.com/backstage/charts/tree/main/charts/backstage

- name: Create a namespace for backstage
  k8s:
    kubeconfig: "/etc/rancher/k3s/k3s.yaml"
    name: "{{apps.backstage.namespace}}"
    api_version: v1
    kind: Namespace
    state: "{{apps.backstage.state}}"
  become: true

- name: Install backstage instance
  block:
    - name: Add backstage chart helm repo
      local_action:
        module: kubernetes.core.helm_repository
        name: backstage
        repo_url: https://backstage.github.io/charts

    - name: load variables files/backstage/values.yaml
      ansible.builtin.include_vars:
        file: files/backstage/values.yaml
        name: release_values

    - name: Install backstage chart
      local_action:
        module: kubernetes.core.helm
        release_state: "{{apps.backstage.state}}"
        name: backstage
        namespace: "{{apps.backstage.namespace}}"
        create_namespace: yes
        update_repo_cache: True
        chart_ref: backstage/backstage
        values: "{{release_values}}"
        wait: true
