1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/test/integration/roles/test_apt/tasks/apt.yml

141 lines
3.5 KiB
YAML
Raw Normal View History

2015-01-08 04:44:31 +01: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.
- name: uninstall hello with apt
apt: pkg=hello state=absent purge=yes
2014-02-20 20:55:55 +01:00
register: apt_result
- name: check hello with dpkg
shell: dpkg --get-selections | fgrep hello
2014-02-20 20:55:55 +01:00
failed_when: False
register: dpkg_result
- name: verify uninstallation of hello
2014-02-20 20:55:55 +01:00
assert:
that:
2014-02-20 20:55:55 +01:00
- "'changed' in apt_result"
- "dpkg_result.rc == 1"
2014-02-20 21:01:23 +01:00
# UNINSTALL AGAIN
- name: uninstall hello with apt
apt: pkg=hello state=absent purge=yes
2014-02-20 21:01:23 +01:00
register: apt_result
- name: verify no change on re-uninstall
assert:
that:
2014-02-20 21:01:23 +01:00
- "not apt_result.changed"
2014-02-20 20:55:55 +01:00
# INSTALL
- name: install hello with apt
apt: name=hello state=present
2014-02-20 20:55:55 +01:00
register: apt_result
- name: check hello with dpkg
shell: dpkg --get-selections | fgrep hello
2014-02-20 20:55:55 +01:00
failed_when: False
register: dpkg_result
- debug: var=apt_result
- debug: var=dpkg_result
- name: verify installation of hello
2014-02-20 20:55:55 +01:00
assert:
that:
2014-02-20 20:55:55 +01:00
- "apt_result.changed"
- "dpkg_result.rc == 0"
- name: verify apt module outputs
assert:
that:
- "'invocation' in apt_result"
2014-02-20 20:55:55 +01:00
- "'changed' in apt_result"
- "'stderr' in apt_result"
- "'stdout' in apt_result"
- "'stdout_lines' in apt_result"
2014-02-20 21:01:23 +01:00
# INSTALL AGAIN
- name: install hello with apt
apt: name=hello state=present
2014-02-20 21:01:23 +01:00
register: apt_result
- name: verify no change on re-install
assert:
that:
2014-02-20 21:01:23 +01:00
- "not apt_result.changed"
2014-09-05 08:40:27 +02: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.* state=present
2014-09-05 08:40:27 +02:00
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"
2015-01-08 04:44:31 +01:00
- name: check hello version
shell: dpkg -s hello | grep Version | sed -r 's/Version:\s+([a-zA-Z0-9.-]+)\s*$/\1/'
register: hello_version
- name: check hello architecture
shell: dpkg -s hello | grep Architecture | sed -r 's/Architecture:\s+([a-zA-Z0-9.-]+)\s*$/\1/'
register: hello_architecture
- name: uninstall hello with apt
apt: pkg=hello state=absent purge=yes
- name: install deb file
apt: deb="/var/cache/apt/archives/hello_{{ hello_version.stdout }}_{{ hello_architecture.stdout }}.deb"
register: apt_initial
- name: install deb file again
apt: deb="/var/cache/apt/archives/hello_{{ hello_version.stdout }}_{{ hello_architecture.stdout }}.deb"
register: apt_secondary
- name: verify installation of hello
assert:
that:
- "apt_initial.changed"
- "not apt_secondary.changed"
- name: uninstall hello with apt
apt: pkg=hello state=absent purge=yes
- name: force install of deb
apt: deb="/var/cache/apt/archives/hello_{{ hello_version.stdout }}_{{ hello_architecture.stdout }}.deb" force=true
register: dpkg_force
- name: verify installation of hello
assert:
that:
- "dpkg_force.changed"