---
apiVersion: batch/v1
kind: Job
metadata:
  name: "{{ ansible_operator_meta.name }}"
  namespace: "{{ ansible_operator_meta.namespace }}"
spec:
  ttlSecondsAfterFinished: 3600
  template:
    spec:
      serviceAccountName: resource-operator-controller-manager-job
      containers:
        - name: "{{ ansible_operator_meta.name }}"
          image: "{{ _runner_image }}"
          imagePullPolicy: Always
          env:
            - name: TOWER_OAUTH_TOKEN
              value: "{{ tower_config_secret['resources'][0]['data']['token'] | b64decode }}"
            - name: TOWER_HOST
              value: "{{ tower_config_secret['resources'][0]['data']['host'] | b64decode }}"
            - name: TOWER_JOB_TEMPLATE_NAME
              value: "{{ job_template_name }}"
            - name: TOWER_VERIFY_SSL
              value: "False"
            - name: ANSIBLEJOB_NAME
              value: "{{ ansible_operator_meta.name }}"
            - name: ANSIBLEJOB_NAMESPACE
              value: "{{ ansible_operator_meta.namespace }}"
      restartPolicy: Never
  backoffLimit: 1
