provision.yml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 is 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 is 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 is succeeded
  25. - stack_exists is 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 is succeeded
  32. - stack_exists is succeeded
  33. - name: Show the dry run errors (create)
  34. debug: var=stack_create_dry_run_output.stderr
  35. when:
  36. - openstack_cli_exists is succeeded
  37. - stack_create_dry_run_output is failed
  38. - name: Show the dry run errors (update)
  39. debug: var=stack_update_dry_run_output.stderr
  40. when:
  41. - openstack_cli_exists is succeeded
  42. - stack_update_dry_run_output is failed
  43. - fail:
  44. msg: The Heat stack creation failed. Please inspect the message above.
  45. when:
  46. - openstack_cli_exists is succeeded
  47. - ( stack_create_dry_run_output is failed or
  48. stack_update_dry_run_output is failed)
  49. - name: Handle the Stack (create/delete)
  50. ignore_errors: True
  51. register: stack_create
  52. until: stack_create is not failed
  53. retries: 20
  54. delay: 5
  55. os_stack:
  56. name: "{{ openshift_openstack_stack_name }}"
  57. state: "{{ openshift_openstack_stack_state }}"
  58. template: "{{ stack_template_path | default(omit) }}"
  59. wait: yes
  60. - name: get errors in stack creation, if any
  61. command: openstack stack failures list {{ openshift_openstack_stack_name }}
  62. register: stack_create_failures
  63. when:
  64. - openstack_cli_exists is succeeded
  65. - stack_create is failed
  66. - name: show errors in stack creation, if any
  67. debug: var=stack_create_failures
  68. when:
  69. - openstack_cli_exists is succeeded
  70. - stack_create is failed
  71. - fail:
  72. msg: Stack creation failed
  73. when:
  74. - stack_create is failed
  75. - name: Add the new nodes to the inventory
  76. meta: refresh_inventory
  77. - name: Legacy LBaaSv2 SG OpenShift API correction
  78. os_port:
  79. state: present
  80. name: "{{ openshift_openstack_api_lb_port_id }}"
  81. security_groups:
  82. - "{{ openshift_openstack_api_lb_sg_id }}"
  83. when:
  84. - openshift_openstack_api_lb_provider|default(None) == "haproxy"
  85. - name: CleanUp
  86. include_tasks: cleanup.yml
  87. when:
  88. - openshift_openstack_stack_state == 'present'
  89. - name: Create the Cinder volume for OpenShift Registry
  90. include_tasks: create-registry-volume.yml
  91. when:
  92. - groups.openstack_infra_nodes is defined
  93. - groups.openstack_infra_nodes.0 is defined
  94. - hostvars[groups.openstack_infra_nodes.0].openshift_hosted_registry_storage_volume_name is defined
  95. - hostvars[groups.openstack_infra_nodes.0].openshift_hosted_registry_storage_volume_size is defined
  96. - hostvars[groups.openstack_infra_nodes.0].openshift_hosted_registry_storage_openstack_volumeID is not defined