Skip to content

Commit

Permalink
Merge pull request #24 from ganto/facts
Browse files Browse the repository at this point in the history
Extend Check_MK server site facts
  • Loading branch information
ganto authored Jul 26, 2016
2 parents 94a7c50 + 7961ede commit c4e64ed
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
20 changes: 20 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,26 @@ checkmk_server__prerequisite_packages: [ 'apache2' ]
checkmk_server__site: 'debops'


# .. envvar:: checkmk_server__hostname
#
# Set Check_MK server DNS hostname (e.g. for agent download, API calls, ...).
checkmk_server__hostname: '{{ ansible_fqdn }}'


# .. envvar:: checkmk_server__site_url
#
# Check_MK server site URL.
checkmk_server__site_url: '{{ ("https://" if checkmk_server__pki else "http://") +
checkmk_server__hostname + "/" +
checkmk_server__site }}'


# .. envvar:: checkmk_server__webapi_url
#
# WebAPI URL of monitoring site.
checkmk_server__webapi_url: '{{ checkmk_server__site_url + "/check_mk/webapi.py" }}'


# .. envvar:: checkmk_server__runtime_config
#
# Check_MK site runtime configuration (``omd config``). Changing
Expand Down
2 changes: 1 addition & 1 deletion tasks/site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
- name: Read SSH public key
command: 'cat {{ checkmk_server__site_home }}/.ssh/id_rsa.pub'
changed_when: False
register: checkmk_server_register_ssh_pubkey
register: checkmk_server__register_ssh_public_key
when: checkmk_server__sshkeys|d()

- name: Wait for the site to be started
Expand Down
11 changes: 8 additions & 3 deletions templates/etc/ansible/facts.d/checkmk_server.fact.j2
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"ssh_publickey": "{{ checkmk_server_register_ssh_pubkey.stdout }}"
}
{% set _site_facts = {} %}
{% set _ = _site_facts.update({checkmk_server__site: {"version": checkmk_server__version_label}}) %}
{% set _ = _site_facts[checkmk_server__site].update({"site_url": checkmk_server__site_url}) %}
{% set _ = _site_facts[checkmk_server__site].update({"webapi_url": checkmk_server__webapi_url}) %}
{% if checkmk_server__register_ssh_public_key.stdout|d() %}
{% set _ = _site_facts[checkmk_server__site].update({"ssh_public_key": checkmk_server__register_ssh_public_key.stdout}) %}
{% endif %}
{{ _site_facts | to_nice_json }}

0 comments on commit c4e64ed

Please sign in to comment.