tripleo-ansible/tripleo_ansible/playbooks/cli-overcloud-node-provisio...

140 lines
4.9 KiB
YAML

---
# 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.qcow2
stat:
path: /var/lib/ironic/images/overcloud-full.qcow2
get_checksum: true
checksum_algorithm: md5
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.qcow2
checksum: "{{ overcloud_full_stat.stat.checksum }}"
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.qcow2
checksum: "{{ overcloud_full_stat.stat.checksum }}"
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
register: baremetal_reserved
until: baremetal_reserved is success
retries: 3
delay: 2
# 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 }}"
register: baremetal_provisioned
until: baremetal_provisioned is success
retries: 3
delay: 2
- name: Populate environment
tripleo_baremetal_populate_environment:
environment: "{{ baremetal_instances.environment }}"
instances: "{{ baremetal_provisioned.instances + baremetal_existing.instances }}"
register: baremetal_environment
- name: Write environment to {{ baremetal_deployed_path }}
copy:
dest: "{{ baremetal_deployed_path }}"
content: "{{ baremetal_environment.environment | default({}) | to_nice_yaml(indent=2) }}"