main.yml 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. # Add a v to the start of the openshift_image_tag if one was not provided
  25. - set_fact:
  26. openshift_image_tag: "{{ 'v' + openshift_image_tag }}"
  27. when:
  28. - openshift_image_tag is defined
  29. - openshift_image_tag[0] != 'v'
  30. - openshift_image_tag != 'latest'
  31. - set_fact:
  32. openshift_pkg_version: "{{ '-' + openshift_pkg_version }}"
  33. when:
  34. - openshift_pkg_version is defined
  35. - openshift_pkg_version[0] != '-'
  36. # Make sure we copy this to a fact if given a var:
  37. - set_fact:
  38. openshift_version: "{{ openshift_version | string }}"
  39. when: openshift_version is defined
  40. # Protect the installed version by default unless explicitly told not to, or given an
  41. # openshift_version already.
  42. - name: Use openshift.common.version fact as version to configure if already installed
  43. set_fact:
  44. openshift_version: "{{ openshift.common.version }}"
  45. when:
  46. - openshift.common.version is defined
  47. - openshift_version is not defined
  48. - openshift_protect_installed_version | bool
  49. - name: Set openshift_version for rpm installation
  50. include: set_version_rpm.yml
  51. when: not is_containerized | bool
  52. - name: Set openshift_version for containerized installation
  53. include: set_version_containerized.yml
  54. when: is_containerized | bool
  55. # At this point we know openshift_version is set appropriately. Now we set
  56. # openshift_image_tag and openshift_pkg_version, so all roles can always assume
  57. # each of this variables *will* be set correctly and can use them per their
  58. # intended purpose.
  59. - set_fact:
  60. openshift_image_tag: v{{ openshift_version }}
  61. when: openshift_image_tag is not defined
  62. - set_fact:
  63. openshift_pkg_version: -{{ openshift_version }}
  64. when: openshift_pkg_version is not defined
  65. - fail:
  66. msg: openshift_version role was unable to set openshift_version
  67. when: openshift_version is not defined
  68. - fail:
  69. msg: openshift_version role was unable to set openshift_image_tag
  70. when: openshift_image_tag is not defined
  71. - fail:
  72. msg: openshift_version role was unable to set openshift_pkg_version
  73. when: openshift_pkg_version is not defined
  74. - fail:
  75. msg: "No OpenShift version available, please ensure your systems are fully registered and have access to appropriate yum repositories."
  76. when:
  77. - not is_containerized | bool
  78. - openshift_version == '0.0'
  79. # We can't map an openshift_release to full rpm version like we can with containers, make sure
  80. # the rpm version we looked up matches the release requested and error out if not.
  81. - fail:
  82. 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."
  83. when:
  84. - not is_containerized | bool
  85. - openshift_release is defined
  86. - not openshift_version.startswith(openshift_release) | bool
  87. # The end result of these three variables is quite important so make sure they are displayed and logged:
  88. - debug: var=openshift_release
  89. - debug: var=openshift_image_tag
  90. - debug: var=openshift_pkg_version