forked from polkachu/secure-server-setup
-
Notifications
You must be signed in to change notification settings - Fork 2
/
util_zabbix_install.yml
81 lines (72 loc) · 3.3 KB
/
util_zabbix_install.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
- name: Deploy Zabbix
hosts: all
gather_facts: true
become: true
vars:
zabbix_template_list:
- Linux by Zabbix agent active
pre_tasks:
- name: Get service facts
ansible.builtin.service_facts:
- name: Verify sudo on localhost
ansible.builtin.shell: "sudo w"
delegate_to: localhost
run_once: true
- name: Add SMART template to list if bare metal
ansible.builtin.set_fact:
zabbix_template_list: "{{ zabbix_template_list + ['SMART by Zabbix agent 2 active'] }}"
when: "'baremetal' in group_names"
- name: Add additional service templates to list
ansible.builtin.set_fact:
zabbix_template_list: "{{ zabbix_template_list + [item.template] }}"
when: item.service in ansible_facts.services
with_items:
- service: "haproxy"
template: "HAProxy by Zabbix agent"
- service: "docker"
template: "Docker by Zabbix agent 2"
- name: Parse list of ansible inventory items to tag zabbix for hardware nodes
ansible.builtin.set_fact:
inventory_group_dict: "{{ inventory_group_dict | default([]) + [{ 'tag': 'inv', 'value': item }] }}"
with_items:
- "{{ group_names }}"
roles:
- role: util_zabbix_prepare
- role: zabbix.zabbix.agent
agent_variant: 2
agent_major_version: "{% if ansible_architecture == 'aarch64' %}7.0{% else %}6.4{% endif %}"
agent_package_state: latest
agent_param_server: "{{ zabbix_agent_listen_addresses }}" # Allow dial-in from multiple source addresses
agent_param_serveractive: "{{ zabbix_server_public_name }}" # Use DNS name for ServerActive
agent_apply_firewalld_rule: false
agent_apply_iptables_rule: false
agent_param_hostmetadata: '{{ group_names | join(",") }},Linux'
- role: zabbix.zabbix.host
host_zabbix_api_server: "{{ zabbix_server_public_name }}"
host_zabbix_api_port: 443
host_zabbix_api_user: "{{ zabbix_login_user }}"
host_zabbix_api_password: "{{ zabbix_login_pass }}"
host_zabbix_api_use_ssl: true
host_description: "Located in {{ node_info.json.city }}, {{ node_info.json.country }} at {{ node_info.json.org }}. Last updated via ansible on {{ ansible_date_time.date }} at {{ ansible_date_time.time }} {{ ansible_date_time.tz }}. "
host_interfaces:
- type: agent
ip: "{% if nebula_internal_ip_addr is defined and nebula_internal_ip_addr | ansible.utils.ipaddr %}{{ nebula_internal_ip_addr }}{% elif ansible_host | ansible.utils.ipaddr %}{{ ansible_host }}{% endif %}"
dns: ""
useip: true
port: "{{ agent_param_listenport | default(10050) }}"
host_hostgroups:
- Linux servers
- "{{ node_info.json.org }}"
host_inventory_mode: automatic
host_inventory:
alias: "{{ inventory_hostname }}"
software: "{{ ansible_distribution }} {{ ansible_distribution_major_version }}"
location: "{{ node_info.json.org }}"
location_lat: "{{ latlong.0 }}"
location_lon: "{{ latlong.1 }}"
site_city: "{{ node_info.json.city }}"
site_state: "{{ node_info.json.region }}"
site_country: "{{ node_info.json.country }}"
host_templates: "{{ zabbix_template_list }}"
host_tags: "{{ inventory_group_dict }}"
- role: util_zabbix_configure