Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for debian >=10 to bootstrap.py #800

Merged
merged 8 commits into from
Mar 21, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 11 additions & 6 deletions bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@

logger = logging.getLogger(__name__)


# This function is needed both by the process starting this script, and by the
# TLJH installer that this script execs in the end. Make sure its replica at
# tljh/utils.py stays in sync with this version!
Expand Down Expand Up @@ -199,12 +198,15 @@ def get_os_release_variable(key):
# Require Ubuntu 18.04+
distro = get_os_release_variable("ID")
version = float(get_os_release_variable("VERSION_ID"))
if distro != "ubuntu":
print("The Littlest JupyterHub currently supports Ubuntu Linux only")
if distro not in ["ubuntu", "debian"]:
print("The Littlest JupyterHub currently supports Ubuntu or Debian Linux only")
sys.exit(1)
elif float(version) < 18.04:
elif distro == "ubuntu" and float(version) < 18.04:
print("The Littlest JupyterHub requires Ubuntu 18.04 or higher")
sys.exit(1)
elif distro == "debian" and float(version) < 10:
print("The Littlest JupyterHub requires Debian 10 or higher")
sys.exit(1)

# Require Python 3.6+
if sys.version_info < (3, 6):
Expand All @@ -224,6 +226,7 @@ def get_os_release_variable(key):
"For local development, see http://tljh.jupyter.org/en/latest/contributing/dev-setup.html"
)
sys.exit(1)
return distro, version


class ProgressPageRequestHandler(SimpleHTTPRequestHandler):
Expand Down Expand Up @@ -259,7 +262,7 @@ def main():
start a local webserver temporarily and report its installation progress via
a web site served locally on port 80.
"""
ensure_host_system_can_install_tljh()
distro, version = ensure_host_system_can_install_tljh()

# Various related constants
install_prefix = os.environ.get("TLJH_INSTALL_PREFIX", "/opt/tljh")
Expand Down Expand Up @@ -345,7 +348,8 @@ def serve_forever(server):
["apt-get", "install", "--yes", "software-properties-common"],
env=apt_get_adjusted_env,
)
run_subprocess(["add-apt-repository", "universe", "--yes"])
if distro == "ubuntu":
run_subprocess(["add-apt-repository", "universe", "--yes"])
jochym marked this conversation as resolved.
Show resolved Hide resolved
run_subprocess(["apt-get", "update"])
run_subprocess(
[
Expand All @@ -356,6 +360,7 @@ def serve_forever(server):
"python3-venv",
"python3-pip",
"git",
"sudo",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume sudo is installed in ubuntu by default, but needs to be installed in debian - is that correct? If so, let's add an inline comment about it!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sudo is. indeed, not installed in Debian by default. But adding it here is harmless if it is installed and fixes it for Debian.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is OK, even if it's pre-installed in Ubuntu this acts as documentation that sudo is required. It's also useful if someone uses a custom Ubuntu cloud image with minimal dependencies.

On the other hand https://tljh.jupyter.org/en/latest/install/custom-server.html#step-1-installing-the-littlest-jupyterhub mentions sudo apt install python3 python3-dev git curl is a pre-requisite so we should decide what is a prerequisite, and what should be managed by bootstrap.py

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What workflow were you using to run bootstrap.py? The official instructions say curl -L https://tljh.jupyter.org/bootstrap.py | sudo -E python3 - --admin <admin-user-name> so sudo needs to be installed before running bootstrap.py

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. But since I needed to modify the script and I never run scripts from the pipe to sudo I downloaded the script with wget and run it with python. If the sudo was not installed previously, the installation would fail.
Note that, there is no harm in requiring installation of already installed component.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, presumably you're running bootstrap.py as root then? That's why I asked for your workflow 😄

It looks like the sudo package is only required for some config files as far as the installer is concerned:

with open("/etc/sudoers.d/jupyterhub-admins", "w") as f:
# JupyterHub admins should have full passwordless sudo access
f.write("%jupyterhub-admins ALL = (ALL) NOPASSWD: ALL\n")
# `sudo -E` should preserve the $PATH we set. This allows
# admins in jupyter terminals to do `sudo -E pip install <package>`,
# `pip` is in the $PATH we set in jupyterhub_config.py to include the user conda env.
f.write("Defaults exempt_group = jupyterhub-admins\n")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I was running it from root. Sudo is required in ubuntu install and probably (?) during some admin tasks. Debian is not using it for admin, but it is fully supported there.

],
env=apt_get_adjusted_env,
)
Expand Down