tripleo-ansible/tripleo_ansible/playbooks/cli-overcloud-node-unprovision.yaml
James Slagle 5667f4ec86 Add pre-provisioned nodes to unprovision confirmation
In order for tripleoclient to properly display a confirmation about
unprovisioning network ports for pre-provisioned nodes, the
pre-provisioned node data must be added to the unprovision confirmation.

The output structure written to the unprovision confirmation file is
changed from a list to a dict so that the provisioned vs pre-provisioned
nodes can be distinguished. This change would break tripleoclient,
however the associated tripeloclient depends-on patch adds backwards
compatibility to check for a list or dict.

Signed-off-by: James Slagle <jslagle@redhat.com>
Depends-On: Id7ebc59948cc6ad6c2270304c35ab0475259a6c0
Change-Id: Id377b2c7ed973a7e2365b33dba2c1d59a59e26b9
2022-02-23 11:14:55 -05:00

77 lines
2.6 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
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: unprovision_confirm is required when prompt is true
when:
- prompt
- unprovision_confirm 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
copy:
dest: "{{ unprovision_confirm }}"
content: "{{ {'instances':baremetal_existing.instances, 'pre_provisioned':baremetal_existing.pre_provisioned} | to_json }}"
when: prompt|bool and unprovision_confirm is defined
- name: Unprovision instances
metalsmith_instances:
instances: "{{ baremetal_existing.instances }}"
state: absent
when: not prompt|bool
- name: Unprovision instance network ports
tripleo_overcloud_network_ports:
stack_name: "{{ stack_name }}"
concurrency: "{{ concurrency }}"
instances: "{{ baremetal_instances.instances }}"
state: absent
when:
- not prompt|bool
- manage_network_ports|default(false)