---

- name: create database
  mysql_db: name={{ item }} state=present
  with_items:
    - nova_api
    - nova

- name: Grant proper access to the nova_api databases
  mysql_user: name=nova host={{ item }} password={{ NOVA_DBPASS }} priv=nova_api.*:ALL state=present
  with_items:
    - localhost
    - "%"

- name: Grant proper access to the nova databases
  mysql_user: name=nova host={{ item }} password={{ NOVA_DBPASS }} priv=nova.*:ALL state=present
  with_items:
    - localhost
    - "%"

- name: create nova service entry and endpoint
  script: create_nova_service_entity_and_api_endpoint.sh {{ NOVA_PASS }} {{ api_host }}
  environment: admin_openrc
  sudo: no

- name: install nova packages
  apt: pkg={{ item }} update_cache=yes cache_valid_time=3600
  with_items:
    - nova-api
    - nova-conductor
    - nova-consoleauth
    - nova-novncproxy
    - nova-scheduler

- name: edit nova conf file
  template: src=nova.conf.j2 dest=/etc/nova/nova.conf

- name: Populate the Compute database
  script: nova_db_sync.sh

- name: Restart the Compute services
  service: name={{ item }} state=restarted
  with_items:
    - nova-api
    - nova-consoleauth
    - nova-scheduler
    - nova-conductor
    - nova-novncproxy

- name: remove the SQLite database file
  file: path=/var/lib/nova/nova.sqlite state=absent

---

- name: create database
  mysql_db: name={{ item }} state=present
  with_items:
    - nova_api
    - nova

- name: Grant proper access to the databases
  mysql_user: name=nova host={{ item }} password={{ NOVA_DBPASS }} priv=nova.*:ALL/nova_api.*:ALL state=present
  with_items:
    - 'localhost'
    - '%'

- name: create nova service entry and endpoint
  script: create_nova_service_entity_and_api_endpoint.sh {{ NOVA_PASS }} {{ api_host }}
  environment: admin_openrc
  sudo: no

- name: install nova packages
  apt: pkg={{ item }} update_cache=yes cache_valid_time=3600
  with_items:
    - nova-api
    - nova-conductor
    - nova-consoleauth
    - nova-novncproxy
    - nova-scheduler

- name: edit nova conf file
  template: src=nova.conf.j2 dest=/etc/nova/nova.conf

- name: Populate the Compute database
  script: nova_db_sync.sh

- name: Restart the Compute services
  service: name={{ item }} state=restarted
  with_items:
    - nova-api
    - nova-consoleauth
    - nova-scheduler
    - nova-conductor
    - nova-novncproxy

- name: remove the SQLite database file
  file: path=/var/lib/nova/nova.sqlite state=absent

Fix grant priviledges to nova user
Fix grant priviledges to nova user
