main.yml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. # RPM openshift_version setup:
  12. - debug: msg="{{ openshift_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }}"
  13. - name: Lookup latest OpenShift rpm version if none specified
  14. action: "{{ ansible_pkg_mgr }} name={{ openshift.common.service_type }}{{ openshift_version | default('') | oo_image_tag_to_rpm_version(include_dash=True) }} state=present"
  15. when: not is_containerized | bool and openshift_version is not defined
  16. - name: Reload facts to pick up version
  17. openshift_facts:
  18. when: not is_containerized | bool and openshift_version is not defined
  19. - set_fact:
  20. openshift_version: "{{ openshift.common.version }}"
  21. when: not is_containerized | bool and openshift_version is not defined
  22. # TODO: What to do if openshift_version = 3.2 for rpm based installs?
  23. # Containerized openshift_version setup:
  24. - name: Lookup latest containerized OpenShift version if none specified
  25. command: >
  26. docker run --rm {{ openshift.common.cli_image }}:latest version
  27. register: cli_image_version
  28. when: is_containerized | bool and openshift_version is not defined
  29. - debug: var=cli_image_version
  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: is_containerized | bool and openshift_version is not defined
  33. # If we got an openshift_version like "3.2", lookup the latest 3.2 container version
  34. # and use that value instead.
  35. - name: Lookup specific OpenShift version if generic release specified
  36. command: >
  37. docker run --rm {{ openshift.common.cli_image }}:v{{ openshift_version }} version
  38. register: cli_image_version
  39. when: is_containerized | bool and openshift_version is defined and openshift_version.split('.') | length == 2
  40. - set_fact:
  41. 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:] }}"
  42. when: is_containerized | bool and openshift_version is defined and openshift_version.split('.') | length == 2
  43. - debug: var=openshift_version