2021-10-07 17:24:02 +02:00
|
|
|
---
|
|
|
|
- name: Test on FreeBSD VMs
|
|
|
|
when:
|
|
|
|
- ansible_facts.distribution == 'FreeBSD'
|
|
|
|
block:
|
|
|
|
##
|
2021-10-08 19:26:13 +02:00
|
|
|
## pkgng - example - state=present for single package
|
2021-10-07 17:24:02 +02:00
|
|
|
##
|
2021-10-07 21:01:39 +02:00
|
|
|
- name: Verify zsh binary is not present
|
2021-10-07 17:24:02 +02:00
|
|
|
stat:
|
2021-10-07 21:01:39 +02:00
|
|
|
path: /usr/local/bin/zsh
|
2021-10-07 17:24:02 +02:00
|
|
|
get_attributes: no
|
|
|
|
get_checksum: no
|
|
|
|
get_mime: no
|
|
|
|
register: pkgng_example1_stat_before
|
|
|
|
|
2021-10-07 21:01:39 +02:00
|
|
|
- name: Install zsh
|
2021-10-07 17:24:02 +02:00
|
|
|
pkgng:
|
2021-10-07 21:01:39 +02:00
|
|
|
name: zsh
|
2021-10-07 17:24:02 +02:00
|
|
|
register: pkgng_example1
|
|
|
|
|
2021-10-07 21:01:39 +02:00
|
|
|
- name: Remove zsh (checkmode)
|
2021-10-07 17:24:02 +02:00
|
|
|
pkgng:
|
2021-10-07 21:01:39 +02:00
|
|
|
name: zsh
|
2021-10-07 17:24:02 +02:00
|
|
|
state: absent
|
|
|
|
check_mode: yes
|
|
|
|
register: pkgng_example1_checkmode
|
|
|
|
|
2021-10-11 14:39:15 +02:00
|
|
|
- name: Install zsh (idempotent, cached)
|
2021-10-07 17:24:02 +02:00
|
|
|
pkgng:
|
2021-10-07 21:01:39 +02:00
|
|
|
name: zsh
|
2021-10-11 14:39:15 +02:00
|
|
|
cached: yes
|
|
|
|
register: pkgng_example1_idempotent_cached
|
2021-10-07 17:24:02 +02:00
|
|
|
|
2021-10-07 21:01:39 +02:00
|
|
|
- name: Verify zsh binary is present
|
2021-10-07 17:24:02 +02:00
|
|
|
stat:
|
2021-10-07 21:01:39 +02:00
|
|
|
path: /usr/local/bin/zsh
|
2021-10-07 17:24:02 +02:00
|
|
|
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
|
2021-10-11 14:39:15 +02:00
|
|
|
- not pkgng_example1_idempotent_cached.changed
|
|
|
|
- not pkgng_example1_idempotent_cached.stdout is match("Updating \w+ repository catalogue\.\.\.")
|
2021-10-07 17:24:02 +02:00
|
|
|
- pkgng_example1_stat_after.stat.exists
|
|
|
|
- pkgng_example1_stat_after.stat.executable
|
|
|
|
|
2021-10-08 18:29:37 +02:00
|
|
|
##
|
2021-10-08 19:26:13 +02:00
|
|
|
## pkgng - example - state=latest for already up-to-date package
|
|
|
|
##
|
|
|
|
- name: Upgrade zsh (idempotent)
|
|
|
|
pkgng:
|
|
|
|
name: zsh
|
|
|
|
state: latest
|
|
|
|
register: pkgng_example2
|
|
|
|
|
|
|
|
- name: Ensure pkgng does not upgrade up-to-date package
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- not pkgng_example2.changed
|
|
|
|
|
|
|
|
## pkgng - example - state=absent for single package
|
2021-10-08 18:29:37 +02:00
|
|
|
##
|
|
|
|
- name: Verify zsh binary is present
|
|
|
|
stat:
|
|
|
|
path: /usr/local/bin/zsh
|
|
|
|
get_attributes: no
|
|
|
|
get_checksum: no
|
|
|
|
get_mime: no
|
2021-10-08 19:26:13 +02:00
|
|
|
register: pkgng_example3_stat_before
|
2021-10-08 18:29:37 +02:00
|
|
|
|
|
|
|
- name: Install zsh (checkmode)
|
|
|
|
pkgng:
|
|
|
|
name: zsh
|
|
|
|
check_mode: yes
|
2021-10-08 19:26:13 +02:00
|
|
|
register: pkgng_example3_checkmode
|
2021-10-08 18:29:37 +02:00
|
|
|
|
|
|
|
- name: Remove zsh
|
|
|
|
pkgng:
|
|
|
|
name: zsh
|
|
|
|
state: absent
|
2021-10-08 19:26:13 +02:00
|
|
|
register: pkgng_example3
|
2021-10-08 18:29:37 +02:00
|
|
|
|
|
|
|
- name: Remove zsh (idempotent)
|
|
|
|
pkgng:
|
|
|
|
name: zsh
|
|
|
|
state: absent
|
2021-10-08 19:26:13 +02:00
|
|
|
register: pkgng_example3_idempotent
|
2021-10-08 18:29:37 +02:00
|
|
|
|
|
|
|
- name: Verify zsh binary is not present
|
|
|
|
stat:
|
|
|
|
path: /usr/local/bin/zsh
|
|
|
|
get_attributes: no
|
|
|
|
get_checksum: no
|
|
|
|
get_mime: no
|
2021-10-08 19:26:13 +02:00
|
|
|
register: pkgng_example3_stat_after
|
2021-10-08 18:29:37 +02:00
|
|
|
|
|
|
|
- name: Ensure pkgng installs package correctly
|
|
|
|
assert:
|
|
|
|
that:
|
2021-10-08 19:26:13 +02:00
|
|
|
- pkgng_example3_stat_before.stat.exists
|
|
|
|
- pkgng_example3_stat_before.stat.executable
|
|
|
|
- not pkgng_example3_checkmode.changed
|
|
|
|
- pkgng_example3.changed
|
|
|
|
- not pkgng_example3_idempotent.changed
|
|
|
|
- not pkgng_example3_stat_after.stat.exists
|
2021-10-08 18:29:37 +02:00
|
|
|
|
2021-10-08 20:53:10 +02:00
|
|
|
##
|
|
|
|
## pkgng - example - state=latest for out-of-date package
|
|
|
|
##
|
|
|
|
- name: Install intentionally out-of-date package and upgrade it
|
|
|
|
#
|
2021-10-09 04:28:17 +02:00
|
|
|
# NOTE: The out-of-date package provided is a minimal,
|
|
|
|
# no-contents test package that declares zsh with
|
|
|
|
# a version of 0, so it should always be upgraded.
|
2021-10-08 20:53:10 +02:00
|
|
|
#
|
|
|
|
# This test might fail at some point in the
|
2021-10-09 04:28:17 +02:00
|
|
|
# future if the FreeBSD package format receives
|
|
|
|
# breaking changes that prevent pkg from installing
|
2021-10-08 20:53:10 +02:00
|
|
|
# older package formats.
|
|
|
|
#
|
|
|
|
block:
|
2021-10-09 05:24:15 +02:00
|
|
|
- name: Create temporary directory to assemble test package
|
|
|
|
file:
|
|
|
|
state: directory
|
|
|
|
path: /tmp/zsh_test_package
|
2021-10-08 20:53:10 +02:00
|
|
|
|
2021-10-09 05:24:15 +02:00
|
|
|
- name: Copy intentionally out-of-date package manifests to testhost
|
2021-10-09 05:11:00 +02:00
|
|
|
copy:
|
2021-10-09 05:24:15 +02:00
|
|
|
src: zsh_test_package_manifests/{{ item }}
|
|
|
|
# Plus-sign must be added at the destination
|
|
|
|
# CI doesn't like files with '+' in them in the repository
|
|
|
|
dest: /tmp/zsh_test_package/+{{ item }}
|
2021-10-09 05:11:00 +02:00
|
|
|
loop:
|
|
|
|
- COMPACT_MANIFEST
|
|
|
|
- MANIFEST
|
|
|
|
|
2021-10-09 04:28:17 +02:00
|
|
|
- name: Create out-of-date test package
|
2021-10-09 05:24:15 +02:00
|
|
|
command: tar -C /tmp/zsh_test_package -cJf /tmp/zsh-0__test.pkg +COMPACT_MANIFEST +MANIFEST
|
2021-10-09 04:28:17 +02:00
|
|
|
|
|
|
|
- name: Install out-of-date test package
|
|
|
|
command: pkg add /tmp/zsh-0__test.pkg
|
2021-10-08 20:53:10 +02:00
|
|
|
register: pkgng_example4_prepare
|
|
|
|
|
|
|
|
- name: Check for any available package upgrades (checkmode)
|
|
|
|
pkgng:
|
|
|
|
name: '*'
|
|
|
|
state: latest
|
|
|
|
check_mode: yes
|
|
|
|
register: pkgng_example4_wildcard_checkmode
|
|
|
|
|
|
|
|
- name: Check for available package upgrade (checkmode)
|
|
|
|
pkgng:
|
2021-10-09 05:11:00 +02:00
|
|
|
name: zsh
|
2021-10-08 20:53:10 +02:00
|
|
|
state: latest
|
|
|
|
check_mode: yes
|
|
|
|
register: pkgng_example4_checkmode
|
|
|
|
|
|
|
|
- name: Upgrade out-of-date package
|
|
|
|
pkgng:
|
2021-10-09 05:11:00 +02:00
|
|
|
name: zsh
|
2021-10-08 20:53:10 +02:00
|
|
|
state: latest
|
|
|
|
register: pkgng_example4
|
|
|
|
|
|
|
|
- name: Upgrade out-of-date package (idempotent)
|
|
|
|
pkgng:
|
2021-10-09 05:11:00 +02:00
|
|
|
name: zsh
|
2021-10-08 20:53:10 +02:00
|
|
|
state: latest
|
|
|
|
register: pkgng_example4_idempotent
|
|
|
|
|
|
|
|
- name: Remove test out-of-date package
|
|
|
|
pkgng:
|
2021-10-09 05:11:00 +02:00
|
|
|
name: zsh
|
2021-10-08 20:53:10 +02:00
|
|
|
state: absent
|
|
|
|
|
|
|
|
- name: Ensure pkgng upgrades package correctly
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- not pkgng_example4_prepare.failed
|
|
|
|
- pkgng_example4_wildcard_checkmode.changed
|
|
|
|
- pkgng_example4_checkmode.changed
|
|
|
|
- pkgng_example4.changed
|
|
|
|
- not pkgng_example4_idempotent.changed
|
|
|
|
|
2021-10-07 17:24:02 +02:00
|
|
|
##
|
2021-10-07 21:01:39 +02:00
|
|
|
## pkgng - example - Install zsh in jail
|
2021-10-07 17:24:02 +02:00
|
|
|
##
|
|
|
|
- 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
|
|
|
|
|
2021-10-07 21:01:39 +02:00
|
|
|
- name: Verify zsh binary is not present
|
2021-10-07 17:24:02 +02:00
|
|
|
stat:
|
2021-10-07 21:01:39 +02:00
|
|
|
path: /usr/jails/testjail/usr/local/bin/zsh
|
2021-10-07 17:24:02 +02:00
|
|
|
get_attributes: no
|
|
|
|
get_checksum: no
|
|
|
|
get_mime: no
|
2021-10-08 18:29:37 +02:00
|
|
|
register: pkgng_jail_example1_stat_before
|
2021-10-07 17:24:02 +02:00
|
|
|
|
2021-10-07 21:01:39 +02:00
|
|
|
- name: Install zsh
|
2021-10-07 17:24:02 +02:00
|
|
|
pkgng:
|
2021-10-07 21:01:39 +02:00
|
|
|
name: zsh
|
2021-10-07 17:24:02 +02:00
|
|
|
jail: testjail
|
2021-10-08 18:29:37 +02:00
|
|
|
register: pkgng_jail_example1
|
2021-10-07 17:24:02 +02:00
|
|
|
|
2021-10-07 21:01:39 +02:00
|
|
|
- name: Remove zsh (checkmode)
|
2021-10-07 17:24:02 +02:00
|
|
|
pkgng:
|
2021-10-07 21:01:39 +02:00
|
|
|
name: zsh
|
2021-10-07 17:24:02 +02:00
|
|
|
state: absent
|
|
|
|
jail: testjail
|
|
|
|
check_mode: yes
|
2021-10-08 18:29:37 +02:00
|
|
|
register: pkgng_jail_example1_checkmode
|
2021-10-07 17:24:02 +02:00
|
|
|
|
2021-10-07 21:01:39 +02:00
|
|
|
- name: Install zsh (idempotent)
|
2021-10-07 17:24:02 +02:00
|
|
|
pkgng:
|
2021-10-07 21:01:39 +02:00
|
|
|
name: zsh
|
2021-10-07 17:24:02 +02:00
|
|
|
jail: testjail
|
2021-10-08 18:29:37 +02:00
|
|
|
register: pkgng_jail_example1_idempotent
|
2021-10-07 17:24:02 +02:00
|
|
|
|
2021-10-07 21:01:39 +02:00
|
|
|
- name: Verify zsh binary is present
|
2021-10-07 17:24:02 +02:00
|
|
|
stat:
|
2021-10-07 21:01:39 +02:00
|
|
|
path: /usr/jails/testjail/usr/local/bin/zsh
|
2021-10-07 17:24:02 +02:00
|
|
|
get_attributes: no
|
|
|
|
get_checksum: no
|
|
|
|
get_mime: no
|
2021-10-08 18:29:37 +02:00
|
|
|
register: pkgng_jail_example1_stat_after
|
2021-10-07 17:24:02 +02:00
|
|
|
|
|
|
|
- name: Ensure pkgng installs package correctly
|
|
|
|
assert:
|
|
|
|
that:
|
2021-10-08 18:29:37 +02:00
|
|
|
- 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
|
2021-10-07 17:24:02 +02:00
|
|
|
always:
|
|
|
|
- name: Stop and remove testjail
|
|
|
|
failed_when: false
|
|
|
|
changed_when: false
|
|
|
|
command: "ezjail-admin delete -wf testjail"
|