set_version_containerized.yml 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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:
  5. openshift_version: "{{ openshift_image_tag[1:].split('-')[0] }}"
  6. when: openshift_image_tag is defined and openshift_version is not defined
  7. - name: Set containerized version to configure if openshift_release specified
  8. set_fact:
  9. openshift_version: "{{ openshift_release }}"
  10. when: openshift_release is defined and openshift_version is not defined
  11. - name: Lookup latest containerized version if no version specified
  12. command: >
  13. docker run --rm {{ openshift.common.cli_image }}:latest version
  14. register: cli_image_version
  15. when: openshift_version is not defined
  16. # Origin latest = pre-release version (i.e. v1.3.0-alpha.1-321-gb095e3a)
  17. - set_fact:
  18. openshift_version: "{{ (cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0:2] | join('-'))[1:] }}"
  19. when: openshift_version is not defined and openshift.common.deployment_type == 'origin' and cli_image_version.stdout_lines[0].split('-') | length > 1
  20. - set_fact:
  21. openshift_version: "{{ cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0][1:] }}"
  22. when: openshift_version is not defined
  23. # If we got an openshift_version like "3.2", lookup the latest 3.2 container version
  24. # and use that value instead.
  25. - name: Set precise containerized version to configure if openshift_release specified
  26. command: >
  27. docker run --rm {{ openshift.common.cli_image }}:v{{ openshift_version }} version
  28. register: cli_image_version
  29. when: openshift_version is defined and openshift_version.split('.') | length == 2
  30. - set_fact:
  31. 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:] }}"
  32. when: openshift_version is defined and openshift_version.split('.') | length == 2