--- # Copyright 2020 Red Hat, Inc. # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. # - name: Overcloud Node Provision connection: "{{ (tripleo_target_host is defined) | ternary('ssh', 'local') }}" hosts: "{{ tripleo_target_host | default('localhost') }}" remote_user: "{{ tripleo_target_user | default(lookup('env', 'USER')) }}" gather_facts: "{{ (tripleo_target_host is defined) | ternary(true, false) }}" any_errors_fatal: true vars: node_timeout: 3600 concurrency: 20 pre_tasks: - fail: msg: stack_name is a required input when: - stack_name is undefined - fail: msg: baremetal_deployment is a required input when: - baremetal_deployment is undefined - fail: msg: baremetal_deployed_path is a required input when: - baremetal_deployed_path is undefined tasks: - name: Detect default overcloud-full image block: - name: stat overcloud-full.raw stat: path: /var/lib/ironic/images/overcloud-full.raw get_checksum: false register: overcloud_full_stat - name: stat overcloud-full.initrd stat: path: /var/lib/ironic/images/overcloud-full.initrd get_checksum: false register: overcloud_full_initrd_stat - name: Set file based default image set_fact: default_image: href: file:///var/lib/ironic/images/overcloud-full.raw kernel: file:///var/lib/ironic/images/overcloud-full.vmlinuz ramdisk: file:///var/lib/ironic/images/overcloud-full.initrd when: - overcloud_full_stat.stat.exists|bool - overcloud_full_initrd_stat.stat.exists|bool - name: Set whole-disk file based default image set_fact: default_image: href: file:///var/lib/ironic/images/overcloud-full.raw when: - overcloud_full_stat.stat.exists|bool - not overcloud_full_initrd_stat.stat.exists|bool - name: Set glance based default image set_fact: default_image: href: overcloud-full when: not overcloud_full_stat.stat.exists|bool - name: Expand roles tripleo_baremetal_expand_roles: baremetal_deployment: "{{ baremetal_deployment }}" state: present stack_name: "{{ stack_name }}" ssh_public_keys: "{{ ssh_public_keys }}" user_name: "{{ ssh_user_name }}" default_image: "{{ default_image }}" register: baremetal_instances - name: Find existing instances tripleo_baremetal_check_existing: instances: "{{ baremetal_instances.instances }}" register: baremetal_existing - name: Reserve instances metalsmith_instances: instances: "{{ baremetal_existing.not_found }}" state: reserved clean_up: true log_level: info register: baremetal_reserved - name: Metalsmith log for reserve instances debug: var: baremetal_reserved.logging # NOTE(cloudnull): This limits the concurrency so that we're not adding # more threads than needed. - name: Set concurrency fact set_fact: runtime_concurrency: "{{ ((concurrency | int) > (baremetal_reserved.instances | length)) | ternary((baremetal_reserved.instances | length), (concurrency | int)) }}" - name: Provision instances metalsmith_instances: instances: "{{ baremetal_reserved.instances }}" state: present wait: true clean_up: false timeout: "{{ node_timeout }}" concurrency: "{{ runtime_concurrency }}" log_level: info register: baremetal_provisioned - name: Metalsmith log for provision instances debug: var: baremetal_provisioned.logging - name: Provision instance network ports tripleo_overcloud_network_ports: stack_name: "{{ stack_name }}" concurrency: "{{ runtime_concurrency }}" instances: "{{ baremetal_instances.instances }}" provisioned_instances: "{{ baremetal_provisioned.instances + baremetal_existing.instances }}" hostname_role_map: "{{ baremetal_instances.hostname_role_map }}" state: present register: instance_network_ports when: manage_network_ports|default(false) - name: Populate environment tripleo_baremetal_populate_environment: environment: "{{ baremetal_instances.environment }}" instances: "{{ baremetal_provisioned.instances + baremetal_existing.instances }}" register: baremetal_environment - name: Populate environment with unmanaged nodes tripleo_unmanaged_populate_environment: environment: "{{ baremetal_environment.environment }}" instances: "{{ baremetal_existing.pre_provisioned }}" node_port_map: "{{ instance_network_ports.node_port_map }}" register: unmanaged_environment when: manage_network_ports|default(false) - name: Populate environment with network port data tripleo_network_ports_populate_environment: environment: "{{ unmanaged_environment.environment }}" role_net_map: "{{ baremetal_instances.role_net_map }}" node_port_map: "{{ instance_network_ports.node_port_map }}" register: network_ports_environment when: manage_network_ports|default(false) - name: Write environment to {{ baremetal_deployed_path }} copy: dest: "{{ baremetal_deployed_path }}" content: "{{ baremetal_environment.environment | default({}) | to_nice_yaml(indent=2) }}" when: not manage_network_ports|default(false) - name: Write environment to {{ baremetal_deployed_path }} copy: dest: "{{ baremetal_deployed_path }}" content: "{{ network_ports_environment.environment | default({}) | to_nice_yaml(indent=2) }}" when: manage_network_ports|default(false)