ansible-test - Add support for more remotes.

pull/78089/head
Matt Clay 2 years ago
parent 5666c6d6a3
commit 24d91f552c

@ -0,0 +1,5 @@
minor_changes:
- ansible-test - Add support for provisioning remotes which require ``doas`` for become.
- ansible-test - Add support for provisioning Ubuntu 20.04 remote instances.
- ansible-test - Add support for provisioning Alpine 3.16 remote instances.
- ansible-test - Add support for provisioning Fedora 35 and 36 remote instances.

@ -1,3 +1,8 @@
alpine/3.16 python=3.10 become=doas provider=aws arch=x86_64
alpine become=doas provider=aws arch=x86_64
fedora/35 python=3.10 become=sudo provider=aws arch=x86_64
fedora/36 python=3.10 become=sudo provider=aws arch=x86_64
fedora become=sudo provider=aws arch=x86_64
freebsd/12.3 python=3.8 python_dir=/usr/local/bin become=su provider=aws arch=x86_64
freebsd/13.0 python=3.7,3.8,3.9 python_dir=/usr/local/bin become=su provider=aws arch=x86_64
freebsd/13.1 python=3.8,3.7,3.9,3.10 python_dir=/usr/local/bin become=su provider=aws arch=x86_64
@ -9,5 +14,6 @@ rhel/8.5 python=3.6,3.8,3.9 become=sudo provider=aws arch=x86_64
rhel/8.6 python=3.6,3.8,3.9 become=sudo provider=aws arch=x86_64
rhel/9.0 python=3.9 become=sudo provider=aws arch=x86_64
rhel become=sudo provider=aws arch=x86_64
ubuntu/20.04 python=3.8,3.9 become=sudo provider=aws arch=x86_64
ubuntu/22.04 python=3.10 become=sudo provider=aws arch=x86_64
ubuntu become=sudo provider=aws arch=x86_64

@ -22,6 +22,25 @@ class Become(metaclass=abc.ABCMeta):
"""Return the given command, if any, with privilege escalation."""
class Doas(Become):
"""Become using 'doas'."""
@property
def method(self): # type: () -> str
"""The name of the Ansible become plugin that is equivalent to this."""
raise NotImplementedError('Ansible has no built-in doas become plugin.')
def prepare_command(self, command): # type: (t.List[str]) -> t.List[str]
"""Return the given command, if any, with privilege escalation."""
become = ['doas', '-n']
if command:
become.extend(['sh', '-c', ' '.join(shlex.quote(c) for c in command)])
else:
become.extend(['-s'])
return become
class Su(Become):
"""Become using 'su'."""
@property

@ -80,6 +80,66 @@ pip_install() {
done
}
bootstrap_remote_alpine()
{
py_pkg_prefix="py3"
packages="
bash
gcc
python3-dev
${py_pkg_prefix}-pip
"
if [ "${controller}" ]; then
packages="
${packages}
${py_pkg_prefix}-cryptography
${py_pkg_prefix}-packaging
${py_pkg_prefix}-yaml
${py_pkg_prefix}-jinja2
${py_pkg_prefix}-resolvelib
"
fi
while true; do
# shellcheck disable=SC2086
apk add -q ${packages} \
&& break
echo "Failed to install packages. Sleeping before trying again..."
sleep 10
done
}
bootstrap_remote_fedora()
{
py_pkg_prefix="python3"
packages="
gcc
${py_pkg_prefix}-devel
"
if [ "${controller}" ]; then
packages="
${packages}
${py_pkg_prefix}-cryptography
${py_pkg_prefix}-jinja2
${py_pkg_prefix}-packaging
${py_pkg_prefix}-pyyaml
${py_pkg_prefix}-resolvelib
"
fi
while true; do
# shellcheck disable=SC2086
dnf install -q -y ${packages} \
&& break
echo "Failed to install packages. Sleeping before trying again..."
sleep 10
done
}
bootstrap_remote_freebsd()
{
packages="
@ -271,21 +331,42 @@ bootstrap_remote_ubuntu()
packages="
gcc
${py_pkg_prefix}-dev
${py_pkg_prefix}-pip
${py_pkg_prefix}-venv
python${python_version}-dev
python3-pip
python${python_version}-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.
cryptography_pkg="${py_pkg_prefix}-cryptography"
jinja2_pkg="${py_pkg_prefix}-jinja2"
packaging_pkg="${py_pkg_prefix}-packaging"
pyyaml_pkg="${py_pkg_prefix}-yaml"
resolvelib_pkg="${py_pkg_prefix}-resolvelib"
# Declare platforms which do not have supporting OS packages available.
# For these ansible-test will use pip to install the requirements instead.
# Only the platform is checked since Ubuntu shares Python packages across Python versions.
case "${platform_version}" in
"20.04")
jinja2_pkg="" # too old
resolvelib_pkg="" # not available
;;
esac
packages="
${packages}
${py_pkg_prefix}-cryptography
${py_pkg_prefix}-jinja2
${py_pkg_prefix}-packaging
${py_pkg_prefix}-yaml
${cryptography_pkg}
${jinja2_pkg}
${packaging_pkg}
${pyyaml_pkg}
${resolvelib_pkg}
"
if [ "${platform_version}/${python_version}" = "20.04/3.9" ]; then
# Install pyyaml using pip so libyaml support is available on Python 3.9.
# The OS package install (which is installed by default) only has a .so file for Python 3.8.
pip_install "--upgrade pyyaml"
fi
fi
while true; do
@ -313,6 +394,8 @@ bootstrap_remote()
python_package_version="$(echo "${python_version}" | tr -d '.')"
case "${platform}" in
"alpine") bootstrap_remote_alpine ;;
"fedora") bootstrap_remote_fedora ;;
"freebsd") bootstrap_remote_freebsd ;;
"macos") bootstrap_remote_macos ;;
"rhel") bootstrap_remote_rhel ;;

Loading…
Cancel
Save