ansible/check_mk.yml

47 lines
1.1 KiB
YAML
Raw Permalink Normal View History

2021-06-30 17:48:32 +02:00
---
- 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: POST
2021-06-30 17:48:32 +02:00
body_format: form-urlencoded
body:
hostname: "{{ ansible_hostname }}.{{ ansible_domain }}"
return_content: True
# validate_certs: no
2021-06-30 17:48:32 +02:00
# 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
...