- hosts: localhost
  tasks:
    - name: Set up cinder storage class
      k8s:
        context: gitea
        state: present
        definition: "{{ lookup('file', 'storage-class.yaml') | from_yaml }}"

    - name: Set up gitea-db namespace
      k8s:
        context: gitea
        state: present
        definition: "{{ lookup('template', 'gitea-db-namespace.yaml') | from_yaml }}"

    - name: Set up gitea-db secrets
      k8s:
        context: gitea
        state: present
        definition: "{{ lookup('template', 'secrets.yaml') | from_yaml }}"

    - name: Set up gitea-db mysql config configmap
      k8s:
        context: gitea
        state: present
        definition: "{{ lookup('file', 'config-map_mysql-config.yaml') | from_yaml }}"

    - name: Set up gitea-db startup scripts configmap
      k8s:
        context: gitea
        state: present
        definition: "{{ lookup('file', 'config-map_startup-scripts.yaml') | from_yaml }}"

    - name: Set up gitea-db xtradb cluster statefulset
      k8s:
        context: gitea
        state: present
        definition: "{{ lookup('file', 'statefulset.yaml') | from_yaml }}"

    - name: Set up gitea-db metrics service
      k8s:
        context: gitea
        state: present
        definition: "{{ lookup('file', 'service-metrics.yaml') | from_yaml }}"

    - name: Set up gitea-db database service
      k8s:
        context: gitea
        state: present
        definition: "{{ lookup('file', 'service-percona.yaml') | from_yaml }}"

    - name: Set up gitea-db galera replication service
      k8s:
        context: gitea
        state: present
        definition: "{{ lookup('file', 'service-repl.yaml') | from_yaml }}"