feat: test attempt 2
This commit is contained in:
parent
a4c1bc8dac
commit
44fc11b862
11 changed files with 3 additions and 0 deletions
|
|
@ -4,3 +4,6 @@ roles:
|
|||
- name: "zabbix_prereq"
|
||||
src: "https://gitlab.simoncor.net/ansible/ans-zabbix-prereq.git"
|
||||
scm: "git"
|
||||
- name: "zabbix_agent"
|
||||
src: "https://gitlab.simoncor.net/ansible/ans-zabbix-agent.git"
|
||||
scm: "git"
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
---
|
||||
|
||||
# zabbix_version
|
||||
zabbix_major_version: "7.4"
|
||||
|
||||
# zabbix agent defaults
|
||||
zabbix_agent_psk_enable: true
|
||||
zabbix_agent_psk: "superlongpsk"
|
||||
zabbix_agent_listen_port: "10050"
|
||||
|
||||
# zabbix server / proxy connectivity
|
||||
zabbix_proxy_address: "zabbix.example.com"
|
||||
zabbix_proxy_port: "10051"
|
||||
|
||||
# zabbix user permissions
|
||||
zabbix_user_sudo: true
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
# disable the NVIDIA plugin
|
||||
# Plugins.NVIDIA.System.Path=/usr/libexec/zabbix/zabbix-agent2-plugin-nvidia-gpu
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
|
||||
# zabbix agent
|
||||
- name: "restart zabbix-agent"
|
||||
ansible.builtin.service:
|
||||
name: "zabbix-agent2"
|
||||
enabled: true
|
||||
state: "restarted"
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
---
|
||||
|
||||
galaxy_info:
|
||||
author: "siempie"
|
||||
description: "install and configure a Zabbix Agent"
|
||||
license: "MIT"
|
||||
role_name: "zabbix_agent"
|
||||
|
||||
dependencies:
|
||||
- role: "zabbix_prereq"
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
---
|
||||
|
||||
# setup psk
|
||||
- name: "setup psk"
|
||||
ansible.builtin.template:
|
||||
src: "templates/zabbix/zabbix_agent.psk.j2"
|
||||
dest: "/etc/zabbix/zabbix_agent.psk"
|
||||
owner: "zabbix"
|
||||
group: "zabbix"
|
||||
mode: "0640"
|
||||
notify: "restart zabbix-agent"
|
||||
|
||||
# config agent
|
||||
- name: "config agent"
|
||||
ansible.builtin.template:
|
||||
src: "templates/zabbix/zabbix_agent.conf.j2"
|
||||
dest: "/etc/zabbix/zabbix_agent2.conf"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
mode: "0664"
|
||||
notify: "restart zabbix-agent"
|
||||
|
||||
# configure plugins
|
||||
- name: "configure plugins"
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item }}"
|
||||
dest: "/etc/zabbix/zabbix_agent2.d/plugins.d/"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
mode: "0644"
|
||||
with_fileglob:
|
||||
- "files/zabbix/plugins.d/*"
|
||||
notify: "restart zabbix-agent"
|
||||
|
|
@ -1,68 +0,0 @@
|
|||
---
|
||||
|
||||
# install zabbix-agent2
|
||||
- name: "install zabbix-agent2"
|
||||
when: "zabbix_major_version not in zabbix_current_version.stdout"
|
||||
block:
|
||||
|
||||
# install repository - debian
|
||||
- name: "install repository"
|
||||
when: 'ansible_os_family == "Debian"'
|
||||
block:
|
||||
|
||||
# remove old agent
|
||||
- name: "remove old agent"
|
||||
ansible.builtin.apt:
|
||||
name: "{{ item }}"
|
||||
state: "absent"
|
||||
loop:
|
||||
- "zabbix-agent2"
|
||||
- "zabbix-agent2-plugin-*"
|
||||
|
||||
# install agent
|
||||
- name: "install agent"
|
||||
ansible.builtin.apt:
|
||||
name: "{{ item }}"
|
||||
state: "present"
|
||||
update_cache: true
|
||||
when: 'ansible_os_family == "Debian"'
|
||||
loop:
|
||||
- "zabbix-agent2"
|
||||
- "zabbix-agent2-plugin-*"
|
||||
|
||||
|
||||
# install repository - suse
|
||||
- name: "install repository"
|
||||
when: 'ansible_os_family == "Suse"'
|
||||
block:
|
||||
|
||||
# remove old agent
|
||||
- name: "remove old agent"
|
||||
ansible.builtin.zypper:
|
||||
name: "{{ item }}"
|
||||
state: "absent"
|
||||
loop:
|
||||
- "zabbix-agent2"
|
||||
- "zabbix-agent2-plugin-*"
|
||||
|
||||
# install agent
|
||||
- name: "install agent"
|
||||
ansible.builtin.zypper:
|
||||
name: "{{ item }}"
|
||||
disable_recommends: false
|
||||
state: "present"
|
||||
when: 'ansible_os_family == "Suse"'
|
||||
loop:
|
||||
- "zabbix-agent2"
|
||||
- "zabbix-agent2-plugin-*"
|
||||
|
||||
|
||||
# install sudoers file
|
||||
- name: "install sudoers file"
|
||||
ansible.builtin.template:
|
||||
src: "templates/sudoers.d/zabbix.j2"
|
||||
dest: "/etc/sudoers.d/zabbix"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
mode: "0440"
|
||||
when: "zabbix_user_sudo"
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
---
|
||||
|
||||
# load variables and collect version information
|
||||
- name: "include vars and collect versions"
|
||||
block:
|
||||
|
||||
# collect zabbix-agent2 version information
|
||||
- name: "collect version information"
|
||||
ansible.builtin.shell:
|
||||
cmd: "zabbix_agent2 --version | head -n 1"
|
||||
changed_when: false
|
||||
failed_when: false
|
||||
ignore_errors: true
|
||||
register: "zabbix_current_version"
|
||||
|
||||
|
||||
# zabbix-agent install
|
||||
- name: "zabbix-agent install"
|
||||
ansible.builtin.include_tasks: "install.yaml"
|
||||
|
||||
# zabbix-agent config
|
||||
- name: "zabbix-agent config"
|
||||
ansible.builtin.include_tasks: "config.yaml"
|
||||
|
|
@ -1 +0,0 @@
|
|||
zabbix ALL=(ALL) NOPASSWD: ALL
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
# general
|
||||
Hostname={{ zabbix_agent_hostname | default(inventory_hostname) }}
|
||||
Server={{ zabbix_proxy_address }}
|
||||
ServerActive={{ zabbix_proxy_address }}:{{ zabbix_proxy_port }}
|
||||
ListenPort={{ zabbix_agent_listen_port }}
|
||||
HostMetadataItem=system.uname
|
||||
HostInterface={{ zabbix_agent_hostinterface | default(inventory_hostname) }}
|
||||
AllowKey=system.run[*]
|
||||
Timeout=30
|
||||
LogType=system
|
||||
DebugLevel=1
|
||||
|
||||
{% if zabbix_agent_psk_enable %}
|
||||
# psk
|
||||
TLSConnect=psk
|
||||
TLSAccept=psk
|
||||
TLSPSKIdentity={{ zabbix_agent_psk_id }}
|
||||
TLSPSKFile=/etc/zabbix/zabbix_agent.psk
|
||||
{% endif %}
|
||||
|
||||
# advanced parameters
|
||||
Include=/etc/zabbix/zabbix_agent2.d/*.conf
|
||||
Include=/etc/zabbix/zabbix_agent2.d/plugins.d/*.conf
|
||||
PluginSocket=/run/zabbix/agent.plugin.sock
|
||||
ControlSocket=/run/zabbix/agent.sock
|
||||
|
|
@ -1 +0,0 @@
|
|||
{{ zabbix_agent_psk }}
|
||||
Loading…
Add table
Add a link
Reference in a new issue