name: openstack/nova/nova_ansible_tasks
enabled: {{ enable_nova | bool }}
container:
  image: "{{ kolla_toolbox_image }}:{{ kolla_toolbox_tag }}"
task:
  mem: {{ nova_init_mem }}
  cpus: {{ nova_init_cpus }}
commands:
  create_database:
    run_once: True
    dependencies:
     - path: mariadb/daemon
    command: {{ ansible_task_cmd }}
      -m mysql_db
      -a "login_host='{{ database_address }}'
          login_port='{{ mariadb_port }}'
          login_user='{{ database_user }}'
          login_password='{{ database_password }}'
          name='{{ nova_database_name }}'"
  create_api_database:
    run_once: True
    dependencies:
     - path: mariadb/daemon
    command: {{ ansible_task_cmd }}
      -m mysql_db
      -a "login_host='{{ database_address }}'
          login_port='{{ mariadb_port }}'
          login_user='{{ database_user }}'
          login_password='{{ database_password }}'
          name='{{ nova_api_database_name }}'"
  database_user_create:
    run_once: True
    dependencies:
     - path: nova_ansible_tasks/create_database
    command: {{ ansible_task_cmd }}
      -m mysql_user
      -a "login_host='{{ database_address }}'
          login_port='{{ mariadb_port }}'
          login_user='{{ database_user }}'
          login_password='{{ database_password }}'
          name='{{ nova_database_name }}'
          password='{{ nova_database_password }}'
          host='%'
          priv='{{ nova_database_name }}.*:ALL'
          append_privs='yes'"
  database_api_user_create:
    run_once: True
    dependencies:
     - path: nova_ansible_tasks/create_api_database
    command: {{ ansible_task_cmd }}
      -m mysql_user
      -a "login_host='{{ database_address }}'
          login_port='{{ mariadb_port }}'
          login_user='{{ database_user }}'
          login_password='{{ database_password }}'
          name='{{ nova_api_database_name }}'
          password='{{ nova_api_database_password }}'
          host='%'
          priv='{{ nova_api_database_name }}.*:ALL'
          append_privs='yes'"
  register_endpoint:
    run_once: True
    dependencies:
     - path: nova-api/db_sync
     - path: keystone_ansible_tasks/running
    command: {{ ansible_task_cmd }}
      -m kolla_keystone_service
      -a "service_name=nova
          service_type=compute
          description='Openstack Compute'
          endpoint_region={{ openstack_region_name }}
          admin_url='http://{{ nova_api_host }}:{{ nova_api_port }}/v2/%(tenant_id)s'
          internal_url='http://{{ nova_api_host }}:{{ nova_api_port }}/v2/%(tenant_id)s'
          public_url='http://{{ nova_api_host }}:{{ nova_api_port }}/v2/%(tenant_id)s'
          region_name={{ openstack_region_name }}
          auth={{ '{{ openstack_nova_auth }}' }}"
      -e "{'openstack_nova_auth':{{ openstack_nova_auth }}}"
  create_user:
    run_once: True
    dependencies:
     - path: nova-api/db_sync
     - path: keystone_ansible_tasks/running
    command: {{ ansible_task_cmd }}
      -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 }}}"
