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

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

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

- name: check if undercloud is ssl enabled
  command: "grep -Fq OS_AUTH_URL=https {{ undercloud_rc }}"
  register: undercloud_ssl
  ignore_errors: true

- name: include undercloud_ssl_camap.yaml
  include_tasks: undercloud_ssl_camap.yaml
  when:
    - undercloud_ssl is succeeded
    - not splitstack_deployment|bool

- name: generate roles list from inventory file
  import_tasks: ../common/load_roles_from_inventory.yaml

- name: create workload launch script
  template:
    src: "{{ workload_launch_template }}"
    dest: "{{ workload_launch_script }}"
    mode: 0775

- name: create upgrade workaround scripts
  template:
    src: workarounds.sh.j2
    dest: "{{ working_dir }}/{{ item }}.sh"
    mode: 0775
    force: true
  loop:
    - 'pre_overcloud_upgrade_prepare_workarounds'
    - 'post_overcloud_upgrade_prepare_workarounds'
    - 'pre_overcloud_upgrade_workarounds'
    - 'post_overcloud_upgrade_workarounds'
    - 'pre_overcloud_upgrade_converge_workarounds'
    - 'post_overcloud_upgrade_converge_workarounds'
    - 'pre_ceph_upgrade_workarounds'
    - 'post_ceph_upgrade_workarounds'
  when: upgrade_workarounds

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

- name: create the custom upgrade init commands
  template:
    src: "{{ upgrade_init_command_template }}"
    dest: "{{ upgrade_init_command_dest }}"
    mode: 0775
  when: upgrade_init_command is string


- name: create overcloud upgrade script
  template:
    src: "{{ overcloud_upgrade_run_template }}"
    dest: "{{ overcloud_upgrade_run_script_base }}-{{ item }}.sh"
    mode: 0775
    force: true
  loop: "{{ oc_roles|default(['all']) }}"

- name: create overcloud converge script
  template:
    src: "{{ overcloud_upgrade_converge_template }}"
    dest: "{{ overcloud_upgrade_converge_script }}"
    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
    force: true

- name: create Remove-Unused-Rpm env-file
  template:
    src: "remove-packages.yaml.j2"
    dest: "{{ working_dir }}/remove-packages.yaml"
    mode: 0755
    force: true
  when: upgrade_remove_rpm|bool

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

- name: Create post upgrade scripts for controller nodes
  import_tasks: ../common/controller_post_scripts.yml

- name: Create L3-agent failover scripts
  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
