Check the presence of the zabbix-release package before trying to install it. #8
|
@ -5,6 +5,10 @@ zabbix_repo_version: '4.0'
|
||||||
zabbix_agent_ubuntu_repo: 'https://repo.zabbix.com/zabbix/{{ zabbix_repo_version }}/{{ ansible_distribution | lower }}/pool/main/z/zabbix-release/zabbix-release_{{ zabbix_repo_version }}-2+{{ ansible_distribution_release }}_all.deb'
|
zabbix_agent_ubuntu_repo: 'https://repo.zabbix.com/zabbix/{{ zabbix_repo_version }}/{{ ansible_distribution | lower }}/pool/main/z/zabbix-release/zabbix-release_{{ zabbix_repo_version }}-2+{{ ansible_distribution_release }}_all.deb'
|
||||||
zabbix_agent_centos_repo: 'https://repo.zabbix.com/zabbix/{{ zabbix_repo_version }}/rhel/{{ ansible_distribution_major_version }}/x86_64/zabbix-release-{{ zabbix_repo_version }}-1.el7.noarch.rpm'
|
zabbix_agent_centos_repo: 'https://repo.zabbix.com/zabbix/{{ zabbix_repo_version }}/rhel/{{ ansible_distribution_major_version }}/x86_64/zabbix-release-{{ zabbix_repo_version }}-1.el7.noarch.rpm'
|
||||||
|
|
||||||
|
zabbix_agent_packages:
|
||||||
|
- 'zabbix-agent'
|
||||||
|
- 'zabbix-release'
|
||||||
|
|
||||||
zabbix_agent_conf_dir: /etc/zabbix
|
zabbix_agent_conf_dir: /etc/zabbix
|
||||||
zabbix_agent_include_conf_dir: '{{ zabbix_agent_conf_dir }}/zabbix_agentd.d'
|
zabbix_agent_include_conf_dir: '{{ zabbix_agent_conf_dir }}/zabbix_agentd.d'
|
||||||
zabbix_agent_log_dir: '/var/log/zabbix'
|
zabbix_agent_log_dir: '/var/log/zabbix'
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
---
|
---
|
||||||
|
- name: Check if the zabbix repository is installed
|
||||||
|
package_facts:
|
||||||
|
manager: "auto"
|
||||||
|
when:
|
||||||
|
- zabbix_agent_install | bool
|
||||||
|
tags: [ 'zabbix', 'zabbix_agent' ]
|
||||||
|
|
||||||
- import_tasks: zabbix-agent-deb.yml
|
- import_tasks: zabbix-agent-deb.yml
|
||||||
when:
|
when:
|
||||||
- zabbix_agent_install | bool
|
- zabbix_agent_install | bool
|
||||||
|
|
|
@ -2,14 +2,15 @@
|
||||||
- name: Repository and packages, deb/ubuntu
|
- name: Repository and packages, deb/ubuntu
|
||||||
block:
|
block:
|
||||||
- name: Install the repository
|
- name: Install the repository
|
||||||
apt: deb={{ zabbix_agent_ubuntu_repo }} state=latest
|
apt: deb={{ zabbix_agent_ubuntu_repo }} state=present
|
||||||
register: update_apt_cache
|
register: update_apt_cache
|
||||||
|
when: "'zabbix-release' not in ansible_facts.packages"
|
||||||
|
|
||||||
- name: Update the apt cache if we just installed the repository
|
- name: Update the apt cache if we just installed the repository
|
||||||
apt: update_cache=yes
|
apt: update_cache=yes
|
||||||
when: update_apt_cache is changed
|
when: update_apt_cache is defined and update_apt_cache is changed
|
||||||
|
|
||||||
- name: Install the Zabbix agent package
|
- name: Install the Zabbix agent package
|
||||||
apt: pkg=zabbix-agent state=latest cache_valid_time=1800
|
apt: pkg={{ zabbix_agent_packages }} state=latest cache_valid_time=1800
|
||||||
|
|
||||||
tags: [ 'zabbix', 'zabbix_agent' ]
|
tags: [ 'zabbix', 'zabbix_agent' ]
|
||||||
|
|
|
@ -2,9 +2,10 @@
|
||||||
- name: Repository and packages, RH/CentOS
|
- name: Repository and packages, RH/CentOS
|
||||||
block:
|
block:
|
||||||
- name: Install the repository
|
- name: Install the repository
|
||||||
yum: name={{ zabbix_agent_centos_repo }} state=latest
|
yum: name={{ zabbix_agent_centos_repo }} state=present
|
||||||
|
when: "'zabbix-release' not in ansible_facts.packages"
|
||||||
|
|
||||||
- name: Install the Zabbix agent package
|
- name: Install the Zabbix agent package
|
||||||
yum: name=zabbix-agent state=latest
|
yum: name={{ zabbix_agent_packages }} state=latest
|
||||||
|
|
||||||
tags: [ 'zabbix', 'zabbix_agent' ]
|
tags: [ 'zabbix', 'zabbix_agent' ]
|
||||||
|
|
Loading…
Reference in New Issue