Ansible Script 추가
This commit is contained in:
96
ansible/01_old/roles/zabbix-agent/tasks/api.yml
Normal file
96
ansible/01_old/roles/zabbix-agent/tasks/api.yml
Normal file
@@ -0,0 +1,96 @@
|
||||
---
|
||||
- name: "API | Create host groups"
|
||||
community.zabbix.zabbix_group:
|
||||
host_group: "{{ zabbix_host_groups }}"
|
||||
state: "{{ zabbix_agent_hostgroups_state }}"
|
||||
when:
|
||||
- zabbix_api_create_hostgroup | bool
|
||||
register: zabbix_api_hostgroup_created
|
||||
until: zabbix_api_hostgroup_created is succeeded
|
||||
delegate_to: "{{ zabbix_api_server_host }}"
|
||||
tags:
|
||||
- api
|
||||
|
||||
- name: "API | Create a new host or update an existing host's info"
|
||||
community.zabbix.zabbix_host:
|
||||
host_name: "{{ zabbix_agent_hostname }}"
|
||||
host_groups: "{{ zabbix_host_groups }}"
|
||||
link_templates: "{{ zabbix_agent_link_templates }}"
|
||||
status: "{{ zabbix_host_status }}"
|
||||
state: "{{ zabbix_agent_host_state }}"
|
||||
force: "{{ zabbix_agent_host_update }}"
|
||||
proxy: "{{ zabbix_agent_proxy }}"
|
||||
inventory_mode: "{{ zabbix_agent_inventory_mode }}"
|
||||
interfaces: "{{ zabbix_agent_interfaces }}"
|
||||
visible_name: "{{ zabbix_agent_visible_hostname | default(zabbix_agent_hostname) }}"
|
||||
tls_psk: "{{ zabbix_agent_tlspsk_secret | default(omit) }}"
|
||||
tls_psk_identity: "{{ zabbix_agent_tlspskidentity | default(omit) }}"
|
||||
tls_issuer: "{{ zabbix_agent_tlsservercertissuer | default(omit) }}"
|
||||
tls_subject: "{{ zabbix_agent_tls_subject | default(omit) }}"
|
||||
tls_accept: "{{ zabbix_agent_tls_config[zabbix_agent_tlsaccept if zabbix_agent_tlsaccept else 'unencrypted'] }}"
|
||||
tls_connect: "{{ zabbix_agent_tls_config[zabbix_agent_tlsconnect if zabbix_agent_tlsconnect else 'unencrypted'] }}"
|
||||
description: "{{ zabbix_agent_description | default(omit) }}"
|
||||
inventory_zabbix: "{{ zabbix_agent_inventory_zabbix | default({}) }}"
|
||||
ipmi_authtype: "{{ zabbix_agent_ipmi_authtype | default(omit) }}"
|
||||
ipmi_password: "{{ zabbix_agent_ipmi_password| default(omit) }}"
|
||||
ipmi_privilege: "{{ zabbix_agent_ipmi_privilege | default(omit) }}"
|
||||
ipmi_username: "{{ zabbix_agent_ipmi_username | default(omit) }}"
|
||||
tags: "{{ zabbix_agent_tags }}"
|
||||
when:
|
||||
- not zabbix_agent2
|
||||
register: zabbix_api_host_created
|
||||
until: zabbix_api_host_created is succeeded
|
||||
delegate_to: "{{ zabbix_api_server_host }}"
|
||||
changed_when: false
|
||||
tags:
|
||||
- api
|
||||
|
||||
- name: "API | Create a new host using agent2 or update an existing host's info"
|
||||
community.zabbix.zabbix_host:
|
||||
host_name: "{{ zabbix_agent2_hostname }}"
|
||||
host_groups: "{{ zabbix_host_groups }}"
|
||||
link_templates: "{{ zabbix_agent_link_templates }}"
|
||||
status: "{{ zabbix_host_status }}"
|
||||
state: "{{ zabbix_agent_host_state }}"
|
||||
force: "{{ zabbix_agent_host_update }}"
|
||||
proxy: "{{ zabbix_agent_proxy }}"
|
||||
inventory_mode: "{{ zabbix_agent_inventory_mode }}"
|
||||
interfaces: "{{ zabbix_agent_interfaces }}"
|
||||
visible_name: "{{ zabbix_agent_visible_hostname | default(zabbix_agent2_hostname) }}"
|
||||
tls_psk: "{{ zabbix_agent2_tlspsk_secret | default(omit) }}"
|
||||
tls_psk_identity: "{{ zabbix_agent2_tlspskidentity | default(omit) }}"
|
||||
tls_issuer: "{{ zabbix_agent2_tlsservercertissuer | default(omit) }}"
|
||||
tls_subject: "{{ zabbix_agent2_tls_subject | default(omit) }}"
|
||||
tls_accept: "{{ zabbix_agent_tls_config[zabbix_agent2_tlsaccept if zabbix_agent2_tlsaccept else 'unencrypted'] }}"
|
||||
tls_connect: "{{ zabbix_agent_tls_config[zabbix_agent2_tlsconnect if zabbix_agent2_tlsconnect else 'unencrypted'] }}"
|
||||
description: "{{ zabbix_agent_description | default(omit) }}"
|
||||
inventory_zabbix: "{{ zabbix_agent_inventory_zabbix | default({}) }}"
|
||||
ipmi_authtype: "{{ zabbix_agent_ipmi_authtype | default(omit) }}"
|
||||
ipmi_password: "{{ zabbix_agent_ipmi_password| default(omit) }}"
|
||||
ipmi_privilege: "{{ zabbix_agent_ipmi_privilege | default(omit) }}"
|
||||
ipmi_username: "{{ zabbix_agent_ipmi_username | default(omit) }}"
|
||||
tags: "{{ zabbix_agent_tags }}"
|
||||
when:
|
||||
- zabbix_agent2 | bool
|
||||
register: zabbix_api_host_created
|
||||
until: zabbix_api_host_created is succeeded
|
||||
delegate_to: "{{ zabbix_api_server_host }}"
|
||||
changed_when: false
|
||||
tags:
|
||||
- api
|
||||
|
||||
- name: "API | Updating host configuration with macros"
|
||||
community.zabbix.zabbix_hostmacro:
|
||||
host_name: "{{ (zabbix_agent2 | bool) | ternary(zabbix_agent2_hostname, zabbix_agent_hostname) }}"
|
||||
macro_name: "{{ item.macro_key }}"
|
||||
macro_value: "{{ item.macro_value }}"
|
||||
macro_type: "{{ item.macro_type|default('text') }}"
|
||||
with_items: "{{ zabbix_agent_macros | default([]) }}"
|
||||
when:
|
||||
- zabbix_agent_macros is defined
|
||||
- item.macro_key is defined
|
||||
register: zabbix_api_hostmarcro_created
|
||||
until: zabbix_api_hostmarcro_created is succeeded
|
||||
delegate_to: "{{ zabbix_api_server_host }}"
|
||||
tags:
|
||||
- api
|
||||
Reference in New Issue
Block a user