2014-03-17 14:41:02 +00:00
|
|
|
# UNINSTALL 'python-apt'
|
|
|
|
# The `apt` module has the smarts to auto-install `python-apt`. To test, we
|
|
|
|
# will first uninstall `python-apt`.
|
|
|
|
- name: check python-apt with dpkg
|
|
|
|
shell: dpkg -s python-apt
|
|
|
|
register: dpkg_result
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: uninstall python-apt with apt
|
|
|
|
apt: pkg=python-apt state=absent purge=yes
|
|
|
|
register: apt_result
|
|
|
|
when: dpkg_result|success
|
|
|
|
|
|
|
|
# UNINSTALL 'hello'
|
|
|
|
# With 'python-apt' uninstalled, the first call to 'apt' should install
|
|
|
|
# python-apt.
|
2014-02-23 10:46:39 +00:00
|
|
|
- name: uninstall hello with apt
|
|
|
|
apt: pkg=hello state=absent purge=yes
|
2014-02-20 19:55:55 +00:00
|
|
|
register: apt_result
|
|
|
|
|
2014-02-23 10:46:39 +00:00
|
|
|
- name: check hello with dpkg
|
|
|
|
shell: dpkg --get-selections | fgrep hello
|
2014-02-20 19:55:55 +00:00
|
|
|
failed_when: False
|
|
|
|
register: dpkg_result
|
|
|
|
|
2014-02-23 10:46:39 +00:00
|
|
|
- name: verify uninstallation of hello
|
2014-02-20 19:55:55 +00:00
|
|
|
assert:
|
2014-02-23 10:46:39 +00:00
|
|
|
that:
|
2014-02-20 19:55:55 +00:00
|
|
|
- "'changed' in apt_result"
|
|
|
|
- "dpkg_result.rc == 1"
|
|
|
|
|
2014-02-20 20:01:23 +00:00
|
|
|
# UNINSTALL AGAIN
|
2014-02-23 10:46:39 +00:00
|
|
|
- name: uninstall hello with apt
|
|
|
|
apt: pkg=hello state=absent purge=yes
|
2014-02-20 20:01:23 +00:00
|
|
|
register: apt_result
|
|
|
|
|
|
|
|
- name: verify no change on re-uninstall
|
|
|
|
assert:
|
2014-02-23 10:46:39 +00:00
|
|
|
that:
|
2014-02-20 20:01:23 +00:00
|
|
|
- "not apt_result.changed"
|
|
|
|
|
2014-02-20 19:55:55 +00:00
|
|
|
# INSTALL
|
2014-02-23 10:46:39 +00:00
|
|
|
- name: install hello with apt
|
|
|
|
apt: name=hello state=present
|
2014-02-20 19:55:55 +00:00
|
|
|
register: apt_result
|
|
|
|
|
2014-02-23 10:46:39 +00:00
|
|
|
- name: check hello with dpkg
|
|
|
|
shell: dpkg --get-selections | fgrep hello
|
2014-02-20 19:55:55 +00:00
|
|
|
failed_when: False
|
|
|
|
register: dpkg_result
|
|
|
|
|
|
|
|
- debug: var=apt_result
|
|
|
|
- debug: var=dpkg_result
|
|
|
|
|
2014-02-23 10:46:39 +00:00
|
|
|
- name: verify installation of hello
|
2014-02-20 19:55:55 +00:00
|
|
|
assert:
|
2014-02-23 10:46:39 +00:00
|
|
|
that:
|
2014-02-20 19:55:55 +00:00
|
|
|
- "apt_result.changed"
|
|
|
|
- "dpkg_result.rc == 0"
|
|
|
|
|
|
|
|
- name: verify apt module outputs
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "'invocation' in apt_result"
|
|
|
|
- "'changed' in apt_result"
|
|
|
|
- "'stderr' in apt_result"
|
2014-02-23 10:46:39 +00:00
|
|
|
- "'stdout' in apt_result"
|
|
|
|
- "'stdout_lines' in apt_result"
|
2014-02-20 20:01:23 +00:00
|
|
|
|
|
|
|
# INSTALL AGAIN
|
2014-02-23 10:46:39 +00:00
|
|
|
- name: install hello with apt
|
|
|
|
apt: name=hello state=present
|
2014-02-20 20:01:23 +00:00
|
|
|
register: apt_result
|
|
|
|
|
|
|
|
- name: verify no change on re-install
|
|
|
|
assert:
|
2014-02-23 10:46:39 +00:00
|
|
|
that:
|
2014-02-20 20:01:23 +00:00
|
|
|
- "not apt_result.changed"
|
|
|
|
|
2014-09-05 06:40:27 +00:00
|
|
|
# UNINSTALL AGAIN
|
|
|
|
- name: uninstall hello with apt
|
|
|
|
apt: pkg=hello state=absent purge=yes
|
|
|
|
register: apt_result
|
|
|
|
|
|
|
|
# INSTALL WITH VERSION WILDCARD
|
|
|
|
- name: install hello with apt
|
|
|
|
apt: name=hello=2.7* state=present
|
|
|
|
register: apt_result
|
|
|
|
|
|
|
|
- name: check hello with wildcard with dpkg
|
|
|
|
shell: dpkg --get-selections | fgrep hello
|
|
|
|
failed_when: False
|
|
|
|
register: dpkg_result
|
|
|
|
|
|
|
|
- debug: var=apt_result
|
|
|
|
- debug: var=dpkg_result
|
|
|
|
|
|
|
|
- name: verify installation of hello
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- "apt_result.changed"
|
|
|
|
- "dpkg_result.rc == 0"
|
2014-02-23 10:46:39 +00:00
|
|
|
|