fix(lint): warning lint errors

Signed-off-by: gardar <gardar@users.noreply.github.com>
This commit is contained in:
gardar 2022-11-25 10:37:52 +00:00
parent e99b807340
commit 2c075e3b15
No known key found for this signature in database
GPG key ID: 75FAE37CBA8C13C2
25 changed files with 78 additions and 130 deletions

View file

@ -1,12 +1,14 @@
---
- name: restart alertmanager
- name: Restart alertmanager
listen: "restart alertmanager"
become: true
ansible.builtin.systemd:
daemon_reload: true
name: alertmanager
state: restarted
- name: reload alertmanager
- name: Reload alertmanager
listen: "reload alertmanager"
become: true
ansible.builtin.systemd:
name: alertmanager

View file

@ -3,10 +3,10 @@
hosts: localhost
gather_facts: false
vars:
# Version seeds to be specified here as molecule doesn't have access to ansible_version at this stage
# Version needs to be specified here as molecule doesn't have access to ansible_version at this stage
version: 0.19.0
tasks:
- name: download alertmanager binary to local folder
- name: Download alertmanager binary to local folder
become: false
ansible.builtin.get_url:
url: "https://github.com/prometheus/alertmanager/releases/download/v{{ version }}/alertmanager-{{ version }}.linux-amd64.tar.gz"
@ -18,7 +18,7 @@
run_once: true
check_mode: false
- name: unpack alertmanager binaries
- name: Unpack alertmanager binaries
become: false
ansible.builtin.unarchive:
src: "/tmp/alertmanager-{{ version }}.linux-amd64.tar.gz"
@ -27,7 +27,7 @@
run_once: true
check_mode: false
- name: link to alertmanager binaries directory
- name: Link to alertmanager binaries directory
become: false
ansible.builtin.file:
src: "/tmp/alertmanager-{{ version }}.linux-amd64"

View file

@ -1,5 +1,5 @@
---
- name: copy amtool config
- name: Copy amtool config
ansible.builtin.template:
force: true
src: "{{ alertmanager_amtool_config_file }}"
@ -8,7 +8,7 @@
ansible.builtin.group: alertmanager
mode: 0644
- name: copy alertmanager config
- name: Copy alertmanager config
ansible.builtin.template:
force: true
src: "{{ alertmanager_config_file }}"
@ -30,7 +30,7 @@
notify:
- restart alertmanager
- name: copy alertmanager template files
- name: Copy alertmanager template files
ansible.builtin.copy:
src: "{{ item }}"
dest: "{{ alertmanager_config_dir }}/templates/"

View file

@ -26,8 +26,11 @@
- "{{ alertmanager_db_dir }}"
- "{{ _alertmanager_amtool_config_dir }}"
- block:
- name: download alertmanager binary to local folder
- name: Get alertmanager binary
when: alertmanager_binary_local_dir | length == 0
block:
- name: Download alertmanager binary to local folder
become: false
ansible.builtin.get_url:
url: "https://github.com/prometheus/alertmanager/releases/download/v{{ alertmanager_version }}/alertmanager-{{ alertmanager_version }}.linux-{{ go_arch }}.tar.gz"
@ -37,11 +40,11 @@
until: _download_archive is succeeded
retries: 5
delay: 2
# run_once: true # <-- this can't be set due to multi-arch support
# run_once: true # <-- this can't be set due to multi-arch support
delegate_to: localhost
check_mode: false
- name: unpack alertmanager binaries
- name: Unpack alertmanager binaries
become: false
ansible.builtin.unarchive:
src: "/tmp/alertmanager-{{ alertmanager_version }}.linux-{{ go_arch }}.tar.gz"
@ -51,7 +54,7 @@
delegate_to: localhost
check_mode: false
- name: propagate official alertmanager and amtool binaries
- name: Propagate official alertmanager and amtool binaries
ansible.builtin.copy:
src: "/tmp/alertmanager-{{ alertmanager_version }}.linux-{{ go_arch }}/{{ item }}"
dest: "{{ _alertmanager_binary_install_dir }}/{{ item }}"
@ -63,9 +66,8 @@
- amtool
notify:
- restart alertmanager
when: alertmanager_binary_local_dir | length == 0
- name: propagate locally distributed alertmanager and amtool binaries
- name: Propagate locally distributed alertmanager and amtool binaries
ansible.builtin.copy:
src: "{{ alertmanager_binary_local_dir }}/{{ item }}"
dest: "{{ _alertmanager_binary_install_dir }}/{{ item }}"

View file

@ -1,31 +1,15 @@
---
- name: Install selinux python packages [RHEL]
- name: Install selinux python packages [RedHat]
ansible.builtin.package:
name:
- "{{ ( (ansible_facts.distribution_major_version | int) < 8) | ternary('libselinux-python','python3-libselinux') }}"
- "{{ ( (ansible_facts.distribution_major_version | int) < 8) | ternary('libselinux-python','python3-policycoreutils') }}"
name: "{{ ['libselinux-python', 'python-policycoreutils']
if ansible_python_version is version('3', '<') else
['python3-libselinux', 'python3-policycoreutils'] }}"
state: present
register: _install_selinux_packages
until: _install_selinux_packages is success
retries: 5
delay: 2
when:
- (ansible_distribution | lower == "redhat") or
(ansible_distribution | lower == "centos")
- name: Install selinux python packages [Fedora]
ansible.builtin.package:
name:
- "{{ ( (ansible_facts.distribution_major_version | int) < 29) | ternary('libselinux-python','python3-libselinux') }}"
- "{{ ( (ansible_facts.distribution_major_version | int) < 29) | ternary('libselinux-python','python3-policycoreutils') }}"
state: present
register: _install_selinux_packages
until: _install_selinux_packages is success
retries: 5
delay: 2
when:
- ansible_distribution | lower == "fedora"
when: ansible_os_family | lower == redhat
- name: Install selinux python packages [clearlinux]
ansible.builtin.package:

View file

@ -1,12 +1,14 @@
---
- name: restart blackbox exporter
- name: Restart blackbox exporter
listen: "restart blackbox exporter"
become: true
ansible.builtin.systemd:
daemon_reload: true
name: blackbox_exporter
state: restarted
- name: reload blackbox exporter
- name: Reload blackbox exporter
listen: "reload blackbox exporter"
become: true
ansible.builtin.systemd:
name: blackbox_exporter

View file

@ -9,7 +9,7 @@
notify:
- restart blackbox exporter
- name: configure blackbox exporter
- name: Configure blackbox exporter
ansible.builtin.template:
src: blackbox_exporter.yml.j2
dest: /etc/blackbox_exporter.yml

View file

@ -13,7 +13,7 @@
ansible.builtin.group: blackbox-exp
createhome: false
- name: download blackbox exporter binary to local folder
- name: Download blackbox exporter binary to local folder
become: false
ansible.builtin.unarchive:
src: "https://github.com/prometheus/blackbox_exporter/releases/download/v{{ blackbox_exporter_version }}/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz"
@ -27,7 +27,7 @@
delegate_to: localhost
check_mode: false
- name: propagate blackbox exporter binary
- name: Propagate blackbox exporter binary
ansible.builtin.copy:
src: "/tmp/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/blackbox_exporter"
dest: "/usr/local/bin/blackbox_exporter"

View file

@ -1,5 +1,6 @@
---
- name: restart node_exporter
- name: Restart node_exporter
listen: "restart node_exporter"
become: true
ansible.builtin.systemd:
daemon_reload: true

View file

@ -27,7 +27,7 @@
run_once: true
check_mode: false
- name: link to node_exporter binaries directory
- name: Link to node_exporter binaries directory
become: false
ansible.builtin.file:
src: "/tmp/node_exporter-{{ node_exporter_version }}.linux-amd64"
@ -36,7 +36,7 @@
run_once: true
check_mode: false
- name: install pyOpenSSL for certificate generation
- name: Install pyOpenSSL for certificate generation
ansible.builtin.pip:
name: "pyOpenSSL"

View file

@ -52,7 +52,7 @@
when: not ansible_check_mode
when: node_exporter_binary_local_dir | length == 0
- name: propagate locally distributed node_exporter binary
- name: Propagate locally distributed node_exporter binary
ansible.builtin.copy:
src: "{{ node_exporter_binary_local_dir }}/node_exporter"
dest: "{{ _node_exporter_binary_install_dir }}/node_exporter"

View file

@ -1,31 +1,15 @@
---
- name: Install selinux python packages [RHEL]
- name: Install selinux python packages [RedHat]
ansible.builtin.package:
name:
- "{{ ( (ansible_facts.distribution_major_version | int) < 8) | ternary('libselinux-python','python3-libselinux') }}"
- "{{ ( (ansible_facts.distribution_major_version | int) < 8) | ternary('policycoreutils-python','python3-policycoreutils') }}"
name: "{{ ['libselinux-python', 'python-policycoreutils']
if ansible_python_version is version('3', '<') else
['python3-libselinux', 'python3-policycoreutils'] }}"
state: present
register: _install_selinux_packages
until: _install_selinux_packages is success
retries: 5
delay: 2
when:
- (ansible_distribution | lower == "redhat") or
(ansible_distribution | lower == "centos")
- name: Install selinux python packages [Fedora]
ansible.builtin.package:
name:
- "{{ ( (ansible_facts.distribution_major_version | int) < 29) | ternary('libselinux-python','python3-libselinux') }}"
- "{{ ( (ansible_facts.distribution_major_version | int) < 29) | ternary('policycoreutils-python','python3-policycoreutils') }}"
state: present
register: _install_selinux_packages
until: _install_selinux_packages is success
retries: 5
delay: 2
when:
- ansible_distribution | lower == "fedora"
when: ansible_os_family | lower == redhat
- name: Install selinux python packages [clearlinux]
ansible.builtin.package:

View file

@ -1,12 +1,14 @@
---
- name: restart prometheus
- name: Restart prometheus
listen: "restart prometheus"
become: true
ansible.builtin.systemd:
daemon_reload: true
name: prometheus
state: restarted
- name: reload prometheus
- name: Reload prometheus
listen: "reload prometheus"
become: true
ansible.builtin.systemd:
name: prometheus

View file

@ -19,7 +19,7 @@
run_once: true
check_mode: false
- name: unpack prometheus binaries
- name: Unpack prometheus binaries
become: false
ansible.builtin.unarchive:
src: "/tmp/prometheus-{{ version }}.linux-amd64.tar.gz"
@ -28,7 +28,7 @@
run_once: true
check_mode: false
- name: link to prometheus binaries directory
- name: Link to prometheus binaries directory
become: false
ansible.builtin.file:
src: "/tmp/prometheus-{{ version }}.linux-amd64"

View file

@ -1,5 +1,5 @@
---
- name: alerting rules file
- name: Alerting rules file
ansible.builtin.template:
src: "alert.rules.j2"
dest: "{{ prometheus_config_dir }}/rules/ansible_managed.rules"
@ -12,7 +12,7 @@
notify:
- reload prometheus
- name: copy custom alerting rule files
- name: Copy custom alerting rule files
ansible.builtin.copy:
src: "{{ item }}"
dest: "{{ prometheus_config_dir }}/rules/"
@ -24,7 +24,7 @@
notify:
- reload prometheus
- name: configure prometheus
- name: Configure prometheus
ansible.builtin.template:
src: "{{ prometheus_config_file }}"
dest: "{{ prometheus_config_dir }}/prometheus.yml"
@ -36,29 +36,29 @@
notify:
- reload prometheus
- name: configure Prometheus web
- name: Configure Prometheus web
ansible.builtin.template:
content: "{{ prometheus_web_config | to_nice_yaml(indent=2,sort_keys=False) }}"
content: "{{ prometheus_web_config | to_nice_yaml(indent=2, sort_keys=False) }}"
dest: "{{ prometheus_config_dir }}/web.yml"
force: true
owner: root
ansible.builtin.group: prometheus
mode: 0640
- name: configure prometheus static targets
- name: Configure prometheus static targets
ansible.builtin.template:
content: |
#jinja2: lstrip_blocks: True
{{ item.value | to_nice_yaml(indent=2,sort_keys=False) }}
{{ item.value | to_nice_yaml(indent=2, sort_keys=False) }}
lstrip_blocks: true
dest: "{{ prometheus_config_dir }}/file_sd/{{ item.key }}.yml"
force: true
owner: root
ansible.builtin.group: prometheus
group: prometheus
mode: 0640
with_dict: "{{ prometheus_targets }}"
when: prometheus_targets != {}
- name: copy prometheus custom static targets
- name: Copy prometheus custom static targets
ansible.builtin.copy:
src: "{{ item }}"
dest: "{{ prometheus_config_dir }}/file_sd/"

View file

@ -34,8 +34,13 @@
- "{{ prometheus_config_dir }}/rules"
- "{{ prometheus_config_dir }}/file_sd"
- block:
- name: download prometheus binary to local folder
- name: Get prometheus binary
when:
- prometheus_binary_local_dir | length == 0
- not prometheus_skip_install
block:
- name: Download prometheus binary to local folder
become: false
ansible.builtin.get_url:
url: "https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz"
@ -49,7 +54,7 @@
delegate_to: localhost
check_mode: false
- name: unpack prometheus binaries
- name: Unpack prometheus binaries
become: false
ansible.builtin.unarchive:
src: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz"
@ -58,7 +63,7 @@
delegate_to: localhost
check_mode: false
- name: propagate official prometheus and promtool binaries
- name: Propagate official prometheus and promtool binaries
ansible.builtin.copy:
src: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}/{{ item }}"
dest: "{{ _prometheus_binary_install_dir }}/{{ item }}"
@ -71,7 +76,7 @@
notify:
- restart prometheus
- name: propagate official console templates
- name: Propagate official console templates
ansible.builtin.copy:
src: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}/{{ item }}/"
dest: "{{ prometheus_config_dir }}/{{ item }}/"
@ -83,11 +88,8 @@
- consoles
notify:
- restart prometheus
when:
- prometheus_binary_local_dir | length == 0
- not prometheus_skip_install
- name: propagate locally distributed prometheus and promtool binaries
- name: Propagate locally distributed prometheus and promtool binaries
ansible.builtin.copy:
src: "{{ prometheus_binary_local_dir }}/{{ item }}"
dest: "{{ _prometheus_binary_install_dir }}/{{ item }}"
@ -115,9 +117,8 @@
- name: Install SELinux dependencies
ansible.builtin.package:
name: "{{ item }}"
name: "{{ _prometheus_selinux_packages }}"
state: present
with_items: "{{ prometheus_selinux_packages }}"
register: _install_packages
until: _install_packages is succeeded
retries: 5

View file

@ -1,16 +1,4 @@
---
- name: Gather variables for each operating system
ansible.builtin.include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version }}.yml"
- "{{ ansible_distribution | lower }}.yml"
- "{{ ansible_os_family | lower }}-{{ ansible_distribution_major_version | lower }}.yml"
- "{{ ansible_os_family | lower }}.yml"
tags:
- prometheus_configure
- prometheus_install
- prometheus_run
- name: Preflight
ansible.builtin.include_tasks: preflight.yml
tags:

View file

@ -1,4 +0,0 @@
---
prometheus_selinux_packages:
- python3-libselinux
- python3-policycoreutils

View file

@ -1,4 +0,0 @@
---
prometheus_selinux_packages:
- libselinux-python
- policycoreutils-python

View file

@ -1,4 +0,0 @@
---
prometheus_selinux_packages:
- python-selinux
- policycoreutils

View file

@ -1,4 +0,0 @@
---
prometheus_selinux_packages:
- python3-libselinux
- python3-policycoreutils

View file

@ -8,3 +8,7 @@ go_arch_map:
go_arch: "{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}"
_prometheus_binary_install_dir: '/usr/local/bin'
_prometheus_selinux_packages: "{{ ['libselinux-python', 'python-policycoreutils']
if ansible_python_version is version('3', '<') else
['python3-libselinux', 'python3-policycoreutils'] }}"

View file

@ -1,4 +0,0 @@
---
prometheus_selinux_packages:
- python3-libselinux
- python3-policycoreutils

View file

@ -1,4 +0,0 @@
---
prometheus_selinux_packages:
- libselinux-python
- policycoreutils-python

View file

@ -1,11 +1,13 @@
---
- name: reload snmp exporter
- name: Reload snmp exporter
listen: "reload snmp exporter"
ansible.builtin.systemd:
daemon_reload: true
name: snmp_exporter
state: reloaded
- name: restart snmp exporter
- name: Restart snmp exporter
listen: "restart snmp exporter"
ansible.builtin.systemd:
daemon_reload: true
name: snmp_exporter