apiVersion: batch/v1
kind: Job
spec:
  parallelism: 1
  completions: 1
  template:
    metadata:
      name: nova-control-bootstrap-create-endpoints
    spec:
      containers:
        - image: "{{ kolla_toolbox_image_full }}"
          name: creating-nova-endpoints
          command: ["sh", "-c"]
          args:
            - /usr/bin/ansible localhost -vvvv -m kolla_keystone_service
              -a "service_name=nova
                  service_type=compute
                  description='Openstack Compute'
                  endpoint_region={{ openstack_region_name }}
                  url='{{ nova_admin_endpoint }}'
                  interface='admin'
                  region_name={{ openstack_region_name }}
                  auth={{ '{{' }} openstack_nova_auth {{ '}}' }}"
              -e "{'openstack_nova_auth':{{ openstack_nova_auth }}}" &&
              /usr/bin/ansible localhost -vvvv -m kolla_keystone_service
              -a "service_name=nova
                  service_type=compute
                  description='Openstack Compute'
                  endpoint_region={{ openstack_region_name }}
                  url='{{ nova_internal_endpoint }}'
                  interface='internal'
                  region_name={{ openstack_region_name }}
                  auth={{ '{{ openstack_nova_auth }}' }}"
              -e "{'openstack_nova_auth':{{ openstack_nova_auth }}}" &&
              /usr/bin/ansible localhost -vvvv -m kolla_keystone_service
              -a "service_name=nova
                  service_type=compute
                  description='Openstack Compute'
                  endpoint_region={{ openstack_region_name }}
                  url='{{ nova_public_endpoint }}'
                  interface='public'
                  region_name={{ openstack_region_name }}
                  auth={{ '{{ openstack_nova_auth }}' }}"
              -e "{'openstack_nova_auth':{{ openstack_nova_auth }}}" &&
              /usr/bin/ansible localhost -vvvv
                  -m kolla_keystone_user
                  -a "project=service
                      user=nova
                      password=$NOVA_KEYSTONE_PASSWORD
                      role=admin
                      region_name={{ openstack_region_name }}
                      auth={{ '{{ openstack_nova_auth }}' }}"
                  -e "{'openstack_nova_auth':{{ openstack_nova_auth }}}"
          volumeMounts:
            - mountPath: /var/log/kolla
              name: kolla-logs
          env:
            - name: ANSIBLE_NOCOLOR
              value: "1"
            - name: ANSIBLE_LIBRARY
              value: "/usr/share/ansible"
            - name: KEYSTONE_ADMIN_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: keystone-admin-password
                  key: password
            - name: NOVA_KEYSTONE_PASSWORD
              valueFrom:
               secretKeyRef:
                  name: nova-keystone-password
                  key: password
      volumes:
        - name: nova-api-config
          configMap:
            name: nova-api-configmap
        - name: etc-localtime
          hostPath:
            path: /etc/localtime
        - name: lib-modules
          hostPath:
            path: /lib/modules
        - name: kolla-logs
          emptyDir: {}
      restartPolicy: OnFailure
metadata:
  name: nova-control-bootstrap-create-endpoints
