Skip to content

Commit

Permalink
Conditionally run appropriate db_sync commands
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jimmymccrory committed Feb 28, 2017
1 parent 05b20e5 commit d2e0001
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tasks/keystone_db_setup.yml
Expand Up @@ -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

0 comments on commit d2e0001

Please sign in to comment.