zabbix agent install option
This commit is contained in:
3
roles/zabbix_agent/defaults/main.yml
Normal file
3
roles/zabbix_agent/defaults/main.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
---
|
||||
zabbix_server: "zabbix.lan"
|
||||
zabbix_version: "7.0"
|
||||
46
roles/zabbix_agent/tasks/main.yml
Normal file
46
roles/zabbix_agent/tasks/main.yml
Normal file
@@ -0,0 +1,46 @@
|
||||
---
|
||||
- name: Get Ubuntu codename
|
||||
ansible.builtin.command: lsb_release -cs
|
||||
register: ubuntu_codename
|
||||
changed_when: false
|
||||
|
||||
- name: Download Zabbix repository package
|
||||
ansible.builtin.get_url:
|
||||
url: "https://repo.zabbix.com/zabbix/{{ zabbix_version }}/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_{{ zabbix_version }}+ubuntu.{{ ansible_distribution_version }}_all.deb"
|
||||
dest: /tmp/zabbix-release.deb
|
||||
mode: '0644'
|
||||
|
||||
- name: Install Zabbix repository package
|
||||
ansible.builtin.apt:
|
||||
deb: /tmp/zabbix-release.deb
|
||||
|
||||
- name: Install Zabbix agent2
|
||||
ansible.builtin.apt:
|
||||
name: zabbix-agent2
|
||||
state: present
|
||||
update_cache: true
|
||||
|
||||
- name: Configure Zabbix server address
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/zabbix/zabbix_agent2.conf
|
||||
regexp: '^Server='
|
||||
line: "Server={{ zabbix_server }}"
|
||||
|
||||
- name: Configure Zabbix active server address
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/zabbix/zabbix_agent2.conf
|
||||
regexp: '^ServerActive='
|
||||
line: "ServerActive={{ zabbix_server }}"
|
||||
|
||||
- name: Configure Zabbix agent hostname
|
||||
ansible.builtin.lineinfile:
|
||||
path: /etc/zabbix/zabbix_agent2.conf
|
||||
regexp: '^Hostname='
|
||||
line: "Hostname={{ ansible_hostname }}"
|
||||
|
||||
- name: Enable and start Zabbix agent2
|
||||
ansible.builtin.systemd:
|
||||
name: zabbix-agent2
|
||||
state: started
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
Reference in New Issue
Block a user