docker_upgrade_check.yml 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. ---
  2. # This snippet determines if a Docker upgrade is required by checking the inventory
  3. # variables, the available packages, and sets l_docker_upgrade to True if so.
  4. - set_fact:
  5. docker_upgrade: True
  6. when: docker_upgrade is not defined
  7. - name: Check if Docker is installed
  8. command: rpm -q docker
  9. args:
  10. warn: no
  11. register: pkg_check
  12. failed_when: pkg_check.rc > 1
  13. changed_when: no
  14. - name: Get current version of Docker
  15. command: "{{ repoquery_installed }} --qf '%{version}' docker"
  16. register: curr_docker_version
  17. retries: 4
  18. until: curr_docker_version is succeeded
  19. changed_when: false
  20. when: not openshift_is_atomic | bool
  21. - name: Get latest available version of Docker
  22. command: >
  23. {{ repoquery_cmd }} --qf '%{version}' "docker"
  24. register: avail_docker_version
  25. retries: 4
  26. until: avail_docker_version is succeeded
  27. # Don't expect docker rpm to be available on hosts that don't already have it installed:
  28. when:
  29. - not openshift_is_atomic | bool
  30. - pkg_check.rc == 0
  31. failed_when: false
  32. changed_when: false
  33. - name: Required docker version not available (non-atomic)
  34. fail:
  35. msg: "This playbook requires access to Docker {{ l_required_docker_version }} or later"
  36. # Disable the 1.12 requirement if the user set a specific Docker version
  37. when:
  38. - not openshift_is_atomic | bool
  39. - docker_version is not defined
  40. - docker_upgrade | bool
  41. - pkg_check.rc == 0
  42. - avail_docker_version.stdout == "" or avail_docker_version.stdout is version(l_required_docker_version,'<')
  43. # Default l_docker_upgrade to False, we'll set to True if an upgrade is required:
  44. - set_fact:
  45. l_docker_upgrade: False
  46. # Make sure a docker_version is set if none was requested:
  47. - set_fact:
  48. docker_version: "{{ avail_docker_version.stdout }}"
  49. when:
  50. - not openshift_is_atomic | bool
  51. - pkg_check.rc == 0
  52. - docker_version is not defined
  53. - name: Flag for Docker upgrade if necessary
  54. set_fact:
  55. l_docker_upgrade: True
  56. when:
  57. - not openshift_is_atomic | bool
  58. - pkg_check.rc == 0
  59. - curr_docker_version.stdout is version(docker_version,'<')
  60. # Additional checks for Atomic hosts:
  61. - name: Determine available Docker
  62. shell: "rpm -q --queryformat '---\ncurr_version: %{VERSION}\navail_version: \n' docker"
  63. register: g_atomic_docker_version_result
  64. when: openshift_is_atomic | bool
  65. - set_fact:
  66. l_docker_version: "{{ g_atomic_docker_version_result.stdout | from_yaml }}"
  67. when: openshift_is_atomic | bool
  68. - name: Required docker version is unavailable (atomic)
  69. fail:
  70. msg: "This playbook requires access to Docker {{ l_required_docker_version }} or later"
  71. when:
  72. - openshift_is_atomic | bool
  73. - l_docker_version.avail_version | default(l_docker_version.curr_version, true) is version(l_required_docker_version,'<')