main.yml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. - assert:
  33. that:
  34. - "{{ openshift_image_tag|match('(^v?\\d+\\.\\d+\\.\\d+(-[\\w\\-\\.]*)?$)') }}"
  35. msg: "openshift_image_tag must be in the format v#.#.#[-optional.#]. Examples: v1.2.3, v3.5.1-alpha.1"
  36. when: openshift.common.deployment_type == 'origin'
  37. # Verifies that when the deployment type is openshift-enterprise the version:
  38. # - starts with a v
  39. # - Has at least 2 integers seperated by dots
  40. # It also allows for optional trailing data which:
  41. # - must start with a dash
  42. # - may contain numbers
  43. - assert:
  44. that:
  45. - "{{ openshift_image_tag|match('(^v\\d+\\.\\d+[\\.\\d+]*(-\\d+)?$)') }}"
  46. 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"
  47. when: openshift.common.deployment_type == 'openshift-enterprise'
  48. when:
  49. - openshift_image_tag is defined
  50. - openshift_image_tag != "latest"
  51. # Add a v to the start of the openshift_image_tag if one was not provided
  52. - set_fact:
  53. openshift_image_tag: "{{ 'v' + openshift_image_tag }}"
  54. when:
  55. - openshift_image_tag is defined
  56. - openshift_image_tag[0] != 'v'
  57. - openshift_image_tag != 'latest'
  58. - set_fact:
  59. openshift_pkg_version: "{{ '-' + openshift_pkg_version }}"
  60. when:
  61. - openshift_pkg_version is defined
  62. - openshift_pkg_version[0] != '-'
  63. # Make sure we copy this to a fact if given a var:
  64. - set_fact:
  65. openshift_version: "{{ openshift_version | string }}"
  66. when: openshift_version is defined
  67. # Protect the installed version by default unless explicitly told not to, or given an
  68. # openshift_version already.
  69. - name: Use openshift.common.version fact as version to configure if already installed
  70. set_fact:
  71. openshift_version: "{{ openshift.common.version }}"
  72. when:
  73. - openshift.common.version is defined
  74. - openshift_version is not defined
  75. - openshift_protect_installed_version | bool
  76. - name: Set openshift_version for rpm installation
  77. include: set_version_rpm.yml
  78. when: not is_containerized | bool
  79. - name: Set openshift_version for containerized installation
  80. include: set_version_containerized.yml
  81. when: is_containerized | bool
  82. # Warn if the user has provided an openshift_image_tag but is not doing a containerized install
  83. # NOTE: This will need to be modified/removed for future container + rpm installations work.
  84. - name: Warn if openshift_image_tag is defined when not doing a containerized install
  85. debug:
  86. msg: >
  87. openshift_image_tag is used for containerized installs. If you are trying to
  88. specify an image for a non-container install see oreg_url.
  89. when:
  90. - not is_containerized | bool
  91. - openshift_image_tag is defined
  92. # At this point we know openshift_version is set appropriately. Now we set
  93. # openshift_image_tag and openshift_pkg_version, so all roles can always assume
  94. # each of this variables *will* be set correctly and can use them per their
  95. # intended purpose.
  96. - block:
  97. - debug:
  98. msg: "openshift_image_tag was not defined. Falling back to v{{ openshift_version }}"
  99. - set_fact:
  100. openshift_image_tag: v{{ openshift_version }}
  101. when: openshift_image_tag is not defined
  102. - block:
  103. - debug:
  104. msg: "openshift_pkg_version was not defined. Falling back to -{{ openshift_version }}"
  105. - set_fact:
  106. openshift_pkg_version: -{{ openshift_version }}
  107. when: openshift_pkg_version is not defined
  108. - fail:
  109. msg: openshift_version role was unable to set openshift_version
  110. when: openshift_version is not defined
  111. - fail:
  112. msg: openshift_version role was unable to set openshift_image_tag
  113. when: openshift_image_tag is not defined
  114. - fail:
  115. msg: openshift_version role was unable to set openshift_pkg_version
  116. when: openshift_pkg_version is not defined
  117. - fail:
  118. msg: "No OpenShift version available, please ensure your systems are fully registered and have access to appropriate yum repositories."
  119. when:
  120. - not is_containerized | bool
  121. - openshift_version == '0.0'
  122. # We can't map an openshift_release to full rpm version like we can with containers, make sure
  123. # the rpm version we looked up matches the release requested and error out if not.
  124. - fail:
  125. 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."
  126. when:
  127. - not is_containerized | bool
  128. - openshift_release is defined
  129. - not openshift_version.startswith(openshift_release) | bool
  130. # The end result of these three variables is quite important so make sure they are displayed and logged:
  131. - debug: var=openshift_release
  132. - debug: var=openshift_image_tag
  133. - debug: var=openshift_pkg_version