added playbook for check_mk check
This commit is contained in:
parent
9ad4b11df5
commit
575f278a8a
45
check_mk.yml
Normal file
45
check_mk.yml
Normal file
@ -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
|
||||
...
|
Loading…
Reference in New Issue
Block a user