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/tests/integration/targets/pkgng/tasks/main.yml
Ross Williams 9a867a38ee pkgng: add state=absent test
Also renumber `jail=...` test to make diffs less
noisy when adding more non-jailed tests.
2021-10-11 02:11:26 +00:00

161 lines
4.4 KiB
YAML

---
- name: Test on FreeBSD VMs
when:
- ansible_facts.distribution == 'FreeBSD'
block:
##
## pkgng - example - install single package
##
- name: Verify zsh binary is not present
stat:
path: /usr/local/bin/zsh
get_attributes: no
get_checksum: no
get_mime: no
register: pkgng_example1_stat_before
- name: Install zsh
pkgng:
name: zsh
register: pkgng_example1
- name: Remove zsh (checkmode)
pkgng:
name: zsh
state: absent
check_mode: yes
register: pkgng_example1_checkmode
- name: Install zsh (idempotent)
pkgng:
name: zsh
register: pkgng_example1_idempotent
- name: Verify zsh binary is present
stat:
path: /usr/local/bin/zsh
get_attributes: no
get_checksum: no
get_mime: no
register: pkgng_example1_stat_after
- name: Ensure pkgng installs package correctly
assert:
that:
- not pkgng_example1_stat_before.stat.exists
- pkgng_example1.changed
- pkgng_example1_checkmode.changed
- not pkgng_example1_idempotent.changed
- pkgng_example1_stat_after.stat.exists
- pkgng_example1_stat_after.stat.executable
##
## pkgng - example - remove single package
##
- name: Verify zsh binary is present
stat:
path: /usr/local/bin/zsh
get_attributes: no
get_checksum: no
get_mime: no
register: pkgng_example2_stat_before
- name: Install zsh (checkmode)
pkgng:
name: zsh
check_mode: yes
register: pkgng_example2_checkmode
- name: Remove zsh
pkgng:
name: zsh
state: absent
register: pkgng_example2
- name: Remove zsh (idempotent)
pkgng:
name: zsh
state: absent
register: pkgng_example2_idempotent
- name: Verify zsh binary is not present
stat:
path: /usr/local/bin/zsh
get_attributes: no
get_checksum: no
get_mime: no
register: pkgng_example2_stat_after
- name: Ensure pkgng installs package correctly
assert:
that:
- pkgng_example2_stat_before.stat.exists
- pkgng_example2_stat_before.stat.executable
- not pkgng_example2_checkmode.changed
- pkgng_example2.changed
- not pkgng_example2_idempotent.changed
- not pkgng_example2_stat_after.stat.exists
##
## pkgng - example - Install zsh in jail
##
- name: Test within jail
#
# NOTE: FreeBSD 12.0 test runner receives a "connection reset by peer" after ~20% downloaded so we are
# only running this on 12.1 or higher
#
when: ansible_distribution_version is version('12.01', '>=')
block:
- name: Setup testjail
include: setup-testjail.yml
- name: Verify zsh binary is not present
stat:
path: /usr/jails/testjail/usr/local/bin/zsh
get_attributes: no
get_checksum: no
get_mime: no
register: pkgng_jail_example1_stat_before
- name: Install zsh
pkgng:
name: zsh
jail: testjail
register: pkgng_jail_example1
- name: Remove zsh (checkmode)
pkgng:
name: zsh
state: absent
jail: testjail
check_mode: yes
register: pkgng_jail_example1_checkmode
- name: Install zsh (idempotent)
pkgng:
name: zsh
jail: testjail
register: pkgng_jail_example1_idempotent
- name: Verify zsh binary is present
stat:
path: /usr/jails/testjail/usr/local/bin/zsh
get_attributes: no
get_checksum: no
get_mime: no
register: pkgng_jail_example1_stat_after
- name: Ensure pkgng installs package correctly
assert:
that:
- not pkgng_jail_example1_stat_before.stat.exists
- pkgng_jail_example1.changed
- pkgng_jail_example1_checkmode.changed
- not pkgng_jail_example1_idempotent.changed
- pkgng_jail_example1_stat_after.stat.exists
- pkgng_jail_example1_stat_after.stat.executable
always:
- name: Stop and remove testjail
failed_when: false
changed_when: false
command: "ezjail-admin delete -wf testjail"