create_maintenance.yml 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. ---
  2. #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
  3. - name: 'Create a maintenace object in zabbix'
  4. hosts: localhost
  5. gather_facts: no
  6. roles:
  7. - os_zabbix
  8. vars:
  9. oo_hostids: ''
  10. oo_groupids: ''
  11. post_tasks:
  12. - assert:
  13. that: oo_desc is defined
  14. - zbxapi:
  15. server: https://noc2.ops.rhcloud.com/zabbix/api_jsonrpc.php
  16. zbx_class: Maintenance
  17. state: present
  18. params:
  19. name: "{{ oo_name }}"
  20. description: "{{ oo_desc }}"
  21. active_since: "{{ oo_start }}"
  22. active_till: "{{ oo_stop }}"
  23. maintenance_type: "0"
  24. output: extend
  25. hostids: "{{ oo_hostids.split(',') | default([]) }}"
  26. #groupids: "{{ oo_groupids.split(',') | default([]) }}"
  27. timeperiods:
  28. - start_time: "{{ oo_start }}"
  29. period: "{{ oo_stop }}"
  30. selectTimeperiods: extend
  31. register: maintenance
  32. - debug: var=maintenance