Hi,
don’t know if this is the preferred way to do it … but we do it like this.
During install we automatically set a label in the file
/usr/lib/check_mk_agent/plugins/virtual_label
with the content
echo '<<<labels:sep(0)>>>'
echo '{"virtual": "<%= @virtual %>"}'
Now @virtual is a variable we get from foreman so this is included in our autoinstall setup.
Basically what it does is it replaces <%= @virtual %> with lxc resulting in
echo '<<<labels:sep(0)>>>'
echo '{"virtual": "lxc"}'
when deployed to the host.
This label will be discoverd during a new inventory of the host.
We then setup a rule like this.
As i said… not sure if this is the preferred way or “best practice” but that’s how we do it
best regards