Getting started

Example inventory

You can install Check_MK agent on a host by adding it to the [debops_services_checkmk_agent host group in your Ansible inventory:


Example playbook

Here's an example playbook that uses the debops-contrib.checkmk_agent role:


- name: Manage Check_MK agent
  hosts:  [ 'debops_service_checkmk_agent' ]
  become: True

  environment: '{{ inventory__environment | d({})
                   | combine(inventory__group_environment | d({}))
                   | combine(inventory__host_environment  | d({})) }}'


    - role: debops-contrib.checkmk_agent/env
      tags: [ 'role::checkmk_agent', 'role::checkmk_agent:env', 'role::mariadb' ]

    - role: debops.apt_preferences
      tags: [ 'role::apt_preferences' ]
        - '{{ checkmk_agent__apt_preferences__dependent_list }}'

    - role: debops.etc_services
      tags: [ 'role::etc_services' ]
        - '{{ checkmk_agent__etc_services__dependent_list }}'
      when: ('xinetd' in checkmk_agent__type)

    - role: debops.ferm
      tags: [ 'role::ferm' ]
        - '{{ checkmk_agent__ferm__dependent_rules }}'

    - role: debops.tcpwrappers
      tags: [ 'role::tcpwrappers' ]
        - '{{ checkmk_agent__tcpwrappers__dependent_allow }}'

    - role: debops.authorized_keys
      tags: [ 'role::authorized_keys' ]
        - '{{ checkmk_agent__authorized_keys__dependent_list }}'

    - role: debops.mariadb
      tags: [ 'role::mariadb' ]
        - '{{ checkmk_agent__mariadb__dependent_users }}'
      when: ("mk_mysql" in checkmk_agent__combined_plugins)

    - role: debops-contrib.checkmk_agent
      tags: [ 'role::checkmk_agent' ]

The playbook is shipped with this role under docs/playbooks/checkmk_agent.yml from which you can symlink it to your playbook directory.

As you can see in this example playbook, the role makes use of a number of other roles to setup it’s environment. Some of these dependency roles are only needed when services are detected. This is true for the debops.mariadb role which is used to manage a database user used to monitor the DBMS and databases by an automatically setup and configured agent plugin. To ensure that checkmk_agent__combined_plugins is valid in the context of other roles (in the same playbook) this variable is based on Ansible facts which are setup by the debops-contrib.checkmk_agent/env role prior to other dependency roles being called. For more details, refer to checkmk_agent__plugin_autodetect.

Ansible tags

You can use Ansible --tags or --skip-tags parameters to limit what tasks are performed during Ansible run. This can be used after a host was first configured to speed up playbook execution, when you are sure that most of the configuration is already in the desired state.

Available role tags:

Environment role tag, should be used in the playbook to execute a special environment role contained in the main role. The environment role prepares the environment for other dependency roles to work correctly.
Main role tag, should be used in the playbook to execute all of the role tasks as well as role dependencies.
Tasks related to system package management like installing or removing packages.
Run tasks related to Check_MK agent plugin configuration.
Run tasks related to Check_MK agent plugin retrieval.