-
-
Notifications
You must be signed in to change notification settings - Fork 114
/
Debian.yml
143 lines (127 loc) · 5.21 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
---
- name: "Debian | Set name if state != latest"
set_fact:
telegraf_agent_package: telegraf={{ telegraf_agent_version }}-{{ telegraf_agent_version_patch }}
when:
- telegraf_agent_package_state != "latest"
- name: "Debian | Set telegraf_agent_package_arch"
set_fact:
telegraf_agent_package_arch: "{{ ansible_architecture }}"
- name: "Debian | Set telegraf_agent_package_arch specific for x86_64"
set_fact:
telegraf_agent_package_arch: "amd64"
when:
- ansible_architecture == "x86_64"
- name: "Debian | Set telegraf_agent_package_arch specific for arm64"
set_fact:
telegraf_agent_package_arch: "armhf"
when:
- ansible_architecture == "arm64"
- name: "Debian | Ensure the system can use the HTTPS transport for APT"
stat:
path: /usr/lib/apt/methods/https
register: apt_https_transport
- name: "Debian | Install APT HTTPS transport"
apt:
name: "apt-transport-https"
state: present
register: are_telegraf_dependencies_packages_installed
until: are_telegraf_dependencies_packages_installed is succeeded
when:
- not apt_https_transport.stat.exists
become: true
- name: "Debian | Configure Telegraf apt repository"
when:
- telegraf_agent_package_method == "repo"
block:
- when: (ansible_distribution == "Debian" and ansible_distribution_major_version|int < 9) or (ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int < 18)
name: "Debian | Download Telegraf apt key"
apt_key:
url: "https://repos.influxdata.com/influxdata-archive.key"
id: 7df8b07e
state: present
register: are_telegraf_dependencies_keys_installed
until: are_telegraf_dependencies_keys_installed is succeeded
become: true
- when: (ansible_distribution == "Debian" and ansible_distribution_major_version|int >= 9) or (ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int >= 18)
block:
- name: "Debian | Ensure the shared keyrings directory exists"
stat:
path: /usr/share/keyrings
register: usr_share_keyrings
- name: "Debian | Create shared keyrings directory"
file:
state: directory
path: /usr/share/keyrings
owner: root
group: root
mode: 0755
when:
- not usr_share_keyrings.stat.exists
become: true
- name: "Debian | Install Telegraf apt key"
get_url:
url: https://repos.influxdata.com/influxdata-archive.key
dest: /usr/share/keyrings/influxdata-archive.asc
register: are_telegraf_dependencies_keys_installed
until: are_telegraf_dependencies_keys_installed is succeeded
become: true
- name: "Debian | Set Telegraf apt repository parameters"
set_fact:
telegraf_repository_params: "[signed-by=/usr/share/keyrings/influxdata-archive.asc]"
- name: "Debian | Add Telegraf repository"
copy:
content: "deb {{ telegraf_repository_params | default('') }} https://repos.influxdata.com/{{ ansible_distribution|lower }} stable main"
dest: /etc/apt/sources.list.d/telegraf.list
become: yes
- name: "Debian | Install Telegraf package (repo)"
apt:
name: "{{ telegraf_agent_package }}"
state: "{{ telegraf_agent_package_state }}"
update_cache: true
register: is_telegraf_package_installed
until: is_telegraf_package_installed is succeeded
notify: "Restart Telegraf"
become: true
when:
- telegraf_agent_package_method == "repo"
ignore_errors: "{{ ansible_check_mode }}"
- name: "Debian | Install Telegraf package (repo)"
apt:
name: "{{ telegraf_agent_package }}"
state: "{{ telegraf_agent_package_state }}"
update_cache: true
register: is_telegraf_package_installed
until: is_telegraf_package_installed is succeeded
notify: "Restart Telegraf"
become: true
ignore_errors: "{{ ansible_check_mode }}"
- name: "Debian | Download Telegraf package (online)"
get_url:
url: https://dl.influxdata.com/telegraf/releases/{{ telegraf_agent_package_file_deb }}
dest: "{{ telegraf_agent_package_path }}/{{ telegraf_agent_package }}"
use_proxy: "{{ true if http_proxy is defined and http_proxy else false }}"
environment:
http_proxy: "{{ http_proxy | default(None) | default(omit) }}"
https_proxy: "{{ https_proxy | default(None) | default(omit) }}"
when:
- telegraf_agent_package_method == "online"
- name: "Debian | Install Telegraf package (online)"
apt:
deb: "{{ telegraf_agent_package_path }}/{{ telegraf_agent_package }}"
state: "present"
allow_downgrade: true
register: is_telegraf_package_installed
until: is_telegraf_package_installed is succeeded
notify: "Restart Telegraf"
become: true
when:
- telegraf_agent_package_method == "online" or telegraf_agent_package_method == "offline"
ignore_errors: "{{ ansible_check_mode }}"
- name: "Debian | Remove repository (online/offline install)"
file:
path: "/etc/apt/sources.list.d/telegraf.list"
state: absent
become: true
when:
- telegraf_agent_package_method == "online" or telegraf_agent_package_method == "offline"