Remote installation of Check_MK Agent (WMI/SSH)

I’m not sure if that hasn’t been discussed here already (search didnt bring sth up) but what about adding a feature to remotely install the check_mk_agent via WMI or SSH directly from the Check_MK Webfrontend ?

So in the bakery we would specify some credentials for the specific hosts and push the agent from the WebUI directly instead of doing a manual or scripted installation on the host itself.

According to the Idea Automatic registration baked into the Agent it would be nice to automatically register the agent that way.

The installation could be done for example for linux hosts over ssh with wget the agent and running the installer silently and doing the registration.
For Windows hosts the distribution could be done over WMI or Powershell Remote like the same princip.

Kind regards,
Constantin

Why reinvent the wheel? Use configuration management tools…

For example, my playbook for the linux agent is just this small lines of ansible code:

---
- name: Installs latest agent from master server
  hosts: all
  gather_facts: no
  vars:
    cmk_bin_dir: "/usr/local/bin/check_mk_agent"
  tasks:
  - name: Download latest agent
    uri:
      url: 'https://cmk.example.com/site/check_mk/agents/check_mk_agent.linux'
      dest: "{{ cmk_bin_dir }}"
      status_code: [200,304]
      owner: root
      mode: '0700'
  - name: Check if authorized_keys is right
    authorized_key:
      key: "<pub key of site user>"
      state: present
      key_options: 'command="{{ cmk_bin_dir }}"'
      user: root

You can easily extend the playbook to add plugins, etc. For windows hosts ofc you have to use the module win_uri or install the msi directly via win_package.

5 Likes

We have a similar playbook. Windows wise, we don’t use ansible (different people). I can’t remember the CM tool they’re using (it’s changed over the years). I just let them know when to push a new client (after upgrading the server).

Edit: Let me also add that once installed, if you have configured everything for Agent Bakery (CEE), I believe it can take care of the rest (whatever the client). We found the Agent Bakery setup to be “complex” enough … and since we’re already dependent on a “CM” mechanism, we just continued to do that.