main.yml 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. ---
  2. # It's important that we don't explicitly pull this image here. Otherwise we
  3. # could result in upgrading a preinstalled environment. We'll have to set
  4. # openshift_image_tag correctly for upgrades.
  5. # Determine openshift_version if none is set for this host, or if a generic "3.2"
  6. # is set, determine the more specific version number by either installing the latest
  7. # rpm, or pulling the v3.2 container and checking the resulting versions.
  8. - set_fact:
  9. is_containerized: "{{ openshift.common.is_containerized | default(False) | bool }}"
  10. - debug: var=openshift_version
  11. - debug: var=openshift_release
  12. - debug: var=openshift_pkg_version
  13. - debug: var=openshift_image_tag
  14. # RPM openshift_version setup:
  15. # TODO: support openshift_release here:
  16. - name: Determine rpm version to configure when openshift_pkg_version specified
  17. set_fact:
  18. # Expects a leading "-" in inventory, strip it off here, and ignore a trailing release,
  19. # openshift_version should always just be "3.2" or "3.2.0.44"
  20. openshift_version: "{{ openshift_pkg_version[1:].split('-')[0] }}"
  21. when: not is_containerized | bool and openshift_pkg_version is defined and openshift_version is not defined
  22. - name: Use openshift.common.version fact as version to configure if already installed
  23. set_fact:
  24. openshift_version: "{{ openshift.common.version }}"
  25. when: openshift.common.version is defined and openshift_version is not defined
  26. - name: Lookup latest OpenShift rpm version if none specified
  27. action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}{{ openshift_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }} state=present"
  28. when: not is_containerized | bool and openshift_version is not defined
  29. - name: Reload facts to pick up version
  30. openshift_facts:
  31. when: not is_containerized | bool and openshift_version is not defined
  32. - set_fact:
  33. openshift_version: "{{ openshift.common.version }}"
  34. when: not is_containerized | bool and openshift_version is not defined
  35. # Containerized openshift_version setup:
  36. - name: Determine version to configure if containerized and release specified
  37. set_fact:
  38. openshift_version: "{{ openshift_release }}"
  39. when: is_containerized | bool and openshift_release is defined and openshift_version is not defined
  40. - name: Determine container version to configure when openshift_image_tag specified
  41. set_fact:
  42. openshift_version: "{{ openshift_image_tag.split('v',1)[1] }}"
  43. when: is_containerized | bool and openshift_image_tag is defined and openshift_version is not defined
  44. - name: Lookup latest containerized OpenShift version if none specified
  45. command: >
  46. docker run --rm {{ openshift.common.cli_image }}:latest version
  47. register: cli_image_version
  48. when: is_containerized | bool and openshift_version is not defined
  49. - debug: var=cli_image_version
  50. - set_fact:
  51. openshift_version: "{{ cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0:2][1:] | join('-') if openshift.common.deployment_type == 'origin' else cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0][1:] }}"
  52. when: is_containerized | bool and openshift_version is not defined
  53. # If we got an openshift_version like "3.2", lookup the latest 3.2 container version
  54. # and use that value instead.
  55. - name: Lookup specific OpenShift version if generic release specified
  56. command: >
  57. docker run --rm {{ openshift.common.cli_image }}:v{{ openshift_version }} version
  58. register: cli_image_version
  59. when: is_containerized | bool and openshift_version is defined and openshift_version.split('.') | length == 2
  60. - set_fact:
  61. openshift_version: "{{ cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0:2][1:] | join('-') if openshift.common.deployment_type == 'origin' else cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0][1:] }}"
  62. when: is_containerized | bool and openshift_version is defined and openshift_version.split('.') | length == 2
  63. - debug: var=openshift_version