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 should always just be "3.2" or "3.2.0.44"
  6. openshift_version: "{{ openshift_image_tag[1:].split('-')[0] }}"
  7. when: openshift_image_tag is defined and openshift_version is not defined
  8. - name: Set containerized version to configure if openshift_release specified
  9. set_fact:
  10. openshift_version: "{{ openshift_release }}"
  11. when: openshift_release is defined and openshift_version is not defined
  12. - name: Lookup latest containerized version if no version specified
  13. command: >
  14. docker run --rm {{ openshift.common.cli_image }}:latest version
  15. register: cli_image_version
  16. when: openshift_version is not defined
  17. - debug: var=cli_image_version
  18. - set_fact:
  19. 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:] }}"
  20. when: openshift_version is not defined
  21. - debug: msg="{{ openshift_version }}"
  22. # If we got an openshift_version like "3.2", lookup the latest 3.2 container version
  23. # and use that value instead.
  24. - name: Set precise containerized version to configure if openshift_release specified
  25. command: >
  26. docker run --rm {{ openshift.common.cli_image }}:v{{ openshift_version }} version
  27. register: cli_image_version
  28. when: openshift_version is defined and openshift_version.split('.') | length == 2
  29. - set_fact:
  30. 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:] }}"
  31. when: openshift_version is defined and openshift_version.split('.') | length == 2