Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend Check_MK server site facts #24

Merged
merged 1 commit into from
Jul 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}