main.yml 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. ---
  2. # Determine the openshift_version to configure if none has been specified or set previously.
  3. - set_fact:
  4. is_containerized: "{{ openshift.common.is_containerized | default(False) | bool }}"
  5. # Block attempts to install origin without specifying some kind of version information.
  6. # This is because the latest tags for origin are usually alpha builds, which should not
  7. # be used by default. Users must indicate what they want.
  8. - fail:
  9. msg: "Must specify openshift_release or openshift_image_tag in inventory to install origin. (suggestion: add openshift_release=\"1.2\" to inventory)"
  10. when:
  11. - is_containerized | bool
  12. - openshift.common.deployment_type == 'origin'
  13. - openshift_release is not defined
  14. - openshift_image_tag is not defined
  15. # Normalize some values that we need in a certain format that might be confusing:
  16. - set_fact:
  17. openshift_release: "{{ openshift_release[1:] }}"
  18. when:
  19. - openshift_release is defined
  20. - openshift_release[0] == 'v'
  21. - set_fact:
  22. openshift_release: "{{ openshift_release | string }}"
  23. when: openshift_release is defined
  24. # Verify that the image tag is in a valid format
  25. - block:
  26. # Verifies that when the deployment type is origin the version:
  27. # - starts with a v
  28. # - Has 3 integers seperated by dots
  29. # It also allows for optional trailing data which:
  30. # - must start with a dash
  31. # - may contain numbers, letters, dashes and dots.
  32. - name: Verify Origin openshift_image_tag is valid
  33. assert:
  34. that:
  35. - "{{ openshift_image_tag|match('(^v?\\d+\\.\\d+\\.\\d+(-[\\w\\-\\.]*)?$)') }}"
  36. msg: "openshift_image_tag must be in the format v#.#.#[-optional.#]. Examples: v1.2.3, v3.5.1-alpha.1"
  37. when: openshift.common.deployment_type == 'origin'
  38. # Verifies that when the deployment type is openshift-enterprise the version:
  39. # - starts with a v
  40. # - Has at least 2 integers seperated by dots
  41. # It also allows for optional trailing data which:
  42. # - must start with a dash
  43. # - may contain numbers
  44. - name: Verify Enterprise openshift_image_tag is valid
  45. assert:
  46. that:
  47. - "{{ openshift_image_tag|match('(^v\\d+\\.\\d+[\\.\\d+]*(-\\d+)?$)') }}"
  48. msg: "openshift_image_tag must be in the format v#.#[.#[.#]]. Examples: v1.2, v3.4.1, v3.5.1.3, v1.2-1, v1.2.3-4"
  49. when: openshift.common.deployment_type == 'openshift-enterprise'
  50. when:
  51. - openshift_image_tag is defined
  52. - openshift_image_tag != "latest"
  53. # Make sure we copy this to a fact if given a var:
  54. - set_fact:
  55. openshift_version: "{{ openshift_version | string }}"
  56. when: openshift_version is defined
  57. # Protect the installed version by default unless explicitly told not to, or given an
  58. # openshift_version already.
  59. - name: Use openshift.common.version fact as version to configure if already installed
  60. set_fact:
  61. openshift_version: "{{ openshift.common.version }}"
  62. when:
  63. - openshift.common.version is defined
  64. - openshift_version is not defined
  65. - openshift_protect_installed_version | bool
  66. - name: Set openshift_version for rpm installation
  67. include: set_version_rpm.yml
  68. when: not is_containerized | bool
  69. - name: Set openshift_version for containerized installation
  70. include: set_version_containerized.yml
  71. when: is_containerized | bool
  72. # Warn if the user has provided an openshift_image_tag but is not doing a containerized install
  73. # NOTE: This will need to be modified/removed for future container + rpm installations work.
  74. - name: Warn if openshift_image_tag is defined when not doing a containerized install
  75. debug:
  76. msg: >
  77. openshift_image_tag is used for containerized installs. If you are trying to
  78. specify an image for a non-container install see oreg_url.
  79. when:
  80. - not is_containerized | bool
  81. - openshift_image_tag is defined
  82. # At this point we know openshift_version is set appropriately. Now we set
  83. # openshift_image_tag and openshift_pkg_version, so all roles can always assume
  84. # each of this variables *will* be set correctly and can use them per their
  85. # intended purpose.
  86. - block:
  87. - debug:
  88. msg: "openshift_image_tag was not defined. Falling back to v{{ openshift_version }}"
  89. - set_fact:
  90. openshift_image_tag: v{{ openshift_version }}
  91. when: openshift_image_tag is not defined
  92. - block:
  93. - debug:
  94. msg: "openshift_pkg_version was not defined. Falling back to -{{ openshift_version }}"
  95. - set_fact:
  96. openshift_pkg_version: -{{ openshift_version }}
  97. when: openshift_pkg_version is not defined
  98. - fail:
  99. msg: openshift_version role was unable to set openshift_version
  100. when: openshift_version is not defined
  101. - fail:
  102. msg: openshift_version role was unable to set openshift_image_tag
  103. when: openshift_image_tag is not defined
  104. - fail:
  105. msg: openshift_version role was unable to set openshift_pkg_version
  106. when: openshift_pkg_version is not defined
  107. - fail:
  108. msg: "No OpenShift version available, please ensure your systems are fully registered and have access to appropriate yum repositories."
  109. when:
  110. - not is_containerized | bool
  111. - openshift_version == '0.0'
  112. # We can't map an openshift_release to full rpm version like we can with containers, make sure
  113. # the rpm version we looked up matches the release requested and error out if not.
  114. - fail:
  115. msg: "Detected OpenShift version {{ openshift_version }} does not match requested openshift_release {{ openshift_release }}. You may need to adjust your yum repositories, inventory, or run the appropriate OpenShift upgrade playbook."
  116. when:
  117. - not is_containerized | bool
  118. - openshift_release is defined
  119. - not openshift_version.startswith(openshift_release) | bool
  120. # The end result of these three variables is quite important so make sure they are displayed and logged:
  121. - debug: var=openshift_release
  122. - debug: var=openshift_image_tag
  123. - debug: var=openshift_pkg_version