-
Notifications
You must be signed in to change notification settings - Fork 284
/
Debian.yml
167 lines (154 loc) · 4.93 KB
/
Debian.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
---
# Tasks specific for Debian/Ubuntu Systems
- name: "Include Zabbix gpg ids"
include_vars: zabbix.yml
- name: "Debian | Set some variables"
set_fact:
zabbix_short_version: "{{ zabbix_agent_version | regex_replace('\\.', '') }}"
zabbix_agent_apt_repository:
- "http://repo.zabbix.com/zabbix/{{ zabbix_agent_version }}/{{ ansible_distribution.lower() }}/"
- "{{ ansible_distribution_release }}"
- "main"
zabbix_underscore_version: "{{ zabbix_agent_version | regex_replace('\\.', '_') }}"
when:
- ansible_machine != "aarch64"
tags:
- always
- name: "Debian | Set some variables"
set_fact:
zabbix_short_version: "{{ zabbix_agent_version | regex_replace('\\.', '') }}"
zabbix_agent_apt_repository:
- "http://repo.zabbix.com/zabbix/{{ zabbix_agent_version }}/{{ ansible_distribution.lower() }}-arm64/"
- "{{ ansible_distribution_release }}"
- "main"
zabbix_underscore_version: "{{ zabbix_agent_version | regex_replace('\\.', '_') }}"
when:
- ansible_machine == "aarch64"
tags:
- always
- name: "Debian | Installing gnupg"
apt:
pkg: gnupg
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) }}"
register: gnupg_installed
until: gnupg_installed is succeeded
become: true
tags:
- install
# 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
- name: "Debian | Create /etc/apt/keyrings/ on older versions"
ansible.builtin.file:
path: /etc/apt/keyrings/
state: directory
mode: '0755'
when:
- (ansible_distribution == "Ubuntu" and ansible_distribution_major_version < "22") or
(ansible_distribution == "Debian" and ansible_distribution_major_version < "12")
- name: "Debian | Download gpg key"
ansible.builtin.get_url:
url: http://repo.zabbix.com/zabbix-official-repo.key
dest: "{{ zabbix_gpg_key }}"
mode: '0644'
force: true
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 | Installing repository {{ ansible_distribution }}"
apt_repository:
repo: "{{ item }} [signed-by={{ zabbix_gpg_key }}] {{ zabbix_agent_apt_repository | join(' ') }}"
state: present
become: true
with_items:
- deb-src
- deb
tags:
- install
- name: "Debian | Create /etc/apt/preferences.d/"
file:
path: /etc/apt/preferences.d/
state: directory
mode: "0755"
when:
- zabbix_agent_apt_priority | int
become: true
tags:
- install
- name: "Debian | Configuring the weight for APT"
copy:
dest: "/etc/apt/preferences.d/zabbix-agent-{{ zabbix_underscore_version }}"
content: |
Package: {{ zabbix_agent_package }}
Pin: origin repo.zabbix.com
Pin-Priority: {{ zabbix_agent_apt_priority | int }}
owner: root
mode: "0644"
when:
- zabbix_agent_apt_priority | int
become: true
tags:
- install
- name: "Debian | apt-get clean"
shell: apt-get clean; apt-get update
args:
warn: "{{ produce_warn | default(omit) }}"
changed_when: false
become: true
tags:
- skip_ansible_lint
- install
- name: "Debian | Installing zabbix-agent"
apt:
pkg: "{{ zabbix_agent_package }}"
state: "{{ zabbix_agent_package_state }}"
update_cache: true
cache_valid_time: 0
force_apt_get: "{{ zabbix_apt_force_apt_get }}"
install_recommends: "{{ zabbix_apt_install_recommends }}"
environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
register: zabbix_agent_package_installed
until: zabbix_agent_package_installed is succeeded
become: true
tags:
- install
- name: "Debian | Installing zabbix-{sender,get}"
apt:
pkg:
- "{{ zabbix_sender_package }}"
- "{{ zabbix_get_package }}"
state: "{{ zabbix_agent_package_state }}"
update_cache: true
cache_valid_time: 0
force_apt_get: "{{ zabbix_apt_force_apt_get }}"
install_recommends: "{{ zabbix_apt_install_recommends }}"
environment:
http_proxy: "{{ zabbix_http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ zabbix_https_proxy | default(None) | default(omit) }}"
when:
- not zabbix_agent_install_agent_only
register: zabbix_agent_package_installed
until: zabbix_agent_package_installed is succeeded
become: true
check_mode: false
tags:
- install
- name: "Debian | Enable the service"
service:
name: "{{ zabbix_agent_service }}"
enabled: true
use: service
become: true
tags:
- service