set_version_containerized.yml 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. ---
  2. - set_fact:
  3. l_use_crio_only: "{{ openshift_use_crio_only | default(false) }}"
  4. - name: Set containerized version to configure if openshift_image_tag specified
  5. set_fact:
  6. # Expects a leading "v" in inventory, strip it off here unless
  7. # openshift_image_tag=latest
  8. openshift_version: "{{ openshift_image_tag[1:].split('-')[0] if openshift_image_tag != 'latest' else openshift_image_tag }}"
  9. when:
  10. - openshift_image_tag is defined
  11. - openshift_version is not defined
  12. - name: Set containerized version to configure if openshift_release specified
  13. set_fact:
  14. openshift_version: "{{ openshift_release }}"
  15. when:
  16. - openshift_release is defined
  17. - openshift_version is not defined
  18. - name: Lookup latest containerized version if no version specified
  19. command: >
  20. docker run --rm {{ openshift_cli_image }}:latest version
  21. register: cli_image_version
  22. when:
  23. - openshift_version is not defined
  24. - not l_use_crio_only
  25. # Origin latest = pre-release version (i.e. v1.3.0-alpha.1-321-gb095e3a)
  26. - set_fact:
  27. openshift_version: "{{ (cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0:2] | join('-'))[1:] }}"
  28. when:
  29. - openshift_version is not defined
  30. - openshift.common.deployment_type == 'origin'
  31. - cli_image_version.stdout_lines[0].split('-') | length > 1
  32. - not l_use_crio_only
  33. - set_fact:
  34. openshift_version: "{{ cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0][1:] }}"
  35. when: openshift_version is not defined
  36. # If we got an openshift_version like "3.2", lookup the latest 3.2 container version
  37. # and use that value instead.
  38. - name: Set precise containerized version to configure if openshift_release specified
  39. command: >
  40. docker run --rm {{ openshift_cli_image }}:v{{ openshift_version }} version
  41. register: cli_image_version
  42. when:
  43. - openshift_version is defined
  44. - openshift_version.split('.') | length == 2
  45. - not l_use_crio_only
  46. - set_fact:
  47. 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:] }}"
  48. when:
  49. - openshift_version is defined
  50. - openshift_version.split('.') | length == 2
  51. - not l_use_crio_only
  52. # TODO: figure out a way to check for the openshift_version when using CRI-O.
  53. # We should do that using the images in the ostree storage so we don't have
  54. # to pull them again.
  55. # We finally have the specific version. Now we clean up any strange
  56. # dangly +c0mm1t-offset tags in the version. See also,
  57. # openshift_facts.py
  58. - set_fact:
  59. openshift_version: "{{ openshift_version | oo_chomp_commit_offset }}"