From 6513453310cdfc42c44a4b879535a8f0795c0295 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Thu, 28 Apr 2022 11:17:46 -0700 Subject: [PATCH] ansible-test - Add support for remote Ubuntu VMs. --- .../fragments/ansible-test-ubuntu-remote.yml | 2 ++ .../ansible_test/_data/completion/remote.txt | 2 ++ .../ansible_test/_internal/host_profiles.py | 2 ++ .../_util/target/setup/bootstrap.sh | 34 +++++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 changelogs/fragments/ansible-test-ubuntu-remote.yml diff --git a/changelogs/fragments/ansible-test-ubuntu-remote.yml b/changelogs/fragments/ansible-test-ubuntu-remote.yml new file mode 100644 index 00000000000..303f8c1eb52 --- /dev/null +++ b/changelogs/fragments/ansible-test-ubuntu-remote.yml @@ -0,0 +1,2 @@ +minor_changes: + - ansible-test - Add support for Ubuntu VMs using the ``--remote`` option. diff --git a/test/lib/ansible_test/_data/completion/remote.txt b/test/lib/ansible_test/_data/completion/remote.txt index ddaace3c3b6..68d02e90c7d 100644 --- a/test/lib/ansible_test/_data/completion/remote.txt +++ b/test/lib/ansible_test/_data/completion/remote.txt @@ -6,3 +6,5 @@ macos python_dir=/usr/local/bin provider=parallels rhel/7.9 python=2.7 provider=aws rhel/8.5 python=3.6,3.8,3.9 provider=aws rhel provider=aws +ubuntu/22.04 python=3.10 provider=aws +ubuntu provider=aws diff --git a/test/lib/ansible_test/_internal/host_profiles.py b/test/lib/ansible_test/_internal/host_profiles.py index aa5665c5dc7..e5718b7ed00 100644 --- a/test/lib/ansible_test/_internal/host_profiles.py +++ b/test/lib/ansible_test/_internal/host_profiles.py @@ -571,6 +571,8 @@ class PosixRemoteProfile(ControllerHostProfile[PosixRemoteConfig], RemoteProfile become = Sudo() elif self.config.platform == 'rhel': become = Sudo() + elif self.config.platform == 'ubuntu': + become = Sudo() else: raise NotImplementedError(f'Become support has not been implemented for platform "{self.config.platform}" and user "{settings.user}" is not root.') diff --git a/test/lib/ansible_test/_util/target/setup/bootstrap.sh b/test/lib/ansible_test/_util/target/setup/bootstrap.sh index debcb6c16a0..329fa684c13 100644 --- a/test/lib/ansible_test/_util/target/setup/bootstrap.sh +++ b/test/lib/ansible_test/_util/target/setup/bootstrap.sh @@ -266,6 +266,39 @@ bootstrap_remote_rhel_pinned_pip_packages() pip_install "${pip_packages}" } +bootstrap_remote_ubuntu() +{ + py_pkg_prefix="python3" + + packages=" + gcc + ${py_pkg_prefix}-dev + ${py_pkg_prefix}-pip + ${py_pkg_prefix}-venv + " + + if [ "${controller}" ]; then + # The resolvelib package is not listed here because the available version (0.8.1) is incompatible with ansible. + # Instead, ansible-test will install it using pip. + packages=" + ${packages} + ${py_pkg_prefix}-cryptography + ${py_pkg_prefix}-jinja2 + ${py_pkg_prefix}-packaging + ${py_pkg_prefix}-yaml + " + fi + + while true; do + # shellcheck disable=SC2086 + apt-get update -qq -y && \ + DEBIAN_FRONTEND=noninteractive apt-get install -qq -y --no-install-recommends ${packages} \ + && break + echo "Failed to install packages. Sleeping before trying again..." + sleep 10 + done +} + bootstrap_docker() { # Required for newer mysql-server packages to install/upgrade on Ubuntu 16.04. @@ -284,6 +317,7 @@ bootstrap_remote() "freebsd") bootstrap_remote_freebsd ;; "macos") bootstrap_remote_macos ;; "rhel") bootstrap_remote_rhel ;; + "ubuntu") bootstrap_remote_ubuntu ;; esac done }