From 575f278a8af81d16c9a26db8ce03770421d8dfe7 Mon Sep 17 00:00:00 2001 From: Jens Heinitz Date: Wed, 30 Jun 2021 17:48:32 +0200 Subject: [PATCH] added playbook for check_mk check --- check_mk.yml | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 check_mk.yml diff --git a/check_mk.yml b/check_mk.yml new file mode 100644 index 0000000..4971697 --- /dev/null +++ b/check_mk.yml @@ -0,0 +1,45 @@ +--- +- name: get info from check_mk + hosts: all + vars: + check_mk_url: "https://cmk.seboto.my-wan.de/cmk/check_mk/webapi.py" + check_mk_body: "action=get_host&_username=automation&_secret=a688b83a-94ad-463c-8cd5-5abfeeb86349" + + tasks: + - name: get info for host server1 from check_mk + uri: + url: "{{ check_mk_url }}?{{ check_mk_body }}" + method: GET + body_format: form-urlencoded + body: + hostname: "{{ ansible_hostname }}.{{ ansible_domain }}" + return_content: True +# headers: +# Content-Type: application/json +# Accept: application/json + register: result + + - name: show result + debug: + var: result + + - name: save json data to var + set_fact: + json_data: "{{ result.json.result }}" + + - name: show json_data + debug: + var: json_data + + - name: set alias + set_fact: + my_alias: "{{ json_data | json_query('attributes.alias') }}" + + - name: show alias + debug: + var: my_alias + + - name: show ansible_hostname + debug: + var: ansible_hostname +...