I'm trying to deploy a Windows Server via Terraform that installs Node-RED,
It gets to the script and seems to stop after the nodejs installation. Can't seems to get PATH variables to stick, but when I log into the remote server after deploy, I can install just fine when I manually enter the the list of commands via cmd.
Any Windows / Terraform gurus out there that can help make this work?
Here is the script section of the Terraform provision using user_data
That kinda makes sense, as I've had build tools install line before the node-red install line.
I wasn't sure this was crucial to NR install, but thought maybe it was needed when installing additional nodes from the Palette Manager. I guess I'm wrong.
The reason I moved windows-build-tools down the to the bottom of the list is because I recall the code was causing an automatic restart on the windows machine, and subsequent things were not installing. I could be wrong on my observations.
So I will move it back up prior to NR install line, and maybe there is a "--NoRestart" kinda option?
I'm curious, windows-build-tools:
Does it even invoke a restart? Or is my script just failing on a different command?
Will report back what happens. Thanks a bunch, Julian.
My biggest thing yesterday was getting the PATH to update with a trailing C:\Python3
Terraform does it's thing, and I think it's doing what it does, but I get into Administrator account, and I type PATH in the cmd and I don't see it. So seems Python won't be located when needed to install these nodes.
When Python was installed I specified a simple C:\Python3 without the directory name containing the latest version number, only a 3, only because I wasn't savvy enough to grab the latest Python version, and update that destination directory, and add to the PATH.
I don't remember it requiring a reboot but then my Windows dev machine is so heavily used that anything could be true! I don't think it would do and I'm not even sure that npm could cause such a thing anyway. The only thing I can think of would be if you have already accessed and locked a file that it wants to replace.
You might be hitting a race condition. I think that when you set a path, you might need to restart the shell or maybe you are setting the path in the wrong shell? Not sure.
Noticed some cases I have to invoke refreshenv after the line to refresh the environment variables.
I then came across another hurdle when installing windows-build-tools via npm, as after it installs this package (I think containing Visual Studio), it will restart the machine automatically. This causes the remaining commands in the script to be discarded. I can't seem to invoke any sort of /NoRestart
I've gutted the whole thing but this script below and can't for the life of me seem to get nodejs installed:
Here is the script now, which successfully installs python3 and adds to the PATH.
Not sure what's internally going on in Windows when this deploys,
and when I check the chocolatey logs, I only see as far as a successful python install... nothing about nodejs when it's called to install via the script.
Do you need to install Node.js via choco? Could you deploy it directly? If not, what about Microsoft's new deployment tool - can't remember the name but I see they are pushing something new that is also open source.
There are several methods, and I don't need to use choco. It was the [seemingly] easiest to grasp and utilize once choco was installed. I had a version of nodejs installed and running at one point so I thought that would be viable, but now I notice there are different install packages like choco install nodejs.install. ... nodejs-ltsnodejs and can't remember which one and what version I tried to get happy results. Regardless, it's been a looong weekend of trial and error, and can't seem to get a working flow
Are you talking about Powershell? I'm going to try some alternatives today.
One of the reasons I don't like choco. It takes horrible liberties with where and how things are installed. I even created a package for it at one time. Thankfully someone else offered to share the maintenance, I can't even remember how to do it now.
Well, there is a standard executable install for Node.js that you can download from their website, that is how I install normally. But yes, you can control that from PowerShell easily enough. I have a bunch of PowerShell commands around that will recreate most of my working laptop should a disaster happen. Not really a script as such because I generally end up just running bits of it rather than the whole thing. Too much changes between rebuilds.
Yeah, this is why I'm working on this very diligently, though frustrating to say the least; To have a "pop-up-tent" of system states.
Terraform to provision the server (AWS or GCP or others), and I'm looking at Anisble as I've used in conjunction in my last project that deploys a client's SaaS "proof of concept" website, business, and function via Node-Red. NR is the diamond in the rough, as many don't know about it, or not know how useful and productive it really is.
Dev team and contributors I see on the forums here are top notch, and respectable.
But I digress... I'm here now working to see how easy it is for Ansible to install the rest on the Windows side. And couple that with Terraform, and (hopefully)... viola.
I'll try and share a version of it when I'm done, if anyone is interested.
I am finally making some progress with this project, however I am at yet another hurdle.
I got Terraform to provision a Windows Server, and Ansible to provision the rest.
I got an issue with getting pm2, pm2-startup (aka pm2-windows-startup) is not running node-red automatically when the system restarts.
When my instance reboots, these don't activate...
However when I log into the Windows Server via MS Remote Desktop, it seems to then load PM2 etc via the Administrator account and node-red will then be up within a few minutes.
Is there a way to get this going without needing to log into the Administrator account?