[RESOLVED] Having issues getting coder_apps to appear in my Workspace

Hello, I have been familiarizing myself with Coder the past few days, and it is fantastic. I just have one thing that I'm getting pretty stuck on and I'm hoping that I can get some help. I am using the guacamole terraform provider by techBeck03, and it creates a guacamole connection that I can connect to at https://guac.example.com/#/client/abcxyz. I am trying to get that URL as a clickable link on my Coder Workspace, but I can't seem to figure out how to get it to appear. It seems logical that I could create a coder_app resource with the url set to the desired URL and external=true. While building the template doesn't give me issues, it doesn't actually display it anywhere. This is the primary reference material I am looking at: https://coder.com/docs/v2/latest/ides/web-ides I believe that the major disconnect is coming from how my resource is displayed in the Workspace, as I'm not using (what appears to be Kubernetes) in my workspace, I am using libvirt via dmacvicar's libvirt terraform provider. EDIT: It turns out that functionality of ALL coder_app's is dependent on the coder-agent being present on the terraform resources VMs, containers, etc. This apparently includes external apps.
Web IDEs - Coder v2 Docs
Learn how to configure web IDEs in your templates
24 Replies
Codercord
Codercord12mo ago
<#1178416549820895282>
Category
Help needed
Product
Coder OSS (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
Atif
Atif12mo ago
Can you share the template?
bamhm182 (BytePen)
bamhm182 (BytePen)OP12mo ago
Discord won't let me send it as one message, so I'm going to have to split it across a few...
terraform {
required_providers {
coder = { source = "coder/coder" }
libvirt = { source = "dmacvicar/libvirt" }
guacamole = { source = "techBeck03/guacamole"}
}
}

provider "libvirt" {}
provider "coder" {}
provider "guacamole" {}

data "coder_workspace" "me" {}

resource "coder_metadata" "deployment" {
resource_id = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}"
item {
key = "Guacamole URL"
value = format("%s%s", "https://guacamole.example.com/#/client/", base64encode(format("%s%s%s%s%s", guacamole_connection_rdp.rdp.identifier, base64decode("AA=="), "c", base64decode("AA=="), "postgresql")))
}
}

resource "coder_agent" "main" {
os = "linux"
arch = "amd64"
}

resource "coder_app" "guacamole" {
agent_id = coder_agent.main.id
slug = "guacamole"
display_name = "Guacamole"
url = "https://guacamole.example.com/#/"
external = true
}

resource "libvirt_domain" "domain" {
name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}"
...snip...
}
}

data "guacamole_connection_group" "group" {
path = data.coder_workspace.me.owner
}

resource "guacamole_connection_rdp" "rdp" {
name = data.coder_workspace.me.name
parent_identifier = data.guacamole_connection_group.group.identifier
...snip...
}
terraform {
required_providers {
coder = { source = "coder/coder" }
libvirt = { source = "dmacvicar/libvirt" }
guacamole = { source = "techBeck03/guacamole"}
}
}

provider "libvirt" {}
provider "coder" {}
provider "guacamole" {}

data "coder_workspace" "me" {}

resource "coder_metadata" "deployment" {
resource_id = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}"
item {
key = "Guacamole URL"
value = format("%s%s", "https://guacamole.example.com/#/client/", base64encode(format("%s%s%s%s%s", guacamole_connection_rdp.rdp.identifier, base64decode("AA=="), "c", base64decode("AA=="), "postgresql")))
}
}

resource "coder_agent" "main" {
os = "linux"
arch = "amd64"
}

resource "coder_app" "guacamole" {
agent_id = coder_agent.main.id
slug = "guacamole"
display_name = "Guacamole"
url = "https://guacamole.example.com/#/"
external = true
}

resource "libvirt_domain" "domain" {
name = "coder-${data.coder_workspace.me.owner}-${data.coder_workspace.me.name}"
...snip...
}
}

data "guacamole_connection_group" "group" {
path = data.coder_workspace.me.owner
}

resource "guacamole_connection_rdp" "rdp" {
name = data.coder_workspace.me.name
parent_identifier = data.guacamole_connection_group.group.identifier
...snip...
}
...snip... ...snip... In the above example, I would like resource.coder_app.guacamole to appear anywhere on the workspace, and it seems like it would appear near the resource.coder_agent.main, but it doesn't appear anywhere. I was looking at it again, and there were quite a few irrelevant lines in there. I condensed it down to show a more direct example.
Atif
Atif12mo ago
If you open https://guacamole.example.com/#/" in your browser can you accesss the rdp desktop?
bamhm182 (BytePen)
bamhm182 (BytePen)OP12mo ago
Not quite, but it would achieve the same functionality. That url is just a url. It doesn't matter if it's guacamole, Google, whatever, just trying to get a button with a link to appear. The garbage up in coder_metadata.deployment is the actual code that generates the actual URL needed to drop right into RDP. It works as a stop gap because I can just click that metadata item to copy it, open a new tab, and paste it in the address bar.
Phorcys
Phorcys12mo ago
hey @bamhm182 (BytePen) you could post the template as a file otherwise i'm looking into your issue on my end, it seems that there's no issue with your template
bamhm182 (BytePen)
bamhm182 (BytePen)OP12mo ago
I have a bunch of stuff that isn't relevant. I will get a simple example together and upload a file with screenshots.
Phorcys
Phorcys12mo ago
yeah, the only relevant part should be
resource "coder_app" "guacamole" {
agent_id = coder_agent.main.id
slug = "guacamole"
display_name = "Guacamole"
url = "https://guacamole.example.com/#/"
external = true
}
resource "coder_app" "guacamole" {
agent_id = coder_agent.main.id
slug = "guacamole"
display_name = "Guacamole"
url = "https://guacamole.example.com/#/"
external = true
}
it's just that having the entire template is almost always better to help not missing out on stuff :-)
bamhm182 (BytePen)
bamhm182 (BytePen)OP12mo ago
For sure. I appreciate it. I'm going to generate a template with digital ocean, since that should be easy to wholly recreate on your end.
Phorcys
Phorcys12mo ago
honestly don't bother, it should definitely show up with any provider do you have multiple coder_agents declared by any chance ?
bamhm182 (BytePen)
bamhm182 (BytePen)OP12mo ago
Yeah, that's why I figured I'd create a simple one that you'd be able to replicate without having to have a libvirt host.
Phorcys
Phorcys12mo ago
what coder version are you running ?
bamhm182 (BytePen)
bamhm182 (BytePen)OP12mo ago
v2.4.0+d19a762 I just have a single coder_agent I bailed on creating a new DO template and just uploaded the libvirt one I'm using. Then I had the idea to modify my existing one to include the exact same discord coder_app (copy-pasted) that I have in my libvirt template. For some reason it works there... Actually, I'm having some issues with DO as well... Let me track down some issues that may or may not be related and follow up in a minute.
Phorcys
Phorcys12mo ago
hey, I do get the guacamole app to show up when using the exact same app definition
No description
Phorcys
Phorcys12mo ago
@bamhm182 (BytePen)
bamhm182 (BytePen)
bamhm182 (BytePen)OP12mo ago
Okay... There must be something weird going on with my setup, then... I think that rather than blindly displaying the links, Coder does some sort of check, and if it fails, it doesn't display the link. I say this because my DO template has issues displaying the CPU/Disk/RAM metadata, and the Discord button appears to try and load as part of the same logic.
Phorcys
Phorcys12mo ago
is the web terminal accessible ? if it isn't then your issue would make sense oh yeah, i just looked at your template the coder agent has to run within the container/vm for anything to work properly otherwise it's just gonna load indefinitely
bamhm182 (BytePen)
bamhm182 (BytePen)OP12mo ago
That makes sense. I wasn't tracking there was a coder agent until right now. The external coder_app's require that coder-agent as well? It would appear that the other part of my problems exist due to flaky networking. I thought I had my podman networking figured out, but it looks like it's still not quite there.
Phorcys
Phorcys12mo ago
i'm not sure if you can do so using a vm, but you have to somehow get the script running wrong reply sorry but yes they do, because the web page's logic is to only show this part of the ui when the agent is reachable in your case, the script is accessible in the coder_agent.main.init_script
bamhm182 (BytePen)
bamhm182 (BytePen)OP12mo ago
That's kind of annoying, but also makes a lot of sense... Also, that explains why I can't get DO to work. Looking at the init script, it calls back to your coder instance to set up the service. Considering DO can't resolve my domain, it isn't able to set it up.
Phorcys
Phorcys12mo ago
indeed!
bamhm182 (BytePen)
bamhm182 (BytePen)OP12mo ago
I appreciate all of your help! I think I'm going to just stick with the currently implemented functionality to create the URL I can copy paste into a new tab for now
Codercord
Codercord6mo ago
@Phorcys closed the thread.
Want results from more Discord servers?
Add your server