prerequisites.yml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. ---
  2. - hosts: localhost
  3. tasks:
  4. # Check ansible
  5. - name: Check Ansible version
  6. assert:
  7. that: >
  8. (ansible_version.major == 2 and ansible_version.minor >= 3) or
  9. (ansible_version.major > 2)
  10. msg: "Ansible version must be at least 2.3"
  11. # Check shade
  12. - name: Try to import python module shade
  13. command: python -c "import shade"
  14. ignore_errors: yes
  15. register: shade_result
  16. - name: Check if shade is installed
  17. assert:
  18. that: 'shade_result.rc == 0'
  19. msg: "Python module shade is not installed"
  20. # Check jmespath
  21. - name: Try to import python module shade
  22. command: python -c "import jmespath"
  23. ignore_errors: yes
  24. register: jmespath_result
  25. - name: Check if jmespath is installed
  26. assert:
  27. that: 'jmespath_result.rc == 0'
  28. msg: "Python module jmespath is not installed"
  29. # Check python-dns
  30. - name: Try to import python DNS module
  31. command: python -c "import dns"
  32. ignore_errors: yes
  33. register: pythondns_result
  34. - name: Check if python-dns is installed
  35. assert:
  36. that: 'pythondns_result.rc == 0'
  37. msg: "Python module python-dns is not installed"
  38. # Check jinja2
  39. - name: Try to import jinja2 module
  40. command: python -c "import jinja2"
  41. ignore_errors: yes
  42. register: jinja_result
  43. - name: Check if jinja2 is installed
  44. assert:
  45. that: 'jinja_result.rc == 0'
  46. msg: "Python module jinja2 is not installed"
  47. # Check Glance image
  48. - name: Try to get image facts
  49. os_image_facts:
  50. image: "{{ openstack_default_image_name }}"
  51. register: image_result
  52. - name: Check that image is available
  53. assert:
  54. that: "image_result.ansible_facts.openstack_image"
  55. msg: "Image {{ openstack_default_image_name }} is not available"
  56. # Check network name
  57. - name: Try to get network facts
  58. os_networks_facts:
  59. name: "{{ openstack_external_network_name }}"
  60. register: network_result
  61. when: not openstack_provider_network_name|default(None)
  62. - name: Check that network is available
  63. assert:
  64. that: "network_result.ansible_facts.openstack_networks"
  65. msg: "Network {{ openstack_external_network_name }} is not available"
  66. when: not openstack_provider_network_name|default(None)
  67. # Check keypair
  68. # TODO kpilatov: there is no Ansible module for getting OS keypairs
  69. # (os_keypair is not suitable for this)
  70. # this method does not force python-openstackclient dependency
  71. - name: Try to show keypair
  72. command: >
  73. python -c 'import shade; cloud = shade.openstack_cloud();
  74. exit(cloud.get_keypair("{{ openstack_ssh_public_key }}") is None)'
  75. ignore_errors: yes
  76. register: key_result
  77. - name: Check that keypair is available
  78. assert:
  79. that: 'key_result.rc == 0'
  80. msg: "Keypair {{ openstack_ssh_public_key }} is not available"
  81. # Check that custom images and flavors exist
  82. - hosts: localhost
  83. # Include variables that will be used by heat
  84. vars_files:
  85. - stack_params.yaml
  86. tasks:
  87. # Check that custom images are available
  88. - include: custom_image_check.yaml
  89. with_items:
  90. - "{{ openstack_master_image }}"
  91. - "{{ openstack_infra_image }}"
  92. - "{{ openstack_node_image }}"
  93. - "{{ openstack_lb_image }}"
  94. - "{{ openstack_etcd_image }}"
  95. - "{{ openstack_dns_image }}"
  96. loop_control:
  97. loop_var: image
  98. # Check that custom flavors are available
  99. - include: custom_flavor_check.yaml
  100. with_items:
  101. - "{{ master_flavor }}"
  102. - "{{ infra_flavor }}"
  103. - "{{ node_flavor }}"
  104. - "{{ lb_flavor }}"
  105. - "{{ etcd_flavor }}"
  106. - "{{ dns_flavor }}"
  107. loop_control:
  108. loop_var: flavor