---
# Generate a number of scripts from templates.  These are scripts
# rather than additional ansible tasks so that they can be run
# manually from the undercloud host.
- name: Create overcloud deploy script
  template:
    src: "{{ deploy_script }}"
    dest: "{{ working_dir }}/overcloud-deploy.sh"
    mode: 0755

- name: Create post-deploy script
  template:
    src: "{{ post_deploy_script }}"
    dest: "{{ working_dir }}/overcloud-deploy-post.sh"
    mode: 0755

- name: Copy neutron l3 ha heat template
  when: enable_pacemaker|bool and number_of_controllers|int < 3
  template:
    src: "neutronl3ha.yaml.j2"
    dest: "{{ working_dir }}/neutronl3ha.yaml"

- name: Create config-downlad environment
  when: (deploy_steps_ansible_workflow|bool) and (deploy_multinode|bool)
  template:
    src: "config-download.yaml.j2"
    dest: "{{ working_dir }}/config-download.yaml"

- name: Write composable roles file
  when: composable_roles|bool and generate_overcloud_roles is not defined
  template:
    src: "overcloud_roles.yaml.j2"
    dest: "{{ working_dir }}/overcloud_roles.yaml"

- name: Copy composable services file
  when: composable_services|bool
  template:
    src: "overcloud_services.yaml.j2"
    dest: "{{ working_dir }}/overcloud_services.yaml"

- name: Create overcloud topology configuration
  template:
    src: "overcloud-topology-config.yaml.j2"
    dest: "{{ working_dir }}/overcloud-topology-config.yaml"
  when: topology_map is defined

- name: Cloud names heat environment
  when: release not in ['mitaka', 'liberty']
  template:
    src: "cloud-names.yaml.j2"
    dest: "{{ working_dir }}/cloud-names.yaml"

- name: Create the hostname_map parameters yaml
  when:
    - groups['overcloud'] is defined
    - groups['overcloud'][0] is defined
    - overcloud_nodes is defined
    - overcloud_nodes[0] is defined
    - overcloud_nodes[0].hostnamemap_override is defined
  template:
    src: "hostnamemap.yaml.j2"
    dest: "{{ working_dir }}/hostnamemap.yaml"

- name: Copy nic-configs resource registry template
  when: use_resource_registry_nic_configs|bool
  template:
    src: "resource-registry-nic-configs.yaml.j2"
    dest: "{{ working_dir }}/resource-registry-nic-configs.yaml"

- name: Create the overcloud network parameters yaml
  when:
    - overcloud_neutron_global_physnet_mtu is defined
  template:
    src: "overcloud_network_params.yaml.j2"
    dest: "{{ working_dir }}/overcloud_network_params.yaml"

- name: Create overriding ansible.cfg for overcloud deployment
  when: override_ansiblecfg|bool
  template:
    src: "ansible.cfg.j2"
    dest: "{{ working_dir }}/custom_ansible.cfg"

- name: Create selinux configuration for overcloud
  template:
    src: "overcloud-selinux-config.yaml.j2"
    dest: "{{ working_dir }}/overcloud-selinux-config.yaml"
