mirror of
https://gitlab.com/s3lph/ansible-collection-prometheus
synced 2024-11-22 09:41:01 +01:00
77 lines
2.4 KiB
YAML
77 lines
2.4 KiB
YAML
---
|
|
|
|
- name: check if package files already exist
|
|
stat:
|
|
path: "/root/{{ item.name }}_{{ item.version }}_{{ item.arch }}.deb"
|
|
loop:
|
|
- name: prometheus-node-exporter
|
|
version: 1.0.1+ds-1
|
|
arch: amd64
|
|
- name: prometheus-node-exporter-collectors
|
|
version: 0+git20201003.8db38d1-1
|
|
arch: all
|
|
- name: moreutils
|
|
version: 0.64-1
|
|
arch: amd64
|
|
register: prometheus_node_register_ucs_deb_stat
|
|
|
|
- name: download packages
|
|
get_url:
|
|
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"
|
|
vars:
|
|
pfirst: "{{ item.item.name[:1] }}"
|
|
package: "{{ item.item.name }}"
|
|
version: "{{ item.item.version }}"
|
|
arch: "{{ item.item.arch }}"
|
|
when: not item.stat.exists
|
|
loop: "{{ prometheus_node_register_ucs_deb_stat.results }}"
|
|
|
|
- name: install packages
|
|
apt:
|
|
deb: "/root/{{ item.item.name }}_{{ item.item.version }}_{{ item.item.arch }}.deb"
|
|
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 }}"
|