()
Sets up user groups & sudo rules
Sets up user groups & sudo rules
Sets up user groups & sudo rules
def ensure_usergroups():
    """
    Sets up user groups & sudo rules
    """
    user.ensure_group("jupyterhub-admins")
    user.ensure_group("jupyterhub-users")

    logger.info("Granting passwordless sudo to JupyterHub admins...")
    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")
def ensure_usergroups ( ) : user . ensure_group ( "jupyterhub-admins" ) user . ensure_group ( "jupyterhub-users" ) logger . info ( "Granting passwordless sudo to JupyterHub admins..." ) 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" )