name: openstack/neutron/neutron_ansible_tasks
enabled: {{ enable_neutron | bool }}
container:
  image: "{{ kolla_toolbox_image }}:{{ kolla_toolbox_tag }}"
task:
  mem: {{ neutron_init_mem }}
  cpus: {{ neutron_init_cpus }}
commands:
  create_database:
    run_once: True
    retries: 3
    delay: 5
    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='{{ neutron_database_name }}'"
  database_user_create:
    run_once: True
    retries: 3
    delay: 5
    dependencies:
     - path: neutron_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='{{ neutron_database_name }}'
          password='{{ neutron_database_password }}'
          host='%'
          priv='{{ neutron_database_name }}.*:ALL'
          append_privs='yes'"
  register_endpoint:
    run_once: True
    retries: 3
    delay: 5
    dependencies:
     - path: neutron-server/db_sync
     - path: keystone_ansible_tasks/running
    command: {{ ansible_task_cmd }}
      -m kolla_keystone_service
      -a "service_name=neutron
          service_type=network
          description='Openstack Networking'
          endpoint_region={{ openstack_region_name }}
          admin_url='http://{{ neutron_server_host }}:{{ neutron_server_port }}'
          internal_url='http://{{ neutron_server_host }}:{{ neutron_server_port }}'
          public_url='http://{{ neutron_server_host }}:{{ neutron_server_port }}'
          region_name={{ openstack_region_name }}
          auth={{ '{{ openstack_neutron_auth }}' }}"
      -e "{'openstack_neutron_auth':{{ openstack_neutron_auth }}}"
  create_user:
    run_once: True
    retries: 3
    delay: 5
    dependencies:
     - path: neutron-server/db_sync
     - path: keystone_ansible_tasks/running
    command: {{ ansible_task_cmd }}
      -m kolla_keystone_user
      -a "project=service
          user=neutron
          password={{ neutron_keystone_password }}
          role=admin
          region_name={{ openstack_region_name }}
          auth={{ '{{ openstack_neutron_auth }}' }}"
      -e "{'openstack_neutron_auth':{{ openstack_neutron_auth }}}"
