Skip to content

Commit

Permalink
Put zabbix_repo_deb_url in defaults (#1225)
Browse files Browse the repository at this point in the history
Instead of having a partial url in vars/Debian.yml, and appending
to it with additional info via set_fact, if zabbix_repo_deb_url is
not defined. Just supply it as a default, which could be overriden
by user.

Zabbix also supplies an ubuntu-arm64 repo, so now we check for that
aswell.

Notes on Raspbian
There are very few ways do differentiate Raspbian from Debian with
ansible_facts. The only candidate seems to be ansible_facts.lsb.id.

The lsb section does not get filled in unless some packages are
installed. But luckily those packages come installed on Raspbian
systems. And we just default it back to ansible_facts.distribution
if lsb.id is not present. So we're gonna simplify and drop some
tasks.

Tested with ansible-core 2.13.13 on;

  2024-03-12-raspios-bullseye-armhf-lite
  2024-03-15-raspios-bookworm-armhf-lite

If this for some unforseen reason wouldn't work on older or newer
versions of raspbian, there's always the option of just overriding
the zabbix_repo_deb_url.
  • Loading branch information
eb4x authored May 9, 2024
1 parent 7854c00 commit 55e58d1
Show file tree
Hide file tree
Showing 15 changed files with 5 additions and 140 deletions.
1 change: 1 addition & 0 deletions roles/zabbix_agent/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ zabbix_repo_yum:
gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
state: present

zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_agent_version }}/{{ ansible_facts.lsb.id | default(ansible_facts['distribution']) | lower }}{% if ansible_facts['architecture'] == 'aarch64' and ansible_facts.lsb.id | default(ansible_facts['distribution']) in ['Debian', 'Ubuntu'] %}-arm64{% endif %}"
zabbix_repo_deb_component: main

# Zabbix API stuff
Expand Down
27 changes: 0 additions & 27 deletions roles/zabbix_agent/tasks/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,6 @@
tags:
- always

- name: "Debian | Installing lsb-release"
ansible.builtin.apt:
pkg: lsb-release
update_cache: true
cache_valid_time: 3600
force: true
state: present
environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
become: true
tags:
- install

- name: "Debian | Update ansible_lsb fact"
ansible.builtin.setup:
gather_subset:
- lsb

- name: "Debian | Repo URL"
ansible.builtin.set_fact:
zabbix_repo_deb_url: "{{ _zabbix_repo_deb_url }}/{{ ansible_lsb.id.lower() }}{{ '-arm64' if ansible_machine == 'aarch64' and ansible_lsb.id == 'debian' else ''}}"
when:
- zabbix_repo_deb_url is undefined
tags:
- always

- name: "Debian | Installing gnupg"
ansible.builtin.apt:
pkg: gnupg
Expand Down
1 change: 0 additions & 1 deletion roles/zabbix_agent/vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,3 @@ zabbix_valid_agent_versions:

debian_keyring_path: /etc/apt/keyrings/
zabbix_gpg_key: "{{ debian_keyring_path }}zabbix-repo.asc"
_zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_agent_version }}"
1 change: 1 addition & 0 deletions roles/zabbix_javagateway/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ zabbix_repo_yum:
gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
state: present

zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_javagateway_version }}/{{ ansible_facts.lsb.id | default(ansible_facts['distribution']) | lower }}{% if ansible_facts['architecture'] == 'aarch64' and ansible_facts.lsb.id | default(ansible_facts['distribution']) in ['Debian', 'Ubuntu'] %}-arm64{% endif %}"
zabbix_repo_deb_component: main

zabbix_javagateway_pidfile: /run/zabbix/zabbix_java_gateway.pid
Expand Down
27 changes: 0 additions & 27 deletions roles/zabbix_javagateway/tasks/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,6 @@
tags:
- always

- name: "Debian | Installing lsb-release"
ansible.builtin.apt:
pkg: lsb-release
update_cache: true
cache_valid_time: 3600
force: true
state: present
environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
become: true
tags:
- install

- name: "Debian | Update ansible_lsb fact"
ansible.builtin.setup:
gather_subset:
- lsb

- name: "Debian | Repo URL"
ansible.builtin.set_fact:
zabbix_repo_deb_url: "{{ _zabbix_repo_deb_url }}/{{ ansible_lsb.id.lower() }}{{ '-arm64' if ansible_machine == 'aarch64' and ansible_lsb.id == 'debian' else ''}}"
when:
- zabbix_repo_deb_url is undefined
tags:
- always

# In releases older than Debian 12 and Ubuntu 22.04, /etc/apt/keyrings does not exist by default.
# It SHOULD be created with permissions 0755 if it is needed and does not already exist.
# See: https://wiki.debian.org/DebianRepository/UseThirdParty
Expand Down
1 change: 0 additions & 1 deletion roles/zabbix_javagateway/vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ zabbix_valid_javagateway_versions:

debian_keyring_path: /etc/apt/keyrings/
zabbix_gpg_key: "{{ debian_keyring_path }}zabbix-repo.asc"
_zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_javagateway_version }}"
1 change: 1 addition & 0 deletions roles/zabbix_proxy/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ zabbix_proxy_version_minor: "*"
# Yum/APT Variables
zabbix_repo_yum_schema: https
zabbix_repo_yum_gpgcheck: 0
zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_proxy_version }}/{{ ansible_facts.lsb.id | default(ansible_facts['distribution']) | lower }}{% if ansible_facts['architecture'] == 'aarch64' and ansible_facts.lsb.id | default(ansible_facts['distribution']) in ['Debian', 'Ubuntu'] %}-arm64{% endif %}"
zabbix_repo_deb_component: main
zabbix_proxy_disable_repo:
- epel
Expand Down
27 changes: 0 additions & 27 deletions roles/zabbix_proxy/tasks/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,6 @@
tags:
- always

- name: "Debian | Installing lsb-release"
ansible.builtin.apt:
pkg: lsb-release
update_cache: true
cache_valid_time: 3600
force: true
state: present
environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
become: true
tags:
- install

- name: "Debian | Update ansible_lsb fact"
ansible.builtin.setup:
gather_subset:
- lsb

- name: "Debian | Repo URL"
ansible.builtin.set_fact:
zabbix_repo_deb_url: "{{ _zabbix_repo_deb_url }}/{{ ansible_lsb.id.lower() }}{{ '-arm64' if ansible_machine == 'aarch64' and ansible_lsb.id == 'debian' else ''}}"
when:
- zabbix_repo_deb_url is undefined
tags:
- always

- name: "Debian | Set some facts for Zabbix"
ansible.builtin.set_fact:
datafiles_path: /usr/share/doc/zabbix-sql-scripts/{{ zabbix_proxy_db_long }}
Expand Down
1 change: 0 additions & 1 deletion roles/zabbix_proxy/vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,5 @@ mysql_plugin:

debian_keyring_path: /etc/apt/keyrings/
zabbix_gpg_key: "{{ debian_keyring_path }}zabbix-repo.asc"
_zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_proxy_version }}"
_zabbix_proxy_fping6location: /usr/bin/fping6
_zabbix_proxy_fpinglocation: /usr/bin/fping
1 change: 1 addition & 0 deletions roles/zabbix_server/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ zabbix_server_version_minor: "*"
zabbix_server_package_state: present
zabbix_repo_yum_gpgcheck: 0
zabbix_repo_yum_schema: https
zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_server_version }}/{{ ansible_facts.lsb.id | default(ansible_facts['distribution']) | lower }}{% if ansible_facts['architecture'] == 'aarch64' and ansible_facts.lsb.id | default(ansible_facts['distribution']) in ['Debian', 'Ubuntu'] %}-arm64{% endif %}"
zabbix_repo_deb_component: main
zabbix_server_disable_repo:
- epel
Expand Down
27 changes: 0 additions & 27 deletions roles/zabbix_server/tasks/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,6 @@
tags:
- always

- name: "Debian | Installing lsb-release"
ansible.builtin.apt:
pkg: lsb-release
update_cache: true
cache_valid_time: 3600
force: true
state: present
environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
become: true
tags:
- install

- name: "Debian | Update ansible_lsb fact"
ansible.builtin.setup:
gather_subset:
- lsb

- name: "Debian | Repo URL"
ansible.builtin.set_fact:
zabbix_repo_deb_url: "{{ _zabbix_repo_deb_url }}/{{ ansible_lsb.id.lower() }}{{ '-arm64' if ansible_machine == 'aarch64' and ansible_lsb.id == 'debian' else ''}}"
when:
- zabbix_repo_deb_url is undefined
tags:
- always

- name: "Debian | Set some facts for Zabbix"
ansible.builtin.set_fact:
datafiles_path: /usr/share/zabbix-sql-scripts/{{ 'postgresql' if zabbix_server_database == 'pgsql' else 'mysql' }}
Expand Down
1 change: 0 additions & 1 deletion roles/zabbix_server/vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,5 @@ zabbix_valid_server_versions:

debian_keyring_path: /etc/apt/keyrings/
zabbix_gpg_key: "{{ debian_keyring_path }}zabbix-repo.asc"
_zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_server_version }}"
_zabbix_server_fping6location: /usr/bin/fping6
_zabbix_server_fpinglocation: /usr/bin/fping
1 change: 1 addition & 0 deletions roles/zabbix_web/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ zabbix_web_apt_priority:
zabbix_web_version_minor: "*"
zabbix_repo_yum_gpgcheck: 0
zabbix_repo_yum_schema: https
zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_web_version }}/{{ ansible_facts.lsb.id | default(ansible_facts['distribution']) | lower }}{% if ansible_facts['architecture'] == 'aarch64' and ansible_facts.lsb.id | default(ansible_facts['distribution']) in ['Debian', 'Ubuntu'] %}-arm64{% endif %}"
zabbix_repo_deb_component: main
zabbix_web_disable_repo:
- epel
Expand Down
27 changes: 0 additions & 27 deletions roles/zabbix_web/tasks/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,6 @@
tags:
- always

- name: "Debian | Update ansible_lsb fact"
ansible.builtin.setup:
gather_subset:
- lsb

- name: "Debian | Installing lsb-release"
ansible.builtin.apt:
pkg: lsb-release
update_cache: true
cache_valid_time: 3600
force: true
state: present
environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
become: true
tags:
- install

- name: "Debian | Repo URL"
ansible.builtin.set_fact:
zabbix_repo_deb_url: "{{ _zabbix_repo_deb_url }}/{{ ansible_lsb.id.lower() }}{{ '-arm64' if ansible_machine == 'aarch64' and ansible_lsb.id == 'debian' else ''}}"
when:
- zabbix_repo_deb_url is undefined
tags:
- always

- name: "Debian | Install PHP Dependencies"
ansible.builtin.apt:
pkg: "{{ zabbix_web_php_dependencies }}"
Expand Down
1 change: 0 additions & 1 deletion roles/zabbix_web/vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,3 @@ zabbix_valid_web_versions:

debian_keyring_path: /etc/apt/keyrings/
zabbix_gpg_key: "{{ debian_keyring_path }}zabbix-repo.asc"
_zabbix_repo_deb_url: "http://repo.zabbix.com/zabbix/{{ zabbix_web_version }}"

0 comments on commit 55e58d1

Please sign in to comment.