---
apiVersion: batch/v1
kind: Job
metadata:
  generateName: e2e-elasticsearch-
  namespace: e2e
spec:
  template:
    metadata:
      name: e2e
      labels:
        app: elasticsearch-deployment-e2e

    spec:
      serviceAccountName: e2e
      restartPolicy: Never
      containers:

      - name: ansibletest
        image: openebs/ansible-runner:ci
        imagePullPolicy: IfNotPresent

        env:
          - name: ANSIBLE_STDOUT_CALLBACK
            #value: log_plays
            value: default

          - name: PROVIDER_STORAGE_CLASS
            # Supported values: openebs-standard,openebs-standalone,local-storage
            value: openebs-cstor-sparse

            # Application pvc
          - name: APP_PVC
            value: openebs-esearch 

            # Application label
          - name: APP_LABEL
            value: 'app=elasticsearch'

           # Affinity Label for Application
          - name: AFFINITY_LABEL
            value: openebs.io/sts-target-affinity

            # Application namespace
          - name: APP_NAMESPACE
            value: app-esearch-ns 

          - name: DEPLOY_TYPE
            value: statefulset

          - name: APP_REPLICA
            value: 'replicas=1'
            
          # Use 'deprovision' for app-clean up
          - name: ACTION
            value: provision

          # define a variable CAPACITY to accept the size given by user
          - name: CAPACITY
            value: 8G

        command: ["/bin/bash"]
        args: ["-c", "ansible-playbook ./apps/elasticsearch/deployers/test.yml -i /etc/ansible/hosts -v; exit 0"]
