set_version_containerized.yml 2.6 KB

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