---
# deployment task for pixelfed
# https://github.com/small-hack/pixelfed-chart

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

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

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

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