TripleO Ansible project repository. Contains playbooks for use with TripleO OpenStack deployments.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

66 lines
2.2 KiB

  1. ---
  2. # Copyright 2020 Red Hat, Inc.
  3. # All Rights Reserved.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  6. # not use this file except in compliance with the License. You may obtain
  7. # a copy of the License at
  8. #
  9. # http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  14. # License for the specific language governing permissions and limitations
  15. # under the License.
  16. #
  17. - name: Overcloud Node Unprovision
  18. connection: "{{ (tripleo_target_host is defined) | ternary('ssh', 'local') }}"
  19. hosts: "{{ tripleo_target_host | default('localhost') }}"
  20. remote_user: "{{ tripleo_target_user | default(lookup('env', 'USER')) }}"
  21. gather_facts: "{{ (tripleo_target_host is defined) | ternary(true, false) }}"
  22. any_errors_fatal: true
  23. vars:
  24. prompt: true
  25. all: false
  26. pre_tasks:
  27. - fail:
  28. msg: stack_name is a required input
  29. when:
  30. - stack_name is undefined
  31. - fail:
  32. msg: baremetal_deployment is a required input
  33. when:
  34. - baremetal_deployment is undefined
  35. - fail:
  36. msg: unprovision_confirm is required when prompt is true
  37. when:
  38. - prompt
  39. - unprovision_confirm is undefined
  40. tasks:
  41. - name: Expand roles
  42. tripleo_baremetal_expand_roles:
  43. baremetal_deployment: "{{ baremetal_deployment }}"
  44. stack_name: "{{ stack_name }}"
  45. state: "{{ all|bool and 'all' or 'absent' }}"
  46. register: baremetal_instances
  47. - name: Find existing instances
  48. tripleo_baremetal_check_existing:
  49. instances: "{{ baremetal_instances.instances }}"
  50. register: baremetal_existing
  51. - name: Write unprovision confirmation
  52. copy:
  53. dest: "{{ unprovision_confirm }}"
  54. content: "{{ baremetal_existing.instances | to_json }}"
  55. when: prompt|bool and unprovision_confirm is defined
  56. - name: Unprovision instances
  57. metalsmith_instances:
  58. instances: "{{ baremetal_existing.instances }}"
  59. state: absent
  60. when: not prompt|bool