Skip to content

Commit

Permalink
Merge pull request #51 from ganto/mkp
Browse files Browse the repository at this point in the history
Add support for installing Check_MK extension packages (MKP)
  • Loading branch information
ganto authored Mar 21, 2017
2 parents 98a11b7 + ede8dba commit f2015dc
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
7 changes: 7 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,13 @@ checkmk_server__site_cfg_netif_description:
wato: False


# .. envvar:: checkmk_server__site_packages
#
# Additional Check_MK packages (MKP) to be installed. See
# :ref:`checkmk_server__site_packages` for more information.
checkmk_server__site_packages: []


# -----------------
# PKI Configuration
# -----------------
Expand Down
34 changes: 34 additions & 0 deletions docs/defaults-configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,40 @@ following keys:
key set with ``privatekey_file``.


.. _checkmk_server__site_packages:

checkmk_server__site_packages
-----------------------------

Check_MK has a plugin system where site customizations such as additional
checks can be installed. This is done via ``.mkp`` packages. For more
information see the upstream documentation about `Check_MK extension packages`_.

.. _Check_MK extension packages: https://mathias-kettner.com/cms_mkps.html

Packages which should be installed for the current Check_MK site are defined
as a list of YAML dictionaries with the following configuration keys. One of
``path`` or ``url`` must be given:

``name``
Name of the package, required.

``path``
Optional. Local file system path of the ``.mkp`` package archive on the
Ansible controller. Cannot be combined with the ``url`` parameter.

``url``
Optional. Download URL of the ``.mkp`` package archive. Cannot be combined
with the ``path`` parameter.

``checksum``
Optional. Checksum of the download archive given in the ``url`` parameter.
Cannot be combined with the ``path`` parameter. For the accepted parameter
format check the Ansible `get_url module`_ documentation.

.. _get_url module: https://docs.ansible.com/ansible/get_url_module.html#options


.. _checkmk_server__multisite_users:

checkmk_server__multisite_users
Expand Down
3 changes: 3 additions & 0 deletions docs/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ Available role tags:

``role::checkmk_server:multisite``
Execute tasks which configure the Check_MK multisite Web interface.

``role::checkmk_server:mkp``
Execute tasks to install Check_MK packages.
44 changes: 44 additions & 0 deletions tasks/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,47 @@
ignore_errors: '{{ ansible_check_mode }}'
register: checkmk_server__register_ssh_public_key
when: checkmk_server__sshkeys|d()

- name: Query installed Check_MK packages
command: mkp list
become_user: '{{ checkmk_server__user }}'
become_flags: '-i'
changed_when: False
always_run: True
register: checkmk_server__register_mkp
tags:
- 'role::checkmk_server:mkp'

- name: Download Check_MK packages
get_url:
url: '{{ item.url }}'
dest: '{{ checkmk_server__site_home }}/tmp'
checksum: '{{ item.checksum|d(omit) }}'
when: ('url' in item) and
(item.name not in checkmk_server__register_mkp.stdout_lines)
register: checkmk_server__register_mkp_download
with_items: '{{ checkmk_server__site_packages }}'
tags:
- 'role::checkmk_server:mkp'

- name: Upload Check_MK packages
copy:
src: '{{ item.path }}'
dest: '{{ checkmk_server__site_home }}/tmp'
when: ('path' in item) and
(item.name not in checkmk_server__register_mkp.stdout_lines)
register: checkmk_server__register_mkp_upload
with_items: '{{ checkmk_server__site_packages }}'
tags:
- 'role::checkmk_server:mkp'

- name: Install Check_MK packages
command: mkp install '{{ item.dest|d() }}'
become_user: '{{ checkmk_server__user }}'
become_flags: '-i'
when: not (item | skipped)
with_flattened:
- '{{ checkmk_server__register_mkp_download.results }}'
- '{{ checkmk_server__register_mkp_upload.results }}'
tags:
- 'role::checkmk_server:mkp'

0 comments on commit f2015dc

Please sign in to comment.