From 4357a78130d84785720750d3d6801db5cf4df464 Mon Sep 17 00:00:00 2001 From: Rick Elrod Date: Thu, 21 Jan 2021 17:12:18 -0600 Subject: [PATCH] [ansible-test] First attempt at freebsd/11.4 (#72655) Change: - Try CI against freebsd 11.4 Test Plan: - ci_complete Tickets: - Fixes #48782 Signed-off-by: Rick Elrod --- .azure-pipelines/azure-pipelines.yml | 8 +++---- .../fragments/ansible-test-freebsd11-4.yml | 2 ++ .../tasks/main.yml | 11 +++++++++ .../collection-tests/git-common.bash | 24 ++++++++++++++++++- .../collection-tests/uninstall-git.yml | 18 ++++++++++++++ .../install-FreeBSD-11.4-python-3.yml | 3 +++ .../uninstall-FreeBSD-11.4-python-3.yml | 4 ++++ .../ansible_test/_data/completion/remote.txt | 1 + 8 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/ansible-test-freebsd11-4.yml create mode 100644 test/integration/targets/ansible-test/collection-tests/uninstall-git.yml create mode 100644 test/integration/targets/setup_paramiko/install-FreeBSD-11.4-python-3.yml create mode 100644 test/integration/targets/setup_paramiko/uninstall-FreeBSD-11.4-python-3.yml diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index 9724950c204..4c9d53e44e2 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -93,8 +93,8 @@ stages: test: rhel/7.9 - name: RHEL 8.3 test: rhel/8.3 - - name: FreeBSD 11.1 - test: freebsd/11.1 + - name: FreeBSD 11.4 + test: freebsd/11.4 - name: FreeBSD 12.2 test: freebsd/12.2 groups: @@ -170,8 +170,8 @@ stages: test: rhel/7.9 - name: RHEL 8.3 test: rhel/8.3 - - name: FreeBSD 11.1 - test: freebsd/11.1 + - name: FreeBSD 11.4 + test: freebsd/11.4 - name: FreeBSD 12.2 test: freebsd/12.2 - stage: Incidental_Docker diff --git a/changelogs/fragments/ansible-test-freebsd11-4.yml b/changelogs/fragments/ansible-test-freebsd11-4.yml new file mode 100644 index 00000000000..4f99ec5cb07 --- /dev/null +++ b/changelogs/fragments/ansible-test-freebsd11-4.yml @@ -0,0 +1,2 @@ +minor_changes: + - ansible-test - Now supports freebsd/11.4 remote (https://github.com/ansible/ansible/issues/48782). diff --git a/test/integration/targets/ansible-galaxy-collection-scm/tasks/main.yml b/test/integration/targets/ansible-galaxy-collection-scm/tasks/main.yml index e83003f2f46..7a98a6ed848 100644 --- a/test/integration/targets/ansible-galaxy-collection-scm/tasks/main.yml +++ b/test/integration/targets/ansible-galaxy-collection-scm/tasks/main.yml @@ -40,3 +40,14 @@ name: git state: absent when: git_install is changed + + # This gets dragged in as a dependency of git on FreeBSD. + # We need to remove it too when done. + - name: remove python37 if necessary + package: + name: python37 + state: absent + when: + - git_install is changed + - ansible_distribution == 'FreeBSD' + - ansible_python.version.major == 2 diff --git a/test/integration/targets/ansible-test/collection-tests/git-common.bash b/test/integration/targets/ansible-test/collection-tests/git-common.bash index 069b157c65f..5055f2e8ab5 100755 --- a/test/integration/targets/ansible-test/collection-tests/git-common.bash +++ b/test/integration/targets/ansible-test/collection-tests/git-common.bash @@ -3,7 +3,29 @@ set -eux -o pipefail # make sure git is installed -git --version || ansible-playbook collection-tests/install-git.yml -i ../../inventory "$@" +set +e +git --version +gitres=$? +set -e + +if [[ $gitres -ne 0 ]]; then + ansible-playbook collection-tests/install-git.yml -i ../../inventory "$@" +fi + +dir="$(pwd)" + +uninstall_git() { + cd "$dir" + ansible-playbook collection-tests/uninstall-git.yml -i ../../inventory "$@" +} + +# This is kind of a hack. The uninstall playbook has no way to know the result +# of the install playbook to determine if it changed. So instead, we assume +# that if git wasn't found to begin with, it was installed by the playbook and +# and needs to be removed when we exit. +if [[ $gitres -ne 0 ]]; then + trap uninstall_git EXIT +fi # init sub project mkdir "${WORK_DIR}/sub" diff --git a/test/integration/targets/ansible-test/collection-tests/uninstall-git.yml b/test/integration/targets/ansible-test/collection-tests/uninstall-git.yml new file mode 100644 index 00000000000..f94caea7d96 --- /dev/null +++ b/test/integration/targets/ansible-test/collection-tests/uninstall-git.yml @@ -0,0 +1,18 @@ +- hosts: localhost + tasks: + - name: Make sure git is uninstalled + package: + name: git + state: absent + register: git_remove + + # This gets dragged in as a dependency of git on FreeBSD. + # We need to remove it too when done. + - name: remove python37 if necessary + package: + name: python37 + state: absent + when: + - git_remove is changed + - ansible_distribution == 'FreeBSD' + - ansible_python.version.major == 2 diff --git a/test/integration/targets/setup_paramiko/install-FreeBSD-11.4-python-3.yml b/test/integration/targets/setup_paramiko/install-FreeBSD-11.4-python-3.yml new file mode 100644 index 00000000000..9a7bfb67022 --- /dev/null +++ b/test/integration/targets/setup_paramiko/install-FreeBSD-11.4-python-3.yml @@ -0,0 +1,3 @@ +- name: Install Paramiko for Python 3 on FreeBSD 11.4 + pkgng: + name: py37-paramiko diff --git a/test/integration/targets/setup_paramiko/uninstall-FreeBSD-11.4-python-3.yml b/test/integration/targets/setup_paramiko/uninstall-FreeBSD-11.4-python-3.yml new file mode 100644 index 00000000000..86956fd9fd8 --- /dev/null +++ b/test/integration/targets/setup_paramiko/uninstall-FreeBSD-11.4-python-3.yml @@ -0,0 +1,4 @@ +- name: Uninstall Paramiko for Python 3 on FreeBSD 11.4 + pkgng: + name: py37-paramiko + state: absent diff --git a/test/lib/ansible_test/_data/completion/remote.txt b/test/lib/ansible_test/_data/completion/remote.txt index 42380af4c84..8cb5664ac95 100644 --- a/test/lib/ansible_test/_data/completion/remote.txt +++ b/test/lib/ansible_test/_data/completion/remote.txt @@ -1,4 +1,5 @@ freebsd/11.1 python=2.7,3.6 python_dir=/usr/local/bin +freebsd/11.4 python=2.7,3.7 python_dir=/usr/local/bin freebsd/12.1 python=3.6,2.7 python_dir=/usr/local/bin freebsd/12.2 python=3.7,2.7 python_dir=/usr/local/bin osx/10.11 python=2.7 python_dir=/usr/local/bin