version_detect.yml 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. ---
  2. - block:
  3. - name: Record RPM based etcd version
  4. command: rpm -qa --qf '%{version}' etcd\*
  5. args:
  6. warn: no
  7. register: etcd_rpm_version
  8. failed_when: false
  9. # AUDIT:changed_when: `false` because we are only inspecting
  10. # state, not manipulating anything
  11. changed_when: false
  12. - debug:
  13. msg: "Etcd rpm version {{ etcd_rpm_version.stdout }} detected"
  14. when:
  15. - not openshift_is_containerized | bool
  16. - block:
  17. - name: Record containerized etcd version (docker)
  18. command: docker exec etcd_container rpm -qa --qf '%{version}' etcd\*
  19. register: etcd_container_version_docker
  20. failed_when: false
  21. # AUDIT:changed_when: `false` because we are only inspecting
  22. # state, not manipulating anything
  23. changed_when: false
  24. when:
  25. - not l_is_etcd_system_container | bool and not l_etcd_static_pod | bool
  26. # Given a register variables is set even if the whwen condition
  27. # is false, we need to set etcd_container_version separately
  28. - set_fact:
  29. etcd_container_version: "{{ etcd_container_version_docker.stdout }}"
  30. when:
  31. - not l_is_etcd_system_container | bool and not l_etcd_static_pod | bool
  32. - name: Record containerized etcd version (runc)
  33. command: runc exec etcd rpm -qa --qf '%{version}' etcd\*
  34. register: etcd_container_version_runc
  35. failed_when: false
  36. # AUDIT:changed_when: `false` because we are only inspecting
  37. # state, not manipulating anything
  38. changed_when: false
  39. when:
  40. - l_is_etcd_system_container | bool and not l_etcd_static_pod | bool
  41. # Given a register variables is set even if the whwen condition
  42. # is false, we need to set etcd_container_version separately
  43. - set_fact:
  44. etcd_container_version: "{{ etcd_container_version_runc.stdout }}"
  45. when:
  46. - l_is_etcd_system_container | bool and not l_etcd_static_pod
  47. - name: Record etcd version (static pod)
  48. command: /usr/local/bin/master-exec etcd etcd rpm -qa --qf '%{version}' etcd\*
  49. register: etcd_container_version_static_pod
  50. failed_when: false
  51. # AUDIT:changed_when: `false` because we are only inspecting
  52. # state, not manipulating anything
  53. changed_when: false
  54. when:
  55. - l_etcd_static_pod | bool
  56. # Given a register variables is set even if the whwen condition
  57. # is false, we need to set etcd_container_version separately
  58. - set_fact:
  59. etcd_container_version: "{{ etcd_container_version_static_pod.stdout }}"
  60. when:
  61. - l_etcd_static_pod | bool
  62. - "'stdout' in etcd_container_version_static_pod"
  63. - debug:
  64. msg: "Etcd containerized version {{ etcd_container_version }} detected"
  65. when: etcd_container_version is defined
  66. when:
  67. - openshift_is_containerized | bool