main.yml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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. # Make sure we copy this to a fact if given a var:
  52. - set_fact:
  53. openshift_version: "{{ openshift_version | string }}"
  54. when: openshift_version is defined
  55. # Protect the installed version by default unless explicitly told not to, or given an
  56. # openshift_version already.
  57. - name: Use openshift.common.version fact as version to configure if already installed
  58. set_fact:
  59. openshift_version: "{{ openshift.common.version }}"
  60. when:
  61. - openshift.common.version is defined
  62. - openshift_version is not defined
  63. - openshift_protect_installed_version | bool
  64. - name: Set openshift_version for rpm installation
  65. include: set_version_rpm.yml
  66. when: not is_containerized | bool
  67. - name: Set openshift_version for containerized installation
  68. include: set_version_containerized.yml
  69. when: is_containerized | bool
  70. # Warn if the user has provided an openshift_image_tag but is not doing a containerized install
  71. # NOTE: This will need to be modified/removed for future container + rpm installations work.
  72. - name: Warn if openshift_image_tag is defined when not doing a containerized install
  73. debug:
  74. msg: >
  75. openshift_image_tag is used for containerized installs. If you are trying to
  76. specify an image for a non-container install see oreg_url.
  77. when:
  78. - not is_containerized | bool
  79. - openshift_image_tag is defined
  80. # At this point we know openshift_version is set appropriately. Now we set
  81. # openshift_image_tag and openshift_pkg_version, so all roles can always assume
  82. # each of this variables *will* be set correctly and can use them per their
  83. # intended purpose.
  84. - block:
  85. - debug:
  86. msg: "openshift_image_tag was not defined. Falling back to v{{ openshift_version }}"
  87. - set_fact:
  88. openshift_image_tag: v{{ openshift_version }}
  89. when: openshift_image_tag is not defined
  90. - block:
  91. - debug:
  92. msg: "openshift_pkg_version was not defined. Falling back to -{{ openshift_version }}"
  93. - set_fact:
  94. openshift_pkg_version: -{{ openshift_version }}
  95. when: openshift_pkg_version is not defined
  96. - fail:
  97. msg: openshift_version role was unable to set openshift_version
  98. when: openshift_version is not defined
  99. - fail:
  100. msg: openshift_version role was unable to set openshift_image_tag
  101. when: openshift_image_tag is not defined
  102. - fail:
  103. msg: openshift_version role was unable to set openshift_pkg_version
  104. when: openshift_pkg_version is not defined
  105. - fail:
  106. msg: "No OpenShift version available, please ensure your systems are fully registered and have access to appropriate yum repositories."
  107. when:
  108. - not is_containerized | bool
  109. - openshift_version == '0.0'
  110. # We can't map an openshift_release to full rpm version like we can with containers, make sure
  111. # the rpm version we looked up matches the release requested and error out if not.
  112. - fail:
  113. 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."
  114. when:
  115. - not is_containerized | bool
  116. - openshift_release is defined
  117. - not openshift_version.startswith(openshift_release) | bool
  118. # The end result of these three variables is quite important so make sure they are displayed and logged:
  119. - debug: var=openshift_release
  120. - debug: var=openshift_image_tag
  121. - debug: var=openshift_pkg_version