/test/integration/roles/test_apt/tasks/apt.yml

https://github.com/ajanthanm/ansible · YAML · 80 lines · 56 code · 15 blank · 9 comment · 0 complexity · 9b52da06b11bbce53a1f458f91316bf2 MD5 · raw file

  1. # UNINSTALL 'python-apt'
  2. # The `apt` module has the smarts to auto-install `python-apt`. To test, we
  3. # will first uninstall `python-apt`.
  4. - name: check python-apt with dpkg
  5. shell: dpkg -s python-apt
  6. register: dpkg_result
  7. ignore_errors: true
  8. - name: uninstall python-apt with apt
  9. apt: pkg=python-apt state=absent purge=yes
  10. register: apt_result
  11. when: dpkg_result|success
  12. # UNINSTALL 'hello'
  13. # With 'python-apt' uninstalled, the first call to 'apt' should install
  14. # python-apt.
  15. - name: uninstall hello with apt
  16. apt: pkg=hello state=absent purge=yes
  17. register: apt_result
  18. - name: check hello with dpkg
  19. shell: dpkg --get-selections | fgrep hello
  20. failed_when: False
  21. register: dpkg_result
  22. - name: verify uninstallation of hello
  23. assert:
  24. that:
  25. - "'changed' in apt_result"
  26. - "dpkg_result.rc == 1"
  27. # UNINSTALL AGAIN
  28. - name: uninstall hello with apt
  29. apt: pkg=hello state=absent purge=yes
  30. register: apt_result
  31. - name: verify no change on re-uninstall
  32. assert:
  33. that:
  34. - "not apt_result.changed"
  35. # INSTALL
  36. - name: install hello with apt
  37. apt: name=hello state=present
  38. register: apt_result
  39. - name: check hello with dpkg
  40. shell: dpkg --get-selections | fgrep hello
  41. failed_when: False
  42. register: dpkg_result
  43. - debug: var=apt_result
  44. - debug: var=dpkg_result
  45. - name: verify installation of hello
  46. assert:
  47. that:
  48. - "apt_result.changed"
  49. - "dpkg_result.rc == 0"
  50. - name: verify apt module outputs
  51. assert:
  52. that:
  53. - "'invocation' in apt_result"
  54. - "'changed' in apt_result"
  55. - "'stderr' in apt_result"
  56. - "'stdout' in apt_result"
  57. - "'stdout_lines' in apt_result"
  58. # INSTALL AGAIN
  59. - name: install hello with apt
  60. apt: name=hello state=present
  61. register: apt_result
  62. - name: verify no change on re-install
  63. assert:
  64. that:
  65. - "not apt_result.changed"