The expand function was failing to add the username and public keys to the instances list. This change treats these arguments like other defaults, and adds tests to confirm they're ending up in the instances list. This change also has a minor fix to the unprovision prompt validation logic. Change-Id: I603623511e4061e782a65d53a3118d211ea6e708
82 lines
2.9 KiB
YAML
82 lines
2.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 Unprovision
|
|
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:
|
|
prompt: true
|
|
all: false
|
|
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: unprovision_confirm or unprovision_environment is required when prompt is true
|
|
when:
|
|
- prompt
|
|
- unprovision_confirm is undefined
|
|
- unprovision_environment is undefined
|
|
|
|
tasks:
|
|
|
|
- name: Expand roles
|
|
tripleo_baremetal_expand_roles:
|
|
baremetal_deployment: "{{ baremetal_deployment }}"
|
|
stack_name: "{{ stack_name }}"
|
|
state: "{{ all|bool and 'all' or 'absent' }}"
|
|
register: baremetal_instances
|
|
|
|
- name: Find existing instances
|
|
tripleo_baremetal_check_existing:
|
|
instances: "{{ baremetal_instances.instances }}"
|
|
register: baremetal_existing
|
|
|
|
- name: Write unprovision confirmation
|
|
block:
|
|
- name: Write instances for confirmation
|
|
copy:
|
|
dest: "{{ unprovision_confirm }}"
|
|
content: "{{ baremetal_existing.instances | to_json }}"
|
|
when: unprovision_confirm is defined
|
|
- name: Expand roles for provisioned instances
|
|
tripleo_baremetal_expand_roles:
|
|
baremetal_deployment: "{{ baremetal_deployment }}"
|
|
stack_name: "{{ stack_name }}"
|
|
state: present
|
|
register: baremetal_instances_existing
|
|
when: unprovision_environment is defined
|
|
- name: Write environment for node delete resource mapping
|
|
copy:
|
|
dest: "{{ unprovision_environment }}"
|
|
content: "{{ baremetal_instances_existing.environment | to_json }}"
|
|
when: unprovision_environment is defined
|
|
when: prompt|bool
|
|
|
|
- name: Unprovision instances
|
|
metalsmith_instances:
|
|
instances: "{{ baremetal_existing.instances }}"
|
|
state: absent
|
|
when: not prompt|bool
|