set_version_rpm.yml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. - name: Clear the exclude= list in the temporary yum.conf
  20. lineinfile:
  21. # since ansible 2.3 s/dest/path
  22. dest: "{{ yum_conf_temp_file }}"
  23. regexp: '^exclude='
  24. line: 'exclude='
  25. - name: Gather common package version
  26. command: >
  27. {{ repoquery_cmd }} --config "{{ yum_conf_temp_file }}" --qf '%{version}' "{{ openshift.common.service_type}}"
  28. register: common_version
  29. failed_when: false
  30. changed_when: false
  31. when: openshift_version is not defined
  32. - name: Delete the temporary yum.conf
  33. file:
  34. path: "{{ yum_conf_temp_file_result.stdout }}"
  35. state: absent
  36. - set_fact:
  37. openshift_version: "{{ common_version.stdout | default('0.0', True) }}"
  38. when: openshift_version is not defined