set_version_rpm.yml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. ---
  2. - name: Set rpm version to configure if openshift_pkg_version specified
  3. set_fact:
  4. # Expects a leading "-" in inventory, strip it off here, and remove trailing release,
  5. openshift_version: "{{ openshift_pkg_version[1:].split('-')[0] }}"
  6. when: openshift_pkg_version is defined and openshift_version is not defined
  7. # if {{ openshift.common.service_type}}-excluder is enabled,
  8. # the repoquery for {{ openshift.common.service_type}} will not work.
  9. # Thus, create a temporary yum,conf file where exclude= is set to an empty list
  10. - name: Create temporary yum.conf file
  11. command: mktemp -d /tmp/yum.conf.XXXXXX
  12. register: yum_conf_temp_file_result
  13. - set_fact:
  14. yum_conf_temp_file: "{{yum_conf_temp_file_result.stdout}}/yum.conf"
  15. - name: Copy yum.conf into the temporary file
  16. copy:
  17. src: /etc/yum.conf
  18. dest: "{{ yum_conf_temp_file }}"
  19. remote_src: True
  20. - name: Clear the exclude= list in the temporary yum.conf
  21. lineinfile:
  22. # since ansible 2.3 s/dest/path
  23. dest: "{{ yum_conf_temp_file }}"
  24. regexp: '^exclude='
  25. line: 'exclude='
  26. - name: Gather common package version
  27. command: >
  28. {{ repoquery_cmd }} --config "{{ yum_conf_temp_file }}" --qf '%{version}' "{{ openshift.common.service_type}}"
  29. register: common_version
  30. failed_when: false
  31. changed_when: false
  32. when: openshift_version is not defined
  33. - name: Delete the temporary yum.conf
  34. file:
  35. path: "{{ yum_conf_temp_file_result.stdout }}"
  36. state: absent
  37. - set_fact:
  38. openshift_version: "{{ common_version.stdout | default('0.0', True) }}"
  39. when: openshift_version is not defined