Conditionally run appropriate db_sync commands

Take advantage of the return code given by keystone_manage db_sync's
'check' option to conditionally run the appropriate database migration
commands.

0 - currently up to date
1 - error requiring operator intervention
2 - expand required
3 - migrate required
4 - contract required

Related-Bug: 1642212
Change-Id: I129590ff6ac4e45bfd9b3ea21ad6615f66d37d31
This commit is contained in:
Jimmy McCrory 2017-02-09 22:25:49 -08:00
parent 05b20e512c
commit d2e00019b4

View File

@ -27,16 +27,28 @@
- "{{ keystone_wsgi_program_names }}"
- "{{ keystone_system_service_name }}"
- name: Check current state of Keystone DB
command: "{{ keystone_bin }}/keystone-manage db_sync --check"
register: keystone_db_sync_check
failed_when: keystone_db_sync_check.rc == 1
changed_when: "{{ keystone_db_sync_check.rc not in [2, 3, 4] }}"
- name: Perform a Keystone DB sync expand
command: "{{ keystone_bin }}/keystone-manage db_sync --expand"
changed_when: true
become: yes
become_user: "{{ keystone_system_user_name }}"
when: keystone_db_sync_check.rc == 2
- name: Perform a Keystone DB sync migrate
command: "{{ keystone_bin }}/keystone-manage db_sync --migrate"
changed_when: true
become: yes
become_user: "{{ keystone_system_user_name }}"
when: "{{ keystone_db_sync_check.rc in [2, 3] }}"
notify:
- Perform a Keystone DB sync contract
- name: Check if Keystone DB sync contract is required
command: "true"
changed_when: keystone_db_sync_check.rc == 4
notify:
- Perform a Keystone DB sync contract