---
- name: create update scripts
  include: create-update-scripts.yaml
  tags: create_update_scripts
  when: update_noop|bool or undercloud_update|bool or overcloud_update|bool

- block:
    - name: undercloud pre-update workarounds
      shell: |
          source {{ undercloud_rc }}
          bash {{ pre_undercloud_update_workarounds_script }} &> {{ working_dir }}/uc_pre_update_workarounds.log
      when: updates_workarounds|bool

    - name: update undercloud
      shell: "bash {{ undercloud_update_script }} &> {{ working_dir }}/undercloud_update.log"
      tags: undercloud_update

    - name: undercloud post-update workarounds
      shell: |
          source {{ undercloud_rc }}
          bash {{ post_undercloud_update_workarounds_script }} &> {{ working_dir }}/uc_pre_update_workarounds.log
      when: updates_workarounds|bool

    - name: validate undercloud update
      include: ../common/undercloud_validate_upgrade.yaml
      tags: undercloud_update_validate

  when: undercloud_update|bool

- block:
    - name: overcloud pre-update prepare workarounds
      shell: |
          source {{ undercloud_rc }}
          bash {{ pre_overcloud_update_prepare_workarounds_script }} &> {{ working_dir }}/pre_overcloud_update_prepare_workarounds.log
      when: updates_workarounds|bool

    - include: overcloud_update_prepare.yml
      tags:
        - overcloud_update
        - overcloud_update_prepare

    - name: overcloud post-update prepare workarounds
      shell: |
          source {{ undercloud_rc }}
          bash {{ post_overcloud_update_prepare_workarounds_script }} &> {{ working_dir }}/post_overcloud_update_prepare_workarounds.log
      when: updates_workarounds|bool

    - name: Ensure ansible-pacemaker module is present in CI.
      yum: name=ansible-pacemaker state=latest
      when: tripleo_ci|default(false)|bool
      tags: overcloud_update
      become: true

    - name: overcloud pre-update run workarounds
      shell: |
          source {{ undercloud_rc }}
          bash {{ pre_overcloud_update_run_workarounds_script }} &> {{ working_dir }}/pre_overcloud_update_run_workarounds.log
      when: updates_workarounds|bool

    - include: overcloud_update_run.yml
      tags:
          - overcloud_update

    - name: overcloud post-update run workarounds
      shell: |
          source {{ undercloud_rc }}
          bash {{ post_overcloud_update_run_workarounds_script }} &> {{ working_dir }}/post_overcloud_update_run_workarounds.log
      when: updates_workarounds|bool

    - name: validate overcloud docker images/containers
      shell: |
          source {{ undercloud_rc }}
          bash {{ overcloud_validate_images_script }} &> {{ working_dir}}/validate_oc_images_containers.log
      tags:
          - overcloud_update
          - overcloud_images_validate

  when: overcloud_update|bool
