2020-11-13 10:36:46 +01:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: check if package files already exist
|
|
|
|
stat:
|
2020-11-13 12:03:34 +01:00
|
|
|
path: "/root/{{ item.name }}_{{ item.version }}_{{ item.arch }}.deb"
|
2020-11-13 10:36:46 +01:00
|
|
|
loop:
|
|
|
|
- name: prometheus-node-exporter
|
2020-11-13 11:34:25 +01:00
|
|
|
version: 1.0.1+ds-1
|
2020-11-13 12:03:34 +01:00
|
|
|
arch: amd64
|
2020-11-13 11:34:25 +01:00
|
|
|
- name: prometheus-node-exporter-collectors
|
2020-11-13 12:09:39 +01:00
|
|
|
version: 0+git20201003.8db38d1-1
|
2020-11-13 12:03:34 +01:00
|
|
|
arch: all
|
2020-11-13 10:36:46 +01:00
|
|
|
- name: moreutils
|
2020-11-13 11:34:25 +01:00
|
|
|
version: 0.64-1
|
2020-11-13 12:03:34 +01:00
|
|
|
arch: amd64
|
2020-11-13 10:36:46 +01:00
|
|
|
register: prometheus_node_register_ucs_deb_stat
|
|
|
|
|
|
|
|
- name: download packages
|
|
|
|
get_url:
|
2020-11-13 12:03:34 +01:00
|
|
|
url: "https://{{ debian_mirror }}/debian/pool/main/{{ pfirst | urlencode() }}/{{ package | urlencode() }}/{{ package | urlencode() }}_{{ version | urlencode() }}_{{ arch | urlencode() }}.deb" # noqa 204
|
|
|
|
dest: "/root/{{ package }}_{{ version }}_{{ arch }}.deb"
|
2020-11-13 10:36:46 +01:00
|
|
|
vars:
|
|
|
|
pfirst: "{{ item.item.name[:1] }}"
|
|
|
|
package: "{{ item.item.name }}"
|
|
|
|
version: "{{ item.item.version }}"
|
2020-11-13 12:03:34 +01:00
|
|
|
arch: "{{ item.item.arch }}"
|
2020-11-13 10:36:46 +01:00
|
|
|
when: not item.stat.exists
|
|
|
|
loop: "{{ prometheus_node_register_ucs_deb_stat.results }}"
|
|
|
|
|
|
|
|
- name: install packages
|
|
|
|
apt:
|
2020-11-13 12:03:34 +01:00
|
|
|
deb: "/root/{{ item.item.name }}_{{ item.item.version }}_{{ item.item.arch }}.deb"
|
2020-11-13 10:36:46 +01:00
|
|
|
loop: "{{ prometheus_node_register_ucs_deb_stat.results }}"
|
|
|
|
|
|
|
|
- name: start prometheus-node-exporter.service
|
|
|
|
systemd:
|
|
|
|
name: prometheus-node-exporter.service
|
|
|
|
state: started
|
|
|
|
enabled: yes
|
|
|
|
|
|
|
|
- name: start prometheus-node-exporter-apt.timer
|
|
|
|
systemd:
|
|
|
|
name: prometheus-node-exporter-apt.timer
|
|
|
|
state: started
|
|
|
|
enabled: yes
|
|
|
|
|
|
|
|
- name: install smartmontools
|
|
|
|
apt:
|
|
|
|
name: smartmontools
|
|
|
|
state: present
|
|
|
|
when:
|
|
|
|
- ansible_virtualization_role == 'host'
|
|
|
|
|
|
|
|
- name: start prometheus-node-exporter-smartmon.timer
|
|
|
|
systemd:
|
|
|
|
name: prometheus-node-exporter-smartmon.timer
|
|
|
|
state: "{{ (ansible_virtualization_role == 'host' and not smartmon_exporter_force_off) | ternary('started', 'stopped') }}"
|
|
|
|
enabled: "{{ ansible_virtualization_role == 'host' }}"
|
|
|
|
|
|
|
|
- name: check firewall settings in ucr
|
|
|
|
command: "/usr/sbin/ucr get {{ item.name }}"
|
|
|
|
changed_when: no
|
|
|
|
check_mode: no
|
|
|
|
loop:
|
|
|
|
- name: security/packetfilter/tcp/9101/all
|
|
|
|
value: ACCEPT
|
|
|
|
- name: security/packetfilter/tcp/9101/all/en
|
|
|
|
value: prometheus-node-exporter
|
|
|
|
register: prometheus_node_register_ucs_ucr
|
|
|
|
|
|
|
|
- name: set firewall settings in ucr
|
|
|
|
command: "/usr/sbin/ucr set {{ item.item.name }}={{ item.item.value }}"
|
|
|
|
changed_when: yes
|
|
|
|
notify:
|
|
|
|
- ucr commit
|
|
|
|
when: item.stdout != item.item.value
|
|
|
|
loop: "{{ prometheus_node_register_ucs_ucr.results }}"
|