HEX
Server: LiteSpeed
System: Linux kapuas.iixcp.rumahweb.net 5.14.0-427.42.1.el9_4.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 1 14:58:02 EDT 2024 x86_64
User: mirz4654 (1666)
PHP: 8.1.33
Disabled: system,exec,escapeshellarg,escapeshellcmd,passthru,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,popen,pclose,dl,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setsid,posix_setuid,posix_setpgid,ini_alter,show_source,define_syslog_variables,symlink,syslog,openlog,openlog,closelog,ocinumcols,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dll,ftp,myshellexec,socket_bind,mail,posix_getwpuid
Upload Files
File: //lib/python3.9/site-packages/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/api.yml
---
- name: "API | Create host groups"
  community.zabbix.zabbix_group:
    host_group: "{{ zabbix_host_groups }}"
    state: "{{ zabbix_agent_hostgroups_state }}"
    validate_certs: "{{ zabbix_api_validate_certs|default(omit) }}"
    timeout: "{{ zabbix_api_timeout }}"
  when:
    - zabbix_api_create_hostgroup | bool
  register: zabbix_api_hostgroup_created
  until: zabbix_api_hostgroup_created is succeeded
  delegate_to: "{{ zabbix_api_server_host }}"
  become: false
  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'] }}"
    validate_certs: "{{ zabbix_api_validate_certs | default(omit) }}"
    timeout: "{{ zabbix_api_timeout }}"
    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 }}"
  become: false
  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'] }}"
    validate_certs: "{{ zabbix_api_validate_certs | default(omit) }}"
    timeout: "{{ zabbix_api_timeout }}"
    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 }}"
  become: false
  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') }}"
    validate_certs: "{{ zabbix_api_validate_certs | default(omit) }}"
    timeout: "{{ zabbix_api_timeout }}"
  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 }}"
  become: false
  tags:
    - api