main.yml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. - set_fact:
  6. is_containerized: "{{ openshift.common.is_containerized | default(False) | bool }}"
  7. # Does the host already have an image tag fact, used to determine if it's a new node
  8. # in non-upgrade scenarios:
  9. has_image_tag_fact: "{{ hostvars[inventory_hostname].openshift.docker.openshift_image_tag is defined }}"
  10. - name: Set version when containerized
  11. command: >
  12. docker run --rm {{ openshift.common.cli_image }} version
  13. register: cli_image_version
  14. when: is_containerized | bool and openshift_image_tag is not defined and (upgrading | bool or not has_image_tag_fact | bool)
  15. # Use the pre-existing image tag from system facts if present, and we're not upgrading.
  16. # Ignores explicit openshift_image_tag if it's in the inventory, as this isn't an upgrade.
  17. - set_fact:
  18. l_image_tag: "{{ hostvars[inventory_hostname].openshift.docker.openshift_image_tag }}"
  19. when: is_containerized | bool and not upgrading | bool and has_image_tag_fact | bool
  20. - set_fact:
  21. l_image_tag: "{{ cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0:2] | join('-') if openshift.common.deployment_type == 'origin' else
  22. cli_image_version.stdout_lines[0].split(' ')[1].split('-')[0] }}"
  23. when: is_containerized | bool and openshift_image_tag is not defined and (upgrading | bool or not has_image_tag_fact | bool)
  24. - set_fact:
  25. l_image_tag: "{{ openshift_image_tag }}"
  26. when: is_containerized | bool and openshift_image_tag is defined and (upgrading | bool or not has_image_tag_fact | bool)
  27. - name: Set post docker install facts
  28. openshift_facts:
  29. role: "{{ item.role }}"
  30. local_facts: "{{ item.local_facts }}"
  31. with_items:
  32. - role: docker
  33. local_facts:
  34. openshift_image_tag: "{{ l_image_tag | default(None) }}"
  35. openshift_version: "{{ l_image_tag.split('-')[0] | oo_image_tag_to_rpm_version if l_image_tag is defined else '' }}"
  36. when: is_containerized | bool