---
- name: create a comptatible deployment scripts from oooq
  include_tasks: ../upgrade/use_oooq.yaml
  args:
    apply:
      tags: use_oooq
  tags: use_oooq
  when: use_oooq|bool

- name: make a copy of the initial overcloud deploy script
  copy:
    remote_src: true
    src: "{{ overcloud_deploy_script }}"
    dest: "{{ overcloud_deploy_script }}.orig.sh"

- name: Adjust ffu scenario file.
  replace:
    dest: "{{ overcloud_deploy_script }}"
    regexp: "{{ composable_scenario }}"
    replace: "{{ upgrade_composable_scenario }}"
  when:
    - tripleo_ci|bool
    - upgrade_composable_scenario|default("")
    - composable_scenario|default("")

- name: Convert CLI options to parameters
  import_tasks: ../common/convert_cli_opts_params.yaml

- name: get auxiliary facts for upgrade
  import_tasks: ../common/auxilary-facts.yaml

- name: Convert Ceph parameters to ceph ansible
  import_tasks: ../common/convert_ceph_params.yaml

- name: Adjust custom roles data file during upgrade
  import_tasks: convert_roles_data.yaml

- name: create ffu upgrade workaround scripts
  template:
    src: fast-forward-upgrade/workarounds.sh.j2
    dest: "{{ working_dir }}/{{ item }}.sh"
    mode: 0775
  loop:
    - 'pre_ffu_undercloud_upgrade_workarounds'
    - 'post_ffu_undercloud_upgrade_workarounds'
    - 'pre_ffu_overcloud_prepare_workarounds'
    - 'post_ffu_overcloud_prepare_workarounds'
    - 'pre_ffu_overcloud_run_workarounds'
    - 'post_ffu_overcloud_run_workarounds'
    - 'pre_ffu_overcloud_upgrade_workarounds'
    - 'post_ffu_overcloud_upgrade_workarounds'
    - 'pre_ffu_overcloud_converge_workarounds'
    - 'post_ffu_overcloud_converge_workarounds'
    - 'pre_ffu_overcloud_ceph_workarounds'
    - 'post_ffu_overcloud_ceph_workarounds'
  when: ffu_upgrade_workarounds

- name: Create FFU custom repos environment
  template:
    src: fast-forward-upgrade/ffu_repos.yaml.j2
    dest: "{{ working_dir }}/ffu_repos.yaml"
  when: "'tripleo-repos' not in ffu_overcloud_repo_type"

- name: create overcloud ffwd run script
  template:
    src: "fast-forward-upgrade/overcloud_upgrade_run.sh.j2"
    dest: "{{ working_dir }}/overcloud_upgrade_run.sh"
    mode: 0775
    force: false

- name: create overcloud converge script
  template:
    src: "overcloud_upgrade_converge.sh.j2"
    dest: "{{ working_dir }}/overcloud_upgrade_converge.sh"
    mode: 0775
    force: true

- name: create ceph upgrade script
  template:
    src: "ceph-upgrade-run.sh.j2"
    dest: "{{ working_dir }}/ceph-upgrade-run.sh"
    mode: 0755

- name: import ssh_config_skip_host tasks
  import_tasks: ../common/ssh_config_skip_host.yml

- name: import create_l3_agent_connectivity_check_script tasks
  import_tasks: ../common/create_l3_agent_connectivity_check_script.yml

- name: import create_l3_agent_failover_check_script tasks
  import_tasks: ../common/create_l3_agent_failover_check_script.yml

- name: create nova actions check script
  import_tasks: ../common/create_nova_actions_check_script.yml

- name: import create HTTP test scripts
  import_tasks: ../common/create_http_test_scripts.yml
