Creating a JupyterLab instance

It might be simple, but I can't get a JupyterLab instance going. The goal is to spin up an AWS EC2 instance. I can do that with VSCode without issue. I add the module from here but get a few errors on launch - https://registry.coder.com/modules/jupyterlab Then I see this doco and it seems to be what the module is meant to do? https://coder.com/docs/admin/templates/extending-templates/web-ides#jupyterlab Can't get that working either. I suspect I am confusing the above doco and just using the module incorrectly and mixing it with the vscode out of the box template. Code below
resource "coder_agent" "main" {
os = "linux"
arch = "amd64"
dir = "/home/coder"

startup_script = <<-EOT
set -e

pip3 install jupyterlab

# install and start JupyterLab
~/.local/bin/jupyter lab --ServerApp.base_url=/@${data.coder_workspace_owner.me.name}/${data.coder_workspace.me.name}/apps/jupyter --ServerApp.token='' --ip='*'
EOT
}

module "jupyterlab" {
source = "registry.coder.com/modules/jupyterlab/coder"
version = "1.0.23"
agent_id = coder_agent.main.id
}

locals {
linux_user = "coder"
user_data = <<-EOT
Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0

--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"

#cloud-config
cloud_final_modules:
- [scripts-user, always]
hostname: ${lower(data.coder_workspace.me.name)}
users:
- name: ${local.linux_user}
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash

--//
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"

#!/bin/bash
sudo -u ${local.linux_user} sh -c '${try(coder_agent.main.init_script, "")}'
--//--
EOT
}
resource "coder_agent" "main" {
os = "linux"
arch = "amd64"
dir = "/home/coder"

startup_script = <<-EOT
set -e

pip3 install jupyterlab

# install and start JupyterLab
~/.local/bin/jupyter lab --ServerApp.base_url=/@${data.coder_workspace_owner.me.name}/${data.coder_workspace.me.name}/apps/jupyter --ServerApp.token='' --ip='*'
EOT
}

module "jupyterlab" {
source = "registry.coder.com/modules/jupyterlab/coder"
version = "1.0.23"
agent_id = coder_agent.main.id
}

locals {
linux_user = "coder"
user_data = <<-EOT
Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0

--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"

#cloud-config
cloud_final_modules:
- [scripts-user, always]
hostname: ${lower(data.coder_workspace.me.name)}
users:
- name: ${local.linux_user}
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash

--//
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"

#!/bin/bash
sudo -u ${local.linux_user} sh -c '${try(coder_agent.main.init_script, "")}'
--//--
EOT
}
Overall a end to end template would be nice. Happy to put one together once I understand it better.
JupyterLab - Coder Registry
A module that adds JupyterLab in your Coder template.
Web IDEs and Coder Apps - Coder Docs
Add and configure Web IDEs in your templates as coder apps
From An unknown user
From An unknown user
5 Replies
Codercord
Codercord2mo ago
<#1310393669009932349>
Category
Help needed
Product
code-server
Platform
Linux
Logs
Please post any relevant logs/error messages.
Chris2pi
Chris2piOP2mo ago
Error message from user data -
trap waitonexit EXIT
+ mktemp -d -t coder.XXXXXX
+ BINARY_DIR=/tmp/coder.OQMQ55
+ BINARY_NAME=coder
+ BINARY_URL=https://FQDN.example
+ cd /tmp/coder.OQMQ55
+ :
+ status=
+ command -v curl
+ curl -fsSL --compressed https://FQDN.example -o coder
+ break
+ chmod +x coder
+ [ -n ]
+ export CODER_AGENT_AUTH=token
+ export CODER_AGENT_URL=https://FQDN.example
+ + head -n1
./coder --version
+ output=Coder v2.16.1+379ced6 Thu Oct 24 19:48:48 UTC 2024
+ echo Coder v2.16.1+379ced6 Thu Oct 24 19:48:48 UTC 2024
+ grep -q Coder
+ exec ./coder agent
2024-11-24 23:39:35.189 [info] agent is starting now url=https://FQDN.example auth=token version=v2.16.1+379ced6
2024-11-24 23:39:35.189 [debu] http server listening addr=127.0.0.1:6060 name=pprof
Encountered an error running "coder agent", see "coder agent --help" for more information
error: CODER_AGENT_TOKEN or CODER_AGENT_TOKEN_FILE must be set for token auth
2024-11-24 23:39:35,194 - cc_scripts_user.py[WARNING]: Failed to run module scripts-user (scripts in /var/lib/cloud/instance/scripts)
2024-11-24 23:39:35,194 - util.py[WARNING]: Running module scripts-user (<module 'cloudinit.config.cc_scripts_user' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_scripts_user.py'>) failed
trap waitonexit EXIT
+ mktemp -d -t coder.XXXXXX
+ BINARY_DIR=/tmp/coder.OQMQ55
+ BINARY_NAME=coder
+ BINARY_URL=https://FQDN.example
+ cd /tmp/coder.OQMQ55
+ :
+ status=
+ command -v curl
+ curl -fsSL --compressed https://FQDN.example -o coder
+ break
+ chmod +x coder
+ [ -n ]
+ export CODER_AGENT_AUTH=token
+ export CODER_AGENT_URL=https://FQDN.example
+ + head -n1
./coder --version
+ output=Coder v2.16.1+379ced6 Thu Oct 24 19:48:48 UTC 2024
+ echo Coder v2.16.1+379ced6 Thu Oct 24 19:48:48 UTC 2024
+ grep -q Coder
+ exec ./coder agent
2024-11-24 23:39:35.189 [info] agent is starting now url=https://FQDN.example auth=token version=v2.16.1+379ced6
2024-11-24 23:39:35.189 [debu] http server listening addr=127.0.0.1:6060 name=pprof
Encountered an error running "coder agent", see "coder agent --help" for more information
error: CODER_AGENT_TOKEN or CODER_AGENT_TOKEN_FILE must be set for token auth
2024-11-24 23:39:35,194 - cc_scripts_user.py[WARNING]: Failed to run module scripts-user (scripts in /var/lib/cloud/instance/scripts)
2024-11-24 23:39:35,194 - util.py[WARNING]: Running module scripts-user (<module 'cloudinit.config.cc_scripts_user' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_scripts_user.py'>) failed
Atif
Atif2mo ago
Hi. Your coder_agent is missing the auth argument. I would suggest starting with the template from here: https://github.com/coder/coder/tree/main/examples/templates/aws-linux This already has the jetbrains-gateway module configured
GitHub
coder/examples/templates/aws-linux at main · coder/coder
Provision remote development environments via Terraform - coder/coder
Phorcys
Phorcys5d ago
hey @Chris2pi, any luck? closing as stale, feel free to reopen
Codercord
Codercord5d ago
@Phorcys closed the thread.

Did you find this page helpful?