summaryrefslogtreecommitdiffstats
path: root/playbooks/adhoc/noc/create_host.yml
blob: 2d2cae2b5a0db9228ce49ca812d5a6b0679adeec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
---
- name: 'Create a host object in zabbix'
  hosts: localhost
  connection: local
  become: no
  gather_facts: no
  roles:
    - os_zabbix
  post_tasks:

    - zbxapi:
        server: https://noc2.ops.rhcloud.com/zabbix/api_jsonrpc.php
        zbx_class: Template
        state: list
        params:
          host: ctr_test_kwoodson
          filter:
            host:
            -  ctr_kwoodson_test_tmpl

      register: tmpl_results

    - debug: var=tmpl_results

#ansible-playbook -e 'oo_desc=kwoodson test' -e 'oo_name=kwoodson test name' -e 'oo_start=1435715357' -e 'oo_stop=1435718985' -e 'oo_hostids=11549' create_maintenance.yml
- name: 'Create a host object in zabbix'
  hosts: localhost
  connection: local
  become: no
  gather_facts: no
  roles:
    - os_zabbix
  post_tasks:

    - zbxapi:
        server: https://noc2.ops.rhcloud.com/zabbix/api_jsonrpc.php
        zbx_class: Host
        state: absent
        params:
          host: ctr_test_kwoodson
          interfaces:
          - type: 1
            main: 1
            useip: 1
            ip: 127.0.0.1
            dns: ""
            port: 10050
          groups:
          - groupid: 1
          templates: "{{ tmpl_results.results | oo_collect('templateid') | oo_build_zabbix_list_dict('templateid') }}"
          output: extend
          filter:
            host:
            -  ctr_test_kwoodson

      register: host_results

    - debug: var=host_results