jupyterhub / the-littlest-jupyterhub

Simple JupyterHub distribution for 1-100 users on a single server
https://tljh.jupyter.org
BSD 3-Clause "New" or "Revised" License
1.04k stars 340 forks source link

Community maintained: CentOS 7 Support #601

Open adamboutcher opened 4 years ago

adamboutcher commented 4 years ago

Can we get some CentOS support with the installer? I'm not a python dev so I can't write code but I managed to remove the parts that were Ubuntu specific.

Basically the Ubuntu detection could check for Cent OS and run yum commands instead of apt-get

This was my very rough guide/edits

yum install -y epel-release
yum install -y python3 python3-devel git curl python3-virtualenv python3-pip
yum groupinstall -y "Development Tools"
yum install -y libcurl libcurl-devel openssl-libs openssl-devel

curl -sL https://rpm.nodesource.com/setup_10.x | bash -
yum install -y nodejs

Edit bootstrap.py - Remove apt and ubuntu checks and check for systemd, change pip to pip3
Edit /opt/tljh/hub/lib64/python3.6/site-packages/tljh/installer.py - Remove all apt checks
Edit bootstrap.py - Remove line that does pip3 update on and the repo

Edit /opt/tljh/hub/lib64/python3.6/site-packages/systemdspawner/systemd.py - Comment out this line (55) "run_cmd.append('--property=WorkingDirectory={}'.format(shlex.quote(working_dir)))"
welcome[bot] commented 4 years ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:

avattaruri commented 3 years ago

I would also be interested in installing on CentOS or RHEL. Are there any updates on this issue?

gregory-lee-bartholomew commented 3 years ago

I was able to get this installed on Fedora 33 today with just a few tweaks. Basically, I just ran the commands from bootstrap.py by hand in a bash shell. I would suggest that someone add a bootstrap-fedora.sh file with something close to the below to make an installer for Fedora Linux and its derivatives. Instead of deleting the lines in installer.py, as the patch does, those lines should probably be wrapped with a conditional that fails when the detected OS is a Fedora derivative.

Just my two cents.

# Many of the below packages probably aren't necessary. I copied several of them from
# https://fedoramagazine.org/jupyter-and-data-science-in-fedora/
dnf install python3-notebook mathjax sscg python3-seaborn python3-lxml python3-basemap python3-scikit-image python3-scikit-learn python3-sympy python3-dask+dataframe python3-nltk python3-h5py python3-pip git nodejs openssl-devel libcurl-devel

# Not sure if this is necessary
dnf groupinstall 'Development Tools'

mkdir -p /opt/tljh/hub
touch /opt/tljh/installer.log
chmod 500 /opt/tljh/installer.log
python3 -m venv /opt/tljh/hub

# The versions were taken directly from bootstrap.py.
# Newer versions are available and will install by default if the version is left unspecified,
# but I haven't tested them.
/opt/tljh/hub/bin/pip install --upgrade pip=='20.0.*'
/opt/tljh/hub/bin/pip install --upgrade pycurl=='7.43.*'

# This seems to be necessary at the moment to get LDAP authentication working
# (https://github.com/jupyterhub/ldapauthenticator/issues/171)
/opt/tljh/hub/bin/pip install -Iv jupyterhub-ldapauthenticator ldap3=='2.7'

/opt/tljh/hub/bin/pip install --upgrade git+https://github.com/jupyterhub/the-littlest-jupyterhub.git

patch /opt/tljh/hub/lib64/python3.9/site-packages/tljh/installer.py << END
--- /root/installer.py.original 2021-03-12 16:17:21.841139058 -0600
+++ /opt/tljh/hub/lib64/python3.9/site-packages/tljh/installer.py   2021-03-12 16:37:09.995193222 -0600
@@ -43,87 +43,10 @@
 logger = logging.getLogger("tljh")

 def ensure_node():
-    """
-    Ensure nodejs from nodesource is installed
-    """
-    key = b"""
------BEGIN PGP PUBLIC KEY BLOCK-----
-Version: GnuPG v1
-Comment: GPGTools - https://gpgtools.org
-
-mQINBFObJLYBEADkFW8HMjsoYRJQ4nCYC/6Eh0yLWHWfCh+/9ZSIj4w/pOe2V6V+
-W6DHY3kK3a+2bxrax9EqKe7uxkSKf95gfns+I9+R+RJfRpb1qvljURr54y35IZgs
-fMG22Np+TmM2RLgdFCZa18h0+RbH9i0b+ZrB9XPZmLb/h9ou7SowGqQ3wwOtT3Vy
-qmif0A2GCcjFTqWW6TXaY8eZJ9BCEqW3k/0Cjw7K/mSy/utxYiUIvZNKgaG/P8U7
-89QyvxeRxAf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/RVzeZjnTGwhN1DnCDy1I66hUTgehONsfVanuP1
-PZKoL38EAxsMzdYgkYH6T9a4wJH/IPt+uuFTFFy3o8TKMvKaJk98+Jsp2X/QuNxh
-qpcIGaVbtQ1bn7m+k5Qe/fz+bFuUeXPivafLLlGc6KbdgMvSW9EVMO7yBy/2JE15
-ZJgl7lXKLQ31VQPAHT3an5IV2C/ie12eEqZWlnCiHV/wT+zhOkSpWdrheWfBT+ac
-hR4jDH80AS3F8jo3byQATJb3RoCYUCVc3u1ouhNZa5yLgYZ/iZkpk5gKjxHPudFb
-DdWjbGflN9k17VCf4Z9yAb9QMqHzHwIGXrb7ryFcuROMCLLVUp07PrTrRxnO9A/4
-xxECi0l/BzNxeU1gK88hEaNjIfviPR/h6Gq6KOcNKZ8rVFdwFpjbvwHMQBWhrqfu
-G3KaePvbnObKHXpfIKoAM7X2qfO+IFnLGTPyhFTcrl6vZBTMZTfZiC1XDQLuGUnd
-sckuXINIU3DFWzZGr0QrqkuE/jyr7FXeUJj9B7cLo+s/TXo+RaVfi3kOc9BoxIvy
-/qiNGs/TKy2/Ujqp/affmIMoMXSozKmga81JSwkADO1JMgUy6dApXz9kP4EE3g==
-=CLGF
------END PGP PUBLIC KEY BLOCK-----
-    """.strip()
-    apt.trust_gpg_key(key)
-    apt.add_source('nodesource', 'https://deb.nodesource.com/node_10.x', 'main')
-    apt.install_packages(['nodejs'])
+    pass

 def remove_chp():
-    """
-    Ensure CHP is not running
-    """
-    if os.path.exists("/etc/systemd/system/configurable-http-proxy.service"):
-        if systemd.check_service_active('configurable-http-proxy.service'):
-            try:
-                systemd.stop_service('configurable-http-proxy.service')
-            except subprocess.CalledProcessError:
-                logger.info("Cannot stop configurable-http-proxy...")
-        if systemd.check_service_enabled('configurable-http-proxy.service'):
-            try:
-                systemd.disable_service('configurable-http-proxy.service')
-            except subprocess.CalledProcessError:
-                logger.info("Cannot disable configurable-http-proxy...")
-        try:
-            systemd.uninstall_unit('configurable-http-proxy.service')
-        except subprocess.CalledProcessError:
-            logger.info("Cannot uninstall configurable-http-proxy...")
-
+    pass

 def ensure_jupyterhub_service(prefix):
     """
@@ -207,17 +130,6 @@
     hub environment be installed with pip prevents accidental mixing of python
     and conda packages!
     """
-    # Install pycurl. JupyterHub prefers pycurl over SimpleHTTPClient automatically
-    # pycurl is generally more bugfree - see https://github.com/jupyterhub/the-littlest-jupyterhub/issues/289
-    # build-essential is also generally useful to everyone involved, and required for pycurl
-    apt.install_packages([
-        'libssl-dev',
-        'libcurl4-openssl-dev',
-        'build-essential'
-    ])
-    conda.ensure_pip_packages(prefix, [
-        'pycurl==7.43.*'
-    ])

     conda.ensure_pip_packages(
         prefix,
END

patch /opt/tljh/hub/lib64/python3.9/site-packages/tljh/apt.py << END
--- /root/apt.py.original   2021-03-13 00:05:17.671405637 -0600
+++ /opt/tljh/hub/lib64/python3.9/site-packages/tljh/apt.py 2021-03-12 16:25:58.924233499 -0600
@@ -7,47 +7,18 @@

 def trust_gpg_key(key):
-    """
-    Trust given GPG public key.
-
-    key is a GPG public key (bytes) that can be passed to apt-key add via stdin.
-    """
-    # If gpg2 doesn't exist, install it.
-    if not os.path.exists('/usr/bin/gpg2'):
-        install_packages(['gnupg2'])
-    utils.run_subprocess(['apt-key', 'add', '-'], input=key)
-
+    pass

 def add_source(name, source_url, section):
-    """
-    Add a debian package source.
-
-    distro is determined from /etc/os-release
-    """
-    # lsb_release is not installed in most docker images by default
-    distro = subprocess.check_output(['/bin/bash', '-c', 'source /etc/os-release && echo ${VERSION_CODENAME}'], stderr=subprocess.STDOUT).decode().strip()
-    line = f'deb {source_url} {distro} {section}\n'
-    with open(os.path.join('/etc/apt/sources.list.d/', name + '.list'), 'a+') as f:
-        # Write out deb line only if it already doesn't exist
-        f.seek(0)
-        if line not in f.read():
-            f.write(line)
-            f.truncate()
-            utils.run_subprocess(['apt-get', 'update', '--yes'])
-
+    pass

 def install_packages(packages):
     """
-    Install debian packages
+    Install packages
     """
-    # Check if an apt-get update is required
-    if len(os.listdir('/var/lib/apt/lists')) == 0:
-        utils.run_subprocess(['apt-get', 'update', '--yes'])
     env = os.environ.copy()
-    # Stop apt from asking questions!
-    env['DEBIAN_FRONTEND'] = 'noninteractive'
     utils.run_subprocess([
-        'apt-get',
+        'dnf',
         'install',
-        '--yes'
+        '-y'
     ] + packages, env=env)
END

# This failed for me the first time through. It errored out while running
# /opt/tljh/user/bin/jupyter lab build --minimize=False --dev-build=False
# so I ran the above line by hand and it worked. Then I re-ran the below
# command and the installation completed successfully. Some google'ing
# suggested that the error was a race condition
# (https://github.com/pypa/pipenv/issues/943#issuecomment-338438806)
/opt/tljh/hub/bin/python3 -m tljh.installer --admin adminuser
adamboutcher commented 3 years ago

I was able to get this installed on Fedora 33 today with just a few tweaks. Basically, I just ran the commands from bootstrap.py by hand in a bash shell. I would suggest that someone add a bootstrap-fedora.sh file with something close to the below to make an installer for Fedora Linux and its derivatives. Instead of deleting the lines in installer.py, as the patch does, those lines should probably be wrapped with a conditional that fails when the detected OS is a Fedora derivative.

Might be worth doing a wget/curl on the gpg key rather than keeping it contained in the install file, that is if anyone pushes a file to the repo.

adamboutcher commented 3 years ago

If I get time and need to reinstall my tljh setup then I'll push a CentOS/Fedora installer.

aculich commented 3 years ago

@adamboutcher any chance you have a CentOS installer ready to push?

adamboutcher commented 3 years ago

Not yet no, work's been busy...

consideRatio commented 3 years ago

We've deliberated a bit about maintenance of a TLJH installation against other distributions than Ubuntu LTS, but for now I think the answer is that we won't try to go for that.

I've marked this as a "wontfix" issue to indicate that, but I figure it would be good to retain this issue as it contains a lot of effort to make a CentOS installation possible.

bash99 commented 1 year ago

I've use lxd/lxc to run a ubuntu 22.04 on centos 7, then install TLJH on it, works great. As the IT operator only give me a VM with centos 7.

Some tips: