---

#- name: create persistent volume resources
#  kubernetes.core.k8s:
#    kubeconfig: "/etc/rancher/k3s/k3s.yaml"
#    state: "{{apps.ktistec.state}}"
#    definition: "{{ lookup('template', item) | from_yaml }}"
#  loop:
#    - ktistec/pv.yaml
#    - ktistec/pv-claim.yaml
#    - ktistec/pv-auth.yaml
#    - ktistec/pv-auth-claim.yaml
#  become: true

#- name: create secret for ktistec
#  kubernetes.core.k8s:
#    kubeconfig: "/etc/rancher/k3s/k3s.yaml"
#    state: "{{apps.ktistec.state}}"
#    definition:
#      apiVersion: v1
#      kind: Secret
#      type: Opaque
#      metadata:
#        name: auth-secret-2025
#        namespace: "{{apps.ktistec.namespace}}"
#      stringData:
#        htpasswd: "richard:$2y$05$E7B3.iHmoLLSyFZJJWEj3u6eMdm2gPGBu1vAn7VPo9Axk3Wbict2m"
#  become: true

- name: create ktistec namespace
  kubernetes.core.k8s:
    kubeconfig: "/etc/rancher/k3s/k3s.yaml"
    name: "{{apps.ktistec.namespace}}"
    api_version: v1
    kind: Namespace
    state: "{{apps.ktistec.state}}"
  become: true

- name: create login secret for dkregistry
  kubernetes.core.k8s:
    kubeconfig: "/etc/rancher/k3s/k3s.yaml"
    state: "{{apps.ktistec.state}}"
    definition:
      apiVersion: v1
      kind: Secret
      type: kubernetes.io/dockerconfigjson
      metadata:
        name: dkregistry-login
        namespace: "{{apps.ktistec.namespace}}"
      data:
        .dockerconfigjson: "eyJhdXRocyI6eyJka3JlZ2lzdHJ5LnhhaS1jb3JwLm5ldCI6eyJ1c2VybmFtZSI6InJpY2hhcmQiLCJwYXNzd29yZCI6Im1lMSIsImVtYWlsIjoicmljaGFyZEBleGFtcGxlLmNvbSIsImF1dGgiOiJjbWxqYUdGeVpEcHRaVEU9In19fQ=="
  become: true

- name: create ktistec activity pub resources
  kubernetes.core.k8s:
    kubeconfig: "/etc/rancher/k3s/k3s.yaml"
    state: "{{apps.ktistec.state}}"
    namespace: "{{apps.ktistec.namespace}}"
    definition: "{{ lookup('template', item) | from_yaml }}"
  loop:
#    - ktistec/configmap.yaml
    - ktistec/ingress.yaml
    - ktistec/service.yaml
    - ktistec/deployment.yaml
  become: true

