mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
ca16956337
* added integration tests for apt upgrade changed version number for hello to 2.6 so that it works with Ubuntu 12.04 prevent tests from checking if aptitude is installed on non ubuntu systems changed ordering on when statements for safe and full upgrade types so that the OS check happens before the aptitude check added integration tests for apt upgrade changed version number for hello to 2.6 so that it works with Ubuntu 12.04 * Moved additions to tasks/main.yml to make revisions easier. Changed tasks to multiline format
172 lines
4.2 KiB
YAML
172 lines
4.2 KiB
YAML
- name: show python version
|
|
debug: var=ansible_python_version
|
|
|
|
- name: use python-apt
|
|
set_fact:
|
|
python_apt: python-apt
|
|
when: ansible_python_version | version_compare('3', '<')
|
|
|
|
- name: use python3-apt
|
|
set_fact:
|
|
python_apt: python3-apt
|
|
when: ansible_python_version | version_compare('3', '>=')
|
|
|
|
# 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
|
|
register: apt_result
|
|
|
|
- name: check hello with dpkg
|
|
shell: dpkg-query -l hello
|
|
failed_when: False
|
|
register: dpkg_result
|
|
|
|
- name: verify uninstallation of hello
|
|
assert:
|
|
that:
|
|
- "'changed' in apt_result"
|
|
- "dpkg_result.rc == 1"
|
|
|
|
# UNINSTALL AGAIN
|
|
- name: uninstall hello with apt
|
|
apt: pkg=hello state=absent purge=yes
|
|
register: apt_result
|
|
|
|
- name: verify no change on re-uninstall
|
|
assert:
|
|
that:
|
|
- "not apt_result.changed"
|
|
|
|
# INSTALL
|
|
- name: install hello with apt
|
|
apt: name=hello state=present
|
|
register: apt_result
|
|
|
|
- name: check hello with dpkg
|
|
shell: dpkg-query -l 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"
|
|
|
|
- name: verify apt module outputs
|
|
assert:
|
|
that:
|
|
- "'changed' in apt_result"
|
|
- "'stderr' in apt_result"
|
|
- "'stdout' in apt_result"
|
|
- "'stdout_lines' in apt_result"
|
|
|
|
# INSTALL AGAIN
|
|
- name: install hello with apt
|
|
apt: name=hello state=present
|
|
register: apt_result
|
|
|
|
- name: verify no change on re-install
|
|
assert:
|
|
that:
|
|
- "not apt_result.changed"
|
|
|
|
# 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
|
|
register: apt_result
|
|
|
|
- name: check hello with wildcard with dpkg
|
|
shell: dpkg-query -l 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"
|
|
|
|
- name: check hello version
|
|
shell: dpkg -s hello | grep Version | awk '{print $2}'
|
|
register: hello_version
|
|
|
|
- name: check hello architecture
|
|
shell: dpkg -s hello | grep Architecture | awk '{print $2}'
|
|
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"
|
|
|
|
# NEGATIVE: upgrade all packages while providing additional packages to install
|
|
- name: provide additional packages to install while upgrading all installed packages
|
|
apt: pkg=*,test state=latest
|
|
ignore_errors: True
|
|
register: apt_result
|
|
|
|
- name: verify failure of upgrade packages and install
|
|
assert:
|
|
that:
|
|
- "not apt_result.changed"
|
|
- "apt_result.failed"
|
|
|
|
- name: autoclean during install
|
|
apt: pkg=hello state=present autoclean=yes
|
|
|
|
- name: autoclean
|
|
apt: autoclean=yes
|
|
|
|
- name: autoremove
|
|
apt: autoremove=yes
|