I am really not an expert on the topic, but I also need a solution.
I think it also depends in what area you are going to change/add code.
Just plugin development in ~/local
or do you also want to change the shipped checkmk code?
If you really want to alter the checkmk code in /opt/omd/versions/<version>
you need to have root permissions to modify/add/delete files there.
I know that some developers are checking out the checkmk git repo, create their feature branch, use any editor they like and have a hotkey, that copies the modified file from the git repo into/opt/omd/versions/<version>
using sudo, to test the code (and even reload the site apache if needed)
But most of us will probably only need to modify files below ~/local
for check plugins, agent plugins, metric definitions, RuleSpecs, FormSpecs and whatever.
For this I think it’s a very good approach to have your code on your workstation in a git repo and map this folder it into a checkmk container or VM so that it is available in the container/VM in or below /opt/omd/sites/<mysite>/local/
You can then use your workstation enviroment, favorite editor, all the tools you like without the need to install anything into that site or VM or container.
But I am not sure if in this case the IDE running in the enviroment of your workstation can make use of the python interpreter of the site and it’s libraries like ~/lib/python3/cmk
But to make any IDE aware of the available classes, functions, methods etc and even the included document it has to be aware of the sites python environment.
During the Plugin developent workshop on last Conference, I learned this solution to use VSC as IDE:
- you have a checkmk site for development running somewhere (on your laptop, vm, container, anything)
- you then make sure that you can passwordless ssh to that site with pubkey authentication (put your pubkey into the site users .ssh/authorized_keys)
- Install visual-studio-code VSC (run it with just “code”)
- In VSC install the extension “Remote - SSH” and “Remote Explorer”. Also install python language support.
- I do not remember the exact steps and details but this is what I now have installed:
On the left sidebar the lowest icon now gives you a “Remote Explorer” and it is possible to create ssh connections. I created e.g. one for localhost to my site workshop_conf10.
On the first ssh connect by VSC some stuff is installed in the site.
My understanding is that in the checkmk site there is a kind of remote VSC server running, communication with the VSC IDE on my workstation via ssh.
However, the final most important thing is now to tell VSC to use the correct python interpreter which is the one from the site.
This is done by clicking in the lower right area as shown here:
And from then on I am able to edit the code and already get all kind of auto completion and auto suggestions.
This was mind blowing for me.
BTW with the codium fork of VSC code it was not possible to use the remote ssh and remote explorer extensions. Mounting the sites ~/local folder than could be done by sshfs instead.
So far so good but somehow VSCode and me do not play well together.
I am an OPS guy and prefer to live hack as site user (in production ) and I am planning to do this with neovim, with one of the ready-to-use nice python IDE configurations that can be found on gitbub.
LazyVim is on of them https://www.lazyvim.org/ but I am going to make an extra post for that.
Just a recent nvim (neovim) an this is needed, and you already get a nice IDE:
git clone https://github.com/LazyVim/starter ~/.config/nvim