set_version_rpm.yml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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:
  7. - openshift_pkg_version is defined
  8. - openshift_version is not defined
  9. # if {{ openshift.common.service_type}}-excluder is enabled,
  10. # the repoquery for {{ openshift.common.service_type}} will not work.
  11. # Thus, create a temporary yum,conf file where exclude= is set to an empty list
  12. - name: Create temporary yum.conf file
  13. command: mktemp -d /tmp/yum.conf.XXXXXX
  14. register: yum_conf_temp_file_result
  15. - set_fact:
  16. yum_conf_temp_file: "{{yum_conf_temp_file_result.stdout}}/yum.conf"
  17. - name: Copy yum.conf into the temporary file
  18. copy:
  19. src: /etc/yum.conf
  20. dest: "{{ yum_conf_temp_file }}"
  21. remote_src: True
  22. - name: Clear the exclude= list in the temporary yum.conf
  23. lineinfile:
  24. # since ansible 2.3 s/dest/path
  25. dest: "{{ yum_conf_temp_file }}"
  26. regexp: '^exclude='
  27. line: 'exclude='
  28. - name: Gather common package version
  29. command: >
  30. {{ repoquery_cmd }} --config "{{ yum_conf_temp_file }}" --qf '%{version}' "{{ openshift.common.service_type}}"
  31. register: common_version
  32. failed_when: false
  33. changed_when: false
  34. when: openshift_version is not defined
  35. - name: Delete the temporary yum.conf
  36. file:
  37. path: "{{ yum_conf_temp_file_result.stdout }}"
  38. state: absent
  39. - set_fact:
  40. openshift_version: "{{ common_version.stdout | default('0.0', True) }}"
  41. when: openshift_version is not defined