create_host.yml 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. ---
  2. - name: 'Create a host object in zabbix'
  3. hosts: localhost
  4. gather_facts: no
  5. roles:
  6. - os_zabbix
  7. post_tasks:
  8. - zbxapi:
  9. server: https://noc2.ops.rhcloud.com/zabbix/api_jsonrpc.php
  10. zbx_class: Template
  11. state: list
  12. params:
  13. host: ctr_test_kwoodson
  14. filter:
  15. host:
  16. - ctr_kwoodson_test_tmpl
  17. register: tmpl_results
  18. - debug: var=tmpl_results
  19. #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
  20. - name: 'Create a host object in zabbix'
  21. hosts: localhost
  22. gather_facts: no
  23. roles:
  24. - os_zabbix
  25. post_tasks:
  26. - zbxapi:
  27. server: https://noc2.ops.rhcloud.com/zabbix/api_jsonrpc.php
  28. zbx_class: Host
  29. state: absent
  30. params:
  31. host: ctr_test_kwoodson
  32. interfaces:
  33. - type: 1
  34. main: 1
  35. useip: 1
  36. ip: 127.0.0.1
  37. dns: ""
  38. port: 10050
  39. groups:
  40. - groupid: 1
  41. templates: "{{ tmpl_results.results | oo_collect('templateid') | oo_build_zabbix_list_dict('templateid') }}"
  42. output: extend
  43. filter:
  44. host:
  45. - ctr_test_kwoodson
  46. register: host_results
  47. - debug: var=host_results