feat: move prereq to dedicated role

This commit is contained in:
Simon Cornet 2025-06-06 17:10:18 +02:00
commit 75226a9c78
5 changed files with 3 additions and 87 deletions

View file

@ -5,4 +5,6 @@ galaxy_info:
description: "install and configure a Zabbix Agent" description: "install and configure a Zabbix Agent"
license: "MIT" license: "MIT"
role_name: "zabbix_agent" role_name: "zabbix_agent"
dependencies: [] dependencies:
- name: "zabbix_prereq"
src: "https://gitlab.simoncor.net/ansible/ans-zabbix-agent.git"

View file

@ -3,15 +3,10 @@
# load variables and collect version information # load variables and collect version information
- name: "include vars and collect versions" - name: "include vars and collect versions"
tags: tags:
- "zabbix_agent_prereq"
- "zabbix_agent_install" - "zabbix_agent_install"
- "zabbix_agent_config" - "zabbix_agent_config"
block: block:
# load os specific variables
- name: "include os specific vars"
ansible.builtin.include_vars: "{{ ansible_os_family }}.yaml"
# collect zabbix-agent2 version information # collect zabbix-agent2 version information
- name: "collect version information" - name: "collect version information"
ansible.builtin.shell: ansible.builtin.shell:
@ -22,13 +17,6 @@
register: "zabbix_current_version" register: "zabbix_current_version"
# zabbix-agent prerequisites
- name: "zabbix-agent prerequisites"
ansible.builtin.import_tasks: "prerequisites.yaml"
tags:
- "zabbix_agent_prereq"
# zabbix-agent install # zabbix-agent install
- name: "zabbix-agent install" - name: "zabbix-agent install"
ansible.builtin.import_tasks: "install.yaml" ansible.builtin.import_tasks: "install.yaml"

View file

@ -1,52 +0,0 @@
---
# install repository
- name: "install repository"
when: "zabbix_major_version not in zabbix_current_version.stdout"
block:
# install repository - debian
- name: "install repository"
when: 'ansible_os_family == "Debian"'
block:
- name: "remove old zabbix-release"
ansible.builtin.apt:
name: "zabbix-release"
state: "absent"
purge: true
- name: "install zabbix-release"
ansible.builtin.apt:
deb: "{{ zabbix_repo_url[ansible_distribution][ansible_distribution_major_version | int] }}"
state: "present"
force: true
- name: "refresh apt cache"
ansible.builtin.apt:
update_cache: true
# install repository - suse
- name: "install repository"
when: 'ansible_os_family == "Suse"'
block:
- name: "remove old zabbix-release"
ansible.builtin.zypper:
name: "zabbix-release"
state: "absent"
- name: "install zabbix-release"
ansible.builtin.zypper:
name: "{{ zabbix_repo_url[ansible_distribution_major_version | int] }}"
state: "present"
disable_recommends: false
nosignature: true
validate_certs: true
- name: "import gpg key"
community.general.zypper_repository:
name: "Zabbix Official Repository"
auto_import_keys: true
runrefresh: true

View file

@ -1,15 +0,0 @@
---
# zabbix repository url
zabbix_repo_url:
Debian:
12:
"https://repo.zabbix.com/zabbix/{{ zabbix_major_version }}/release/debian/pool/main/z/zabbix-release/\
zabbix-release_latest_{{ zabbix_major_version }}+debian12_all.deb"
Ubuntu:
24:
"https://repo.zabbix.com/zabbix/{{ zabbix_major_version }}/release/ubuntu/pool/main/z/zabbix-release/\
zabbix-release_latest_{{ zabbix_major_version }}+ubuntu24.04_all.deb"
22:
"https://repo.zabbix.com/zabbix/{{ zabbix_major_version }}/release/ubuntu/pool/main/z/zabbix-release/\
zabbix-release_latest_{{ zabbix_major_version }}+ubuntu22.04_all.deb"

View file

@ -1,7 +0,0 @@
---
# zabbix repository url
zabbix_repo_url:
15:
"https://repo.zabbix.com/zabbix/{{ zabbix_major_version }}/release/sles/\
15/noarch/zabbix-release-latest-{{ zabbix_major_version }}.sles15.noarch.rpm"