check-prerequisites.yml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. ---
  2. # Check ansible
  3. - name: Check Ansible version
  4. assert:
  5. that: >
  6. (ansible_version.major == 2 and ansible_version.minor >= 3) or
  7. (ansible_version.major > 2)
  8. msg: "Ansible version must be at least 2.3"
  9. # Check shade
  10. - name: Try to import python module shade
  11. command: python -c "import shade"
  12. ignore_errors: yes
  13. register: shade_result
  14. - name: Check if shade is installed
  15. assert:
  16. that: 'shade_result.rc == 0'
  17. msg: "Python module shade is not installed"
  18. # Gather Neutron extension facts
  19. - name: Check for Neutron trunk support
  20. os_network_extensions:
  21. # Gather OpenStack service catalog endpoint facts
  22. - name: Check for cloud service catalog endpoints
  23. os_service_catalog:
  24. # Check trunk support
  25. - fail:
  26. msg: "Trunk ports enabled but support lacking in Neutron"
  27. when: (use_trunk_ports | default(False)) and
  28. ('trunk' not in openstack_network_extensions)
  29. # Check jmespath
  30. - name: Try to import python module shade
  31. command: python -c "import jmespath"
  32. ignore_errors: yes
  33. register: jmespath_result
  34. - name: Check if jmespath is installed
  35. assert:
  36. that: 'jmespath_result.rc == 0'
  37. msg: "Python module jmespath is not installed"
  38. # Check python-dns
  39. - name: Try to import python DNS module
  40. command: python -c "import dns"
  41. ignore_errors: yes
  42. register: pythondns_result
  43. when: openshift_openstack_external_nsupdate_keys is defined
  44. - name: Check if python-dns is installed
  45. assert:
  46. that: 'pythondns_result.rc == 0'
  47. msg: "Python module python-dns is not installed"
  48. when: openshift_openstack_external_nsupdate_keys is defined
  49. # Check jinja2
  50. - name: Try to import jinja2 module
  51. command: python -c "import jinja2"
  52. ignore_errors: yes
  53. register: jinja_result
  54. - name: Check if jinja2 is installed
  55. assert:
  56. that: 'jinja_result.rc == 0'
  57. msg: "Python module jinja2 is not installed"
  58. # Check network name
  59. - name: Try to get network facts
  60. os_networks_facts:
  61. name: "{{ openshift_openstack_external_network_name }}"
  62. register: network_result
  63. when: not openshift_openstack_provider_network_name|default(None)
  64. - name: Check that network is available
  65. assert:
  66. that: "network_result.ansible_facts.openstack_networks"
  67. msg: "Network {{ openshift_openstack_external_network_name }} is not available"
  68. when: not openshift_openstack_provider_network_name|default(None)
  69. - name: Get subnet facts when using a custom subnet
  70. os_subnets_facts:
  71. name: "{{ openshift_openstack_node_subnet_name }}"
  72. register: subnet_result
  73. when: openshift_openstack_node_subnet_name is defined
  74. - name: Set custom network id
  75. set_fact:
  76. openshift_openstack_node_network_id: "{{ subnet_result.ansible_facts.openstack_subnets[0].network_id }}"
  77. when: openshift_openstack_node_subnet_name is defined
  78. - name: Set custom subnet id
  79. set_fact:
  80. openshift_openstack_node_subnet_id: "{{ subnet_result.ansible_facts.openstack_subnets[0].id }}"
  81. when: openshift_openstack_node_subnet_name is defined
  82. - name: Set custom subnet cidr
  83. set_fact:
  84. openshift_openstack_subnet_cidr: "{{ subnet_result.ansible_facts.openstack_subnets[0].cidr }}"
  85. when: openshift_openstack_node_subnet_name is defined
  86. # TODO ltomasbo: there is no Ansible module for getting router facts
  87. - name: Get custom router id
  88. command: >
  89. python -c 'import shade; cloud = shade.openstack_cloud();
  90. print cloud.get_router("{{ openshift_openstack_router_name }}").id'
  91. register: router_info
  92. when: openshift_openstack_router_name is defined
  93. - name: Set custom router id
  94. set_fact:
  95. openshift_openstack_router_id: "{{ router_info.stdout }}"
  96. when: openshift_openstack_router_name is defined
  97. # Check keypair
  98. # TODO kpilatov: there is no Ansible module for getting OS keypairs
  99. # (os_keypair is not suitable for this)
  100. # this method does not force python-openstackclient dependency
  101. - name: Try to show keypair
  102. command: >
  103. python -c 'import shade; cloud = shade.openstack_cloud();
  104. exit(cloud.get_keypair("{{ openshift_openstack_keypair_name }}") is None)'
  105. ignore_errors: yes
  106. register: key_result
  107. - name: Check that keypair is available
  108. assert:
  109. that: 'key_result.rc == 0'
  110. msg: "Keypair {{ openshift_openstack_keypair_name }} is not available"
  111. # Check flavors and images
  112. - include_tasks: image-and-flavor-check.yml
  113. with_items:
  114. - { image: "{{ openshift_openstack_default_image_name }}", flavor: "{{ openshift_openstack_default_flavor }}" }
  115. - { image: "{{ openshift_openstack_master_image }}", flavor: "{{ openshift_openstack_master_flavor }}" }
  116. - { image: "{{ openshift_openstack_infra_image }}", flavor: "{{ openshift_openstack_infra_flavor }}" }
  117. - { image: "{{ openshift_openstack_cns_image }}", flavor: "{{ openshift_openstack_cns_flavor }}" }
  118. - { image: "{{ openshift_openstack_node_image }}", flavor: "{{ openshift_openstack_node_flavor }}" }
  119. - { image: "{{ openshift_openstack_lb_image }}", flavor: "{{ openshift_openstack_lb_flavor }}" }
  120. - { image: "{{ openshift_openstack_etcd_image }}", flavor: "{{ openshift_openstack_etcd_flavor }}" }
  121. - name: Check Load Balancer options
  122. fail:
  123. msg: >
  124. Only one of `openshift_openstack_use_lbaas_load_balancer` and
  125. `openshift_openstack_use_vm_load_balancer` can be true at a time.
  126. when:
  127. - openshift_openstack_use_lbaas_load_balancer
  128. - openshift_openstack_use_vm_load_balancer
  129. - name: Check LBaaS Load Balancer providers
  130. fail:
  131. msg: >
  132. Your configured openshift_openstack_lbaasv2_provider is not supported
  133. by your cloud.
  134. when: (openshift_openstack_use_lbaas_load_balancer and openshift_openstack_lbaasv2_provider == 'Neutron::LBaaS' and 'lbaasv2' not in openstack_network_extensions) or
  135. (openshift_openstack_use_lbaas_load_balancer and openshift_openstack_lbaasv2_provider == 'Octavia' and 'load-balancer' not in openstack_service_catalog)
  136. - name: Verify the nsupdate zone is a subset of the full cluster domain
  137. fail:
  138. msg: >
  139. The `openshift_openstack_nsupdate_zone` ({{ openshift_openstack_nsupdate_zone }})
  140. must be a substring of `openshift_openstack_full_dns_domain ({{ openshift_openstack_full_dns_domain }})`
  141. when:
  142. - openshift_openstack_nsupdate_zone is defined
  143. - openshift_openstack_full_dns_domain is defined
  144. - openshift_openstack_full_dns_domain is not match("(.*\.)*" + openshift_openstack_nsupdate_zone + "$")