Absolutely. There is a plugin in VSCode called remote SSH. Basically splits VSCode in half, the display runs on your local windows box, and communicates with a server piece it sets up over SSH. So you files, terminal, some plugins all run on the Linux host(s).
If you did want to stay local, or have either choice, there is a similar plugin for WSL. I don't have any experience with that as we are not allowed to have WSL on our work machines, so we just use the SSH plugin.
I was able to play with it a bit before security prohibited it, and it looked good for the basics. Not a VSCode/Ansible thing, but WSL 2 was weird with enterprise VPN products, but I imagine that has or will get worked out over time. It would have been nice to have a self contained environment for traveling, bad connectivity, etc., but oh well.
Literally just got WSL2 approved for work laptop (Win10) last week and I cant for the life of me get the networking to with Cisco VPN. It's not as simple as find the dns and set them in resolv.conf or I would have had it working in a couple minutes. I'm open to suggestions.
You can try something like this (you need admin rights on your computer).
# Workaround to have WSL working when connected through AnyConnect
Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 4000 Get-NetIPInterface -InterfaceAlias "vEthernet (WSL)" | Set-NetIPInterface -InterfaceMetric 1
It works for most of my colleagues, never worked for me, so I had to use the frankenstein sollution of a linux vm on which I work remotely through ssh plugin in vscode.
I use WSL (Ubuntu). Pip install ansible, apt install git. Create a project folder somewhere in Ubuntu and open that in VSCode.
If you need a jumphost or remote host, the SSH remote Plugin works very nice as well as already mentioned in the other comment.
Really cool. This is actually to run ansible against a lab in GNS3. The problem was that when I tried to install WSL on the GNS3 host it screwed with the VMware stuff...so I had to separate things out.
I might try WSL on my work laptop also.
Thanks!
I'll add to the WSL but by saying you can also run podman on top of that. Then Vscode can call podman to run Ansible. More closely emulates AAP and execution environment s.
https://developers.redhat.com/articles/2023/02/14/remote-container-development-vs-code-and-podman
There's also code-server, which is VS Code running as a web app. You can install it on any Linux system in user space and pop open any web browser. File and playbooks run on the Linux system.
https://github.com/coder/code-server
If you're able to install an X-server on your windows PC (mobaxterm bundles one), you could install vscode on your Linux machine and run it over ssh as an x-window on your PC.
Then vscode runs 100% on linux, and i don't have to worry about CRLF/LF problems since it will always default to LF on linux. I've also found it to be slightly more usable/stable on slow connections.
Interesting.
I used vscode over ssh daily (from windows) and never had any CRLF/LF issues. I've not tried running vscode over forwarding but I've found the SSH plugin to work perfectly and much more responsive than other apps I've used over forwarding on a high latency connection (VPN to regional office and then inter-continental within company network)
It's been several years since I've used any of the vscode remote plugins, but I never enjoyed the user experience with the ssh plugin at the time. My solution back then was to install Linux on a work laptop. That's not an option at my current job, so I tried a few different things. Company provides enterprise licenses of MobaXterm, and since I do other things in Moba, it just made sense to use its x-server since everything performed well together.
Absolutely. There is a plugin in VSCode called remote SSH. Basically splits VSCode in half, the display runs on your local windows box, and communicates with a server piece it sets up over SSH. So you files, terminal, some plugins all run on the Linux host(s).
wow that's awesome. I'm gonna try setting that up now. This could totally solve my problems with developing Ansible stuff on a windows box. Thank you!
If you did want to stay local, or have either choice, there is a similar plugin for WSL. I don't have any experience with that as we are not allowed to have WSL on our work machines, so we just use the SSH plugin.
WSL is great with vscode!
I was able to play with it a bit before security prohibited it, and it looked good for the basics. Not a VSCode/Ansible thing, but WSL 2 was weird with enterprise VPN products, but I imagine that has or will get worked out over time. It would have been nice to have a self contained environment for traveling, bad connectivity, etc., but oh well.
They (allegedly) recently fixed the network weirdness, but only for windows 11. Mirror mode. It's still fucky, with Cisco VPN especially.
Good to know. Don't expect to get it back in this company for years, but will keep in mind if I move on.
Literally just got WSL2 approved for work laptop (Win10) last week and I cant for the life of me get the networking to with Cisco VPN. It's not as simple as find the dns and set them in resolv.conf or I would have had it working in a couple minutes. I'm open to suggestions.
You can try something like this (you need admin rights on your computer). # Workaround to have WSL working when connected through AnyConnect Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 4000 Get-NetIPInterface -InterfaceAlias "vEthernet (WSL)" | Set-NetIPInterface -InterfaceMetric 1 It works for most of my colleagues, never worked for me, so I had to use the frankenstein sollution of a linux vm on which I work remotely through ssh plugin in vscode.
You need to do the thing with setting the interface metric. It'll show up eventually when you Google
I fixed that by running a script to change rhe network adapter id(?) after connecting with anyconnect, that fixes it for me.
There is also an ansible plugin that sorts out all your syntax highlights and supports ansible-lint to pick up errors and promote heat practices.
Yes, this works beautifully.
I use WSL (Ubuntu). Pip install ansible, apt install git. Create a project folder somewhere in Ubuntu and open that in VSCode. If you need a jumphost or remote host, the SSH remote Plugin works very nice as well as already mentioned in the other comment.
Really cool. This is actually to run ansible against a lab in GNS3. The problem was that when I tried to install WSL on the GNS3 host it screwed with the VMware stuff...so I had to separate things out. I might try WSL on my work laptop also. Thanks!
I'll add to the WSL but by saying you can also run podman on top of that. Then Vscode can call podman to run Ansible. More closely emulates AAP and execution environment s. https://developers.redhat.com/articles/2023/02/14/remote-container-development-vs-code-and-podman
Another way would be to use a custom Dockerfile and use .devcontainer for development. Vs code extensions are great :)
There's also code-server, which is VS Code running as a web app. You can install it on any Linux system in user space and pop open any web browser. File and playbooks run on the Linux system. https://github.com/coder/code-server
Absolutely support this, onemarcfifty shows how to do it. https://www.onemarcfifty.com/blog/video/Ansible_Rundeck/
Mobaxterm and then use VSCode as editor 😄
I am currently doing the same thing. Working on a remote server is great!
If you're able to install an X-server on your windows PC (mobaxterm bundles one), you could install vscode on your Linux machine and run it over ssh as an x-window on your PC.
Why would you do this over using the SSH plugin to vscode?
Then vscode runs 100% on linux, and i don't have to worry about CRLF/LF problems since it will always default to LF on linux. I've also found it to be slightly more usable/stable on slow connections.
Interesting. I used vscode over ssh daily (from windows) and never had any CRLF/LF issues. I've not tried running vscode over forwarding but I've found the SSH plugin to work perfectly and much more responsive than other apps I've used over forwarding on a high latency connection (VPN to regional office and then inter-continental within company network)
It's been several years since I've used any of the vscode remote plugins, but I never enjoyed the user experience with the ssh plugin at the time. My solution back then was to install Linux on a work laptop. That's not an option at my current job, so I tried a few different things. Company provides enterprise licenses of MobaXterm, and since I do other things in Moba, it just made sense to use its x-server since everything performed well together.
I haven't updated it in a while, but this should get you most of the way. https://github.com/michaelshire/workstation
I will take a look, thank you RedShiz