provision.yml 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. ---
  2. - name: Generate the templates
  3. include_tasks: generate-templates.yml
  4. when:
  5. - openshift_openstack_stack_state == 'present'
  6. - name: check for openstack client
  7. command: openstack
  8. register: openstack_cli_exists
  9. ignore_errors: True
  10. - name: validate the Heat template
  11. command: openstack orchestration template validate -t {{ stack_template_path }}
  12. register: template_validation_output
  13. when: openstack_cli_exists|succeeded
  14. - name: Check if the stack exists
  15. command: openstack stack show {{ openshift_openstack_stack_name }}
  16. ignore_errors: True
  17. register: stack_exists
  18. when: openstack_cli_exists|succeeded
  19. - name: Dry-run the stack (create)
  20. command: openstack stack create --dry-run -t {{ stack_template_path }} {{ openshift_openstack_stack_name }}
  21. ignore_errors: True
  22. register: stack_create_dry_run_output
  23. when:
  24. - openstack_cli_exists|succeeded
  25. - stack_exists|failed
  26. - name: Dry-run the stack (update)
  27. command: openstack stack update --dry-run -t {{ stack_template_path }} {{ openshift_openstack_stack_name }}
  28. ignore_errors: True
  29. register: stack_update_dry_run_output
  30. when:
  31. - openstack_cli_exists|succeeded
  32. - stack_exists|succeeded
  33. - name: Show the dry run errors (create)
  34. debug: var=stack_create_dry_run_output.stderr
  35. when:
  36. - openstack_cli_exists|succeeded
  37. - stack_create_dry_run_output|failed
  38. - name: Show the dry run errors (update)
  39. debug: var=stack_update_dry_run_output.stderr
  40. when:
  41. - openstack_cli_exists|succeeded
  42. - stack_update_dry_run_output|failed
  43. - fail:
  44. msg: The Heat stack creation failed. Please inspect the message above.
  45. when:
  46. - openstack_cli_exists|succeeded
  47. - (stack_create_dry_run_output|failed or stack_update_dry_run_output|failed)
  48. - name: Handle the Stack (create/delete)
  49. ignore_errors: True
  50. register: stack_create
  51. os_stack:
  52. name: "{{ openshift_openstack_stack_name }}"
  53. state: "{{ openshift_openstack_stack_state }}"
  54. template: "{{ stack_template_path | default(omit) }}"
  55. wait: yes
  56. - name: get errors in stack creation, if any
  57. command: openstack stack failures list {{ openshift_openstack_stack_name }}
  58. register: stack_create_failures
  59. when:
  60. - openstack_cli_exists|succeeded
  61. - stack_create|failed
  62. - name: show errors in stack creation, if any
  63. debug: var=stack_create_failures
  64. when:
  65. - openstack_cli_exists|succeeded
  66. - stack_create|failed
  67. - fail:
  68. msg: Stack creation failed
  69. when:
  70. - stack_create|failed
  71. - name: Add the new nodes to the inventory
  72. meta: refresh_inventory
  73. - name: Legacy LBaaSv2 SG OpenShift API correction
  74. os_port:
  75. state: present
  76. name: "{{ openshift_openstack_api_lb_port_id }}"
  77. security_groups:
  78. - "{{ openshift_openstack_api_lb_sg_id }}"
  79. when:
  80. - openshift_openstack_api_lb_provider|default(None) == "haproxy"
  81. - name: CleanUp
  82. include_tasks: cleanup.yml
  83. when:
  84. - openshift_openstack_stack_state == 'present'
  85. # TODO(shadower): create the registry and PV Cinder volumes if specified
  86. # and include the `prepare-and-format-cinder-volume` tasks to set it up