Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor zabbix proxy #1196

Merged
merged 18 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 34 additions & 18 deletions .github/workflows/proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,33 @@ jobs:
fail-fast: false
matrix:
container:
- rockylinux9
- rockylinux8
- centos7
- ubuntu2204
- ubuntu2004
- ubuntu1804
- debian12
- debian11
- debian10
- name: rockylinux9
base_image: rockylinux/rockylinux:9-ubi-init
os_family: redhat
- name: rockylinux8
base_image: rockylinux/rockylinux:8-ubi-init
os_family: redhat
- name: centos7
base_image: centos/systemd:latest
os_family: redhat
- name: ubuntu2204
base_image: ubuntu:22.04
os_family: debian
- name: ubuntu2004
base_image: ubuntu:20.04
os_family: debian
- name: ubuntu1804
base_image: ubuntu:18.04
os_family: debian
- name: debian12
base_image: debian:12
os_family: debian
- name: debian11
base_image: debian:11
os_family: debian
- name: debian10
base_image: debian:10
os_family: debian
collection_role:
- zabbix_proxy
database:
Expand All @@ -39,12 +57,11 @@ jobs:
- v64
- v62
- v60
include:
- interpreter: python3
- interpreter: python
Copy link
Collaborator Author

@eb4x eb4x Mar 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The geerlingguy centos doesn't come with python3, which is kind of a shame. Better to do a rehaul of that image.

container: centos7
exclude:
- container: debian12
- container:
name: debian12
base_image: debian:12
os_family: debian
version: v62
steps:
- name: Check out code
Expand Down Expand Up @@ -78,10 +95,9 @@ jobs:

- name: Run role tests
run: >-
MY_MOLECULE_CONTAINER=${{ matrix.container }}
MY_MOLECULE_IMAGE=${{ matrix.container }}
MY_MOLECULE_CONTAINER=${{ matrix.container.name }}
MY_MOLECULE_IMAGE=${{ matrix.container.base_image }}
MY_MOLECULE_OS_FAMILY=${{ matrix.container.os_family }}
MY_MOLECULE_VERSION=${{ matrix.version }}
MY_MOLECULE_DATABASE=${{ matrix.database }}
MY_MOLECULE_INTERPRETER=${{ matrix.interpreter }}
MY_MOLECULE_DOCKER_COMMAND=${{ matrix.command }}
molecule test -s ${{ matrix.collection_role }}
3 changes: 3 additions & 0 deletions molecule/zabbix_proxy/Dockerfile.debian.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM {{ item.base_image }}
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y python3-pip systemd-sysv
CMD ["/sbin/init"]
3 changes: 3 additions & 0 deletions molecule/zabbix_proxy/Dockerfile.redhat.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM {{ item.base_image }}
RUN yum install -y python3-pip
CMD ["/sbin/init"]
11 changes: 5 additions & 6 deletions molecule/zabbix_proxy/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ driver:
name: docker
platforms:
- name: zabbix-proxy-${MY_MOLECULE_VERSION:-v64}-${MY_MOLECULE_DATABASE:-mysql}-${MY_MOLECULE_CONTAINER:-rockylinux8}
image: geerlingguy/docker-${MY_MOLECULE_IMAGE:-rockylinux8}-ansible:latest
dockerfile: Dockerfile.${MY_MOLECULE_OS_FAMILY:-redhat}.j2
base_image: ${MY_MOLECULE_IMAGE:-rockylinux/rockylinux:8-ubi-init}
image: ${MY_MOLECULE_CONTAINER:-rockylinux8}
privileged: true
pre_build_image: true
command: ${MOLECULE_DOCKER_COMMAND:-""}
command: /sbin/init
networks:
- name: zabbix
volumes:
Expand All @@ -22,10 +23,8 @@ provisioner:
ANSIBLE_ROLES_PATH: $HOME/.ansible/collections/ansible_collections/community/zabbix/roles
inventory:
group_vars:
python3:
all:
ansible_python_interpreter: /usr/bin/python3
python:
ansible_python_interpreter: /usr/bin/python
v64:
zabbix_proxy_version: 6.4
v62:
Expand Down
16 changes: 0 additions & 16 deletions molecule/zabbix_proxy/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,3 @@
dest: /etc/sudoers
line: "Defaults !requiretty"
state: present

- name: "Make sure the docs can be installed. (RedHat)"
ansible.builtin.lineinfile:
dest: /etc/yum.conf
line: "tsflags=nodocs"
state: absent
when:
- ansible_os_family == 'RedHat'

- name: "Make sure the docs can be installed. (Debian)"
ansible.builtin.lineinfile:
path: /etc/dpkg/dpkg.cfg.d/excludes
state: absent
regexp: "path-exclude=/usr/share/doc/*"
when:
- ansible_os_family != 'RedHat'
3 changes: 1 addition & 2 deletions roles/zabbix_proxy/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ 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']) == 'Debian' %}-arm64{% endif %}"
zabbix_repo_deb_component: main
zabbix_proxy_disable_repo:
- epel
zabbix_repo_yum:
- name: zabbix
description: Zabbix Official Repository - $basearch
Expand Down
140 changes: 0 additions & 140 deletions roles/zabbix_proxy/tasks/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,10 @@
- name: "Debian | Set short version name"
ansible.builtin.set_fact:
zabbix_short_version: "{{ zabbix_proxy_version | regex_replace('\\.', '') }}"
zabbix_python_prefix: "python{% if ansible_python_version is version('3', '>=') %}3{% endif %}"
zabbix_underscore_version: "{{ zabbix_proxy_version | regex_replace('\\.', '_') }}"
tags:
- always

- name: "Debian | Installing lsb-release"
pyrodie18 marked this conversation as resolved.
Show resolved Hide resolved
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 }}
tags:
- install
- config

- name: "Debian | Installing gnupg"
ansible.builtin.apt:
pkg: gnupg
Expand Down Expand Up @@ -129,108 +94,3 @@
become: true
tags:
- install

- name: "Debian | Installing zabbix-proxy-{{ zabbix_proxy_database }}"
ansible.builtin.apt:
pkg: "zabbix-proxy-{{ zabbix_proxy_database }}"
update_cache: true
cache_valid_time: 0
force: true
state: "{{ zabbix_proxy_package_state }}"
default_release: "{{ ansible_distribution_release }}"
environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
register: is_zabbix_proxy_package_installed
until: is_zabbix_proxy_package_installed is succeeded
become: true
tags:
- install

- name: "Debian | Installing zabbix-sql-scripts"
ansible.builtin.apt:
pkg: zabbix-sql-scripts
state: "{{ zabbix_proxy_package_state }}"
update_cache: true
cache_valid_time: 0
default_release: "{{ ansible_distribution_release }}"
environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
register: zabbix_proxy_package_sql_installed
until: zabbix_proxy_package_sql_installed is succeeded
when:
- zabbix_proxy_version is version('6.0', '>=')
become: true
tags:
- install

- name: "Debian | Install Ansible module dependencies"
ansible.builtin.apt:
name: "{{ zabbix_python_prefix }}-psycopg2"
state: present
environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
register: zabbix_proxy_dependencies_installed
until: zabbix_proxy_dependencies_installed is succeeded
become: true
when:
- zabbix_proxy_database_creation
tags:
- install
- dependencies

- name: "Debian | Install Mysql Client package"
pyrodie18 marked this conversation as resolved.
Show resolved Hide resolved
ansible.builtin.apt:
name: "{{ mysql_client_pkgs[ansible_distribution_major_version] }}"
state: present
environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
register: zabbix_proxy_dependencies_installed
until: zabbix_proxy_dependencies_installed is succeeded
become: true
when:
- zabbix_proxy_database == 'mysql'
- zabbix_proxy_install_database_client
tags:
- install
- dependencies
- database

- name: "Debian | Install PostgreSQL Client package"
ansible.builtin.apt:
name: postgresql-client
state: present
environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
register: are_zabbix_proxy_dependency_packages_installed
until: are_zabbix_proxy_dependency_packages_installed is succeeded
become: true
when:
- zabbix_proxy_database_creation or zabbix_proxy_database_sqlload
- zabbix_proxy_database == 'pgsql'
- zabbix_proxy_install_database_client
tags:
- install
- dependencies
- database

- name: "Debian | Install sqlite3"
ansible.builtin.apt:
name: sqlite3
state: present
environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
register: are_zabbix_proxy_dependency_packages_installed
until: are_zabbix_proxy_dependency_packages_installed is succeeded
become: true
when:
- zabbix_proxy_database == 'sqlite3'
tags:
- install
- dependencies
- database
Loading
Loading