/test/integration/roles/test_yum/tasks/yum.yml

https://github.com/ajanthanm/ansible · YAML · 86 lines · 58 code · 16 blank · 12 comment · 0 complexity · 83bbf3d3e311293bb7cb9a0b4b493f63 MD5 · raw file

  1. # UNINSTALL 'yum-utils'
  2. # The `yum` module has the smarts to auto-install `yum-utils`. To test, we
  3. # will first uninstall `yum-utils`.
  4. - name: check yum-utils with rpm
  5. shell: rpm -q yum-utils
  6. register: rpm_result
  7. ignore_errors: true
  8. # Don't uninstall yum-utils with the `yum` module, it would be bad. The `yum`
  9. # module does some `repoquery` magic after removing a package. It fails when you
  10. # remove `yum-utils.
  11. - name: uninstall yum-utils with shell
  12. shell: yum -y remove yum-utils
  13. when: rpm_result|success
  14. # UNINSTALL
  15. # With 'yum-utils' uninstalled, the first call to 'yum' should install
  16. # yum-utils.
  17. - name: uninstall sos
  18. yum: name=sos state=removed
  19. register: yum_result
  20. - name: check sos with rpm
  21. shell: rpm -q sos
  22. failed_when: False
  23. register: rpm_result
  24. - debug: var=yum_result
  25. - debug: var=rpm_result
  26. - name: verify uninstalltion of sos
  27. assert:
  28. that:
  29. - "yum_result.rc == 0"
  30. - "rpm_result.rc == 1"
  31. # UNINSTALL AGAIN
  32. - name: uninstall sos again
  33. yum: name=sos state=removed
  34. register: yum_result
  35. - name: verify no change on re-uninstall
  36. assert:
  37. that:
  38. - "not yum_result.changed"
  39. # INSTALL
  40. - name: install sos
  41. yum: name=sos state=present
  42. register: yum_result
  43. - name: check sos with rpm
  44. shell: rpm -q sos
  45. failed_when: False
  46. register: rpm_result
  47. - debug: var=yum_result
  48. - debug: var=rpm_result
  49. - name: verify installation of sos
  50. assert:
  51. that:
  52. - "yum_result.rc == 0"
  53. - "yum_result.changed"
  54. - "rpm_result.rc == 0"
  55. - name: verify yum module outputs
  56. assert:
  57. that:
  58. - "'invocation' in yum_result"
  59. - "'changed' in yum_result"
  60. - "'msg' in yum_result"
  61. - "'rc' in yum_result"
  62. - "'results' in yum_result"
  63. # INSTALL AGAIN
  64. - name: install sos again
  65. yum: name=sos state=present
  66. register: yum_result
  67. - name: verify no change on second install
  68. assert:
  69. that:
  70. - "not yum_result.changed"