fix(lint): fix all linter exceptions and remove exception rules

Signed-off-by: gardar <gardar@users.noreply.github.com>
This commit is contained in:
gardar 2022-11-25 13:53:37 +00:00
parent 2c075e3b15
commit 2529617e41
No known key found for this signature in database
GPG key ID: 75FAE37CBA8C13C2
27 changed files with 149 additions and 118 deletions

View file

@ -1,10 +0,0 @@
---
skip_list:
- experimental
- yaml[indentation] # Violations reported by yamllint.
- yaml[line-length] # Violations reported by yamllint.
- name[play] # Rule for checking task and play names.
- name[missing] # Rule for checking task and play names.
warn_list:
- jinja[spacing] # Rule that looks inside jinja2 templates.
- name[casing] # Rule for checking task and play names.

View file

@ -16,16 +16,16 @@ galaxy_info:
- buster
- name: EL
versions:
- 7
- 8
- '7'
- '8'
- name: Fedora
versions:
- 30
- 31
- '30'
- '31'
galaxy_tags:
- monitoring
- prometheus
- alerting
- alert
- monitoring
- prometheus
- alerting
- alert
dependencies: []

View file

@ -1,5 +1,6 @@
---
- hosts: all
- name: Converge
hosts: all
any_errors_fatal: true
roles:
- alertmanager

View file

@ -11,6 +11,7 @@
ansible.builtin.get_url:
url: "https://github.com/prometheus/alertmanager/releases/download/v{{ version }}/alertmanager-{{ version }}.linux-amd64.tar.gz"
dest: "/tmp/alertmanager-{{ version }}.linux-amd64.tar.gz"
mode: 0644
register: _download_archive
until: _download_archive is succeeded
retries: 5

View file

@ -1,5 +1,6 @@
---
- hosts: all
- name: Converge
hosts: all
any_errors_fatal: true
roles:
- alertmanager

View file

@ -33,9 +33,11 @@
- 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"
url: "https://github.com/prometheus/alertmanager/releases/download/v{{ alertmanager_version }}/
alertmanager-{{ alertmanager_version }}.linux-{{ go_arch }}.tar.gz"
dest: "/tmp/alertmanager-{{ alertmanager_version }}.linux-{{ go_arch }}.tar.gz"
checksum: "sha256:{{ __alertmanager_checksum }}"
mode: 0644
register: _download_archive
until: _download_archive is succeeded
retries: 5

View file

@ -16,7 +16,12 @@
ansible.builtin.set_fact:
alertmanager_systemd_version: "{{ __systemd_version.stdout_lines[0].split(' ')[-1] }}"
- block:
- name: Discover latest version
when:
- alertmanager_version == "latest"
- alertmanager_binary_local_dir | length == 0
block:
- name: Get latest release
ansible.builtin.uri:
url: "https://api.github.com/repos/prometheus/alertmanager/releases/latest"
@ -35,11 +40,12 @@
ansible.builtin.set_fact:
alertmanager_version: "{{ _latest_release.json.tag_name[1:] }}"
alertmanager_checksum_url: "https://github.com/prometheus/alertmanager/releases/download/v{{ alertmanager_version }}/sha256sums.txt"
when:
- alertmanager_version == "latest"
- alertmanager_binary_local_dir | length == 0
- block:
- name: Get alertmanager binary checksum
delegate_to: localhost
when:
- alertmanager_binary_local_dir | length == 0
block:
- name: "Get checksum list"
ansible.builtin.set_fact:
__alertmanager_checksums: "{{ lookup('url', 'https://github.com/prometheus/alertmanager/releases/download/v' + alertmanager_version + '/sha256sums.txt', wantlist=True) | list }}"
@ -51,9 +57,6 @@
with_items: "{{ __alertmanager_checksums }}"
when:
- "('linux-' + go_arch + '.tar.gz') in item"
delegate_to: localhost
when:
- alertmanager_binary_local_dir | length == 0
- name: Fail when extra config flags are duplicating ansible variables
@ -80,54 +83,58 @@
- alertmanager_route == {}
- name: "DEPRECATION WARNING: alertmanager version 0.15 and earlier are no longer supported and will be dropped from future releases"
ignore_errors: true
failed_when: false
ansible.builtin.fail:
msg: "Please use `alertmanager_version >= v0.16.0`"
when: alertmanager_version is version_compare('0.16.0', '<')
- block:
- name: Check deprecated variable `alertmanager_cli_flags`
when: alertmanager_cli_flags is defined
block:
- name: Backward compatibility of variable [part 1]
ansible.builtin.set_fact:
alertmanager_config_flags_extra: "{{ alertmanager_cli_flags }}"
- name: "DEPRECATION WARNING: `alertmanager_cli_flags` is no longer supported and will be dropped from future releases"
ignore_errors: true
failed_when: false
ansible.builtin.fail:
msg: "Please use `alertmanager_config_flags_extra` instead of `alertmanager_cli_flags`"
when: alertmanager_cli_flags is defined
- block:
- name: Check deprecated variable `alertmanager_listen_address`
when: alertmanager_listen_address is defined
block:
- name: Backward compatibility of variable [part 2]
ansible.builtin.set_fact:
alertmanager_web_listen_address: "{{ alertmanager_listen_address }}"
- name: "DEPRECATION WARNING: `alertmanager_listen_address` is no longer supported and will be dropped from future releases"
ignore_errors: true
failed_when: false
ansible.builtin.fail:
msg: "Please use `alertmanager_web_listen_address` instead of `alertmanager_listen_address`"
when: alertmanager_listen_address is defined
- block:
- name: Check deprecated variable `alertmanager_external_url`
when: alertmanager_external_url is defined
block:
- name: Backward compatibility of variable [part 3]
ansible.builtin.set_fact:
alertmanager_web_external_url: "{{ alertmanager_external_url }}"
- name: "DEPRECATION WARNING: `alertmanager_external_url` is no longer supported and will be dropped from future releases"
ignore_errors: true
failed_when: false
ansible.builtin.fail:
msg: "Please use `alertmanager_web_external_url` instead of `alertmanager_external_url`"
when: alertmanager_external_url is defined
- block:
- name: Check deprecated variable `alertmanager_mesh`
when: alertmanager_mesh is defined
block:
- name: HA config compatibility with alertmanager<0.15.0
ansible.builtin.set_fact:
alertmanager_cluster: "{{ alertmanager_mesh }}"
- name: "DEPRECATION WARNING: `alertmanager_mesh` is no longer supported and will be dropped from future releases"
ignore_errors: true
failed_when: false
ansible.builtin.fail:
msg: "Please use `alertmanager_cluster` instead of `alertmanager_cluster`"
when: alertmanager_mesh is defined
- name: "`alertmanager_child_routes` is no longer supported"
ansible.builtin.fail:

View file

@ -16,18 +16,18 @@ galaxy_info:
- buster
- name: EL
versions:
- 7
- 8
- '7'
- '8'
- name: Fedora
versions:
- 30
- 31
- '30'
- '31'
galaxy_tags:
- exporter
- monitoring
- prometheus
- metrics
- blackbox
- probe
- exporter
- monitoring
- prometheus
- metrics
- blackbox
- probe
dependencies: []

View file

@ -1,5 +1,6 @@
---
- hosts: all
- name: Converge
hosts: all
any_errors_fatal: true
roles:
- blackbox_exporter

View file

@ -16,10 +16,12 @@
- 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"
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"
dest: "/tmp"
remote_src: true
creates: "/tmp/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/blackbox_exporter"
creates: "/tmp/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/
blackbox_exporter"
register: _download_binary
until: _download_binary is succeeded
retries: 5
@ -29,7 +31,8 @@
- 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"
src: "/tmp/blackbox_exporter-{{ blackbox_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}/
blackbox_exporter"
dest: "/usr/local/bin/blackbox_exporter"
mode: 0750
owner: blackbox-exp

View file

@ -16,12 +16,12 @@ galaxy_info:
- buster
- name: EL
versions:
- 7
- 8
- '7'
- '8'
- name: Fedora
versions:
- 30
- 31
- '30'
- '31'
galaxy_tags:
- monitoring
- prometheus

View file

@ -11,11 +11,14 @@
state: directory
owner: root
group: root
mode: 0755
- name: Copy cert and key
ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
with_items:
mode: "{{ item.mode | default(0644) }}"
loop:
- src: "/tmp/tls.cert"
dest: "{{ node_exporter_tls_server_config.cert_file }}"
- src: "/tmp/tls.key"

View file

@ -9,8 +9,10 @@
- name: Download node_exporter binary to local folder
become: false
ansible.builtin.get_url:
url: "https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz"
url: "https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/
node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz"
dest: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz"
mode: 0644
register: _download_binary
until: _download_binary is succeeded
retries: 5

View file

@ -1,5 +1,6 @@
---
- hosts: all
- name: Converge
hosts: all
any_errors_fatal: true
roles:
- node_exporter

View file

@ -8,7 +8,12 @@
mode: 0644
notify: restart node_exporter
- block:
- name: Configure node_exporter
when:
( node_exporter_tls_server_config | length > 0 ) or
( node_exporter_http_server_config | length > 0 ) or
( node_exporter_basic_auth_users | length > 0 )
block:
- name: Create node_exporter config directory
ansible.builtin.file:
path: "/etc/node_exporter"
@ -25,10 +30,6 @@
ansible.builtin.group: root
mode: 0644
notify: restart node_exporter
when:
( node_exporter_tls_server_config | length > 0 ) or
( node_exporter_http_server_config | length > 0 ) or
( node_exporter_basic_auth_users | length > 0 )
- name: Create textfile collector dir
ansible.builtin.file:

View file

@ -17,11 +17,15 @@
home: /
when: _node_exporter_system_user != "root"
- block:
- name: Discover latest version
when: node_exporter_binary_local_dir | length == 0
block:
- name: Download node_exporter binary to local folder
become: false
ansible.builtin.get_url:
url: "https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz"
url: "https://github.com/prometheus/node_exporter/releases/download/v{{ node_exporter_version }}/
node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz"
dest: "/tmp/node_exporter-{{ node_exporter_version }}.linux-{{ go_arch }}.tar.gz"
checksum: "sha256:{{ node_exporter_checksum }}"
mode: '0644'
@ -50,7 +54,6 @@
ansible.builtin.group: root
notify: restart node_exporter
when: not ansible_check_mode
when: node_exporter_binary_local_dir | length == 0
- name: Propagate locally distributed node_exporter binary
ansible.builtin.copy:

View file

@ -13,8 +13,10 @@
become: true
when:
( not __node_exporter_is_installed.stat.exists ) or
( (__node_exporter_current_version_output.stderr_lines | length > 0) and (__node_exporter_current_version_output.stderr_lines[0].split(" ")[2] != node_exporter_version) ) or
( (__node_exporter_current_version_output.stdout_lines | length > 0) and (__node_exporter_current_version_output.stdout_lines[0].split(" ")[2] != node_exporter_version) ) or
( (__node_exporter_current_version_output.stderr_lines | length > 0)
and (__node_exporter_current_version_output.stderr_lines[0].split(" ")[2] != node_exporter_version) ) or
( (__node_exporter_current_version_output.stdout_lines | length > 0)
and (__node_exporter_current_version_output.stdout_lines[0].split(" ")[2] != node_exporter_version) ) or
( node_exporter_binary_local_dir | length > 0 )
tags:
- node_exporter_install

View file

@ -27,7 +27,9 @@
- "item not in node_exporter_enabled_collectors"
with_items: "{{ node_exporter_disabled_collectors }}"
- block:
- name: Assert that TLS config is correct
when: node_exporter_tls_server_config | length > 0
block:
- name: Assert that TLS key and cert path are set
ansible.builtin.assert:
that:
@ -49,7 +51,6 @@
that:
- "{{ __node_exporter_cert_file.stat.exists }}"
- "{{ __node_exporter_key_file.stat.exists }}"
when: node_exporter_tls_server_config | length > 0
- name: Check if node_exporter is installed
ansible.builtin.stat:
@ -71,7 +72,13 @@
- node_exporter_install
- skip_ansible_lint
- block:
- name: Discover latest version
when:
- node_exporter_version == "latest"
- node_exporter_binary_local_dir | length == 0
delegate_to: localhost
run_once: true
block:
- name: Get latest release
ansible.builtin.uri:
url: "https://api.github.com/repos/prometheus/node_exporter/releases/latest"
@ -89,13 +96,11 @@
- name: "Set node_exporter version to {{ _latest_release.json.tag_name[1:] }}"
ansible.builtin.set_fact:
node_exporter_version: "{{ _latest_release.json.tag_name[1:] }}"
when:
- node_exporter_version == "latest"
- node_exporter_binary_local_dir | length == 0
delegate_to: localhost
run_once: true
- block:
- name: Get node_exporter binary checksum
delegate_to: localhost
when: node_exporter_binary_local_dir | length == 0
block:
- name: Get checksum list from github
ansible.builtin.set_fact:
_checksums: "{{ lookup('url', 'https://github.com/prometheus/node_exporter/releases/download/v' + node_exporter_version + '/sha256sums.txt', wantlist=True) | list }}"
@ -107,5 +112,3 @@
with_items: "{{ _checksums }}"
when:
- "('linux-' + go_arch + '.tar.gz') in item"
delegate_to: localhost
when: node_exporter_binary_local_dir | length == 0

View file

@ -90,7 +90,7 @@ prometheus_static_targets_files:
- prometheus/targets/*.yml
- prometheus/targets/*.json
prometheus_alert_rules:
prometheus_alert_rules: # noqa yaml[line-length] # noqa line-length
- alert: Watchdog
expr: vector(1)
for: 10m

View file

@ -16,19 +16,19 @@ galaxy_info:
- buster
- name: EL
versions:
- 7
- 8
- '7'
- '8'
- name: Fedora
versions:
- 30
- 31
- '30'
- '31'
galaxy_tags:
- monitoring
- prometheus
- metrics
- alerts
- alerting
- molecule
- cloud
- monitoring
- prometheus
- metrics
- alerts
- alerting
- molecule
- cloud
dependencies: []

View file

@ -12,6 +12,7 @@
ansible.builtin.get_url:
url: "https://github.com/prometheus/prometheus/releases/download/v{{ version }}/prometheus-{{ version }}.linux-amd64.tar.gz"
dest: "/tmp/prometheus-{{ version }}.linux-amd64.tar.gz"
mode: 0644
register: _download_archive
until: _download_archive is succeeded
retries: 5

View file

@ -43,9 +43,11 @@
- 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"
url: "https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/
prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz"
dest: "/tmp/prometheus-{{ prometheus_version }}.linux-{{ go_arch }}.tar.gz"
checksum: "sha256:{{ __prometheus_checksum }}"
mode: 0644
register: _download_archive
until: _download_archive is succeeded
retries: 5

View file

@ -72,7 +72,13 @@
- prometheus_alertmanager_config == []
- prometheus_alert_rules != []
- block:
- name: Discover latest version
when:
- prometheus_version == "latest"
- prometheus_binary_local_dir | length == 0
- not prometheus_skip_install
block:
- name: Get latest release
ansible.builtin.uri:
url: "https://api.github.com/repos/prometheus/prometheus/releases/latest"
@ -91,12 +97,13 @@
- name: "Set prometheus version to {{ _latest_release.json.tag_name[1:] }}"
ansible.builtin.set_fact:
prometheus_version: "{{ _latest_release.json.tag_name[1:] }}"
- name: Get prometheus binary checksum
delegate_to: localhost
when:
- prometheus_version == "latest"
- prometheus_binary_local_dir | length == 0
- not prometheus_skip_install
- block:
block:
- name: "Get checksum list"
ansible.builtin.set_fact:
__prometheus_checksums: "{{ lookup('url', 'https://github.com/prometheus/prometheus/releases/download/v' + prometheus_version + '/sha256sums.txt', wantlist=True) | list }}"
@ -108,7 +115,3 @@
with_items: "{{ __prometheus_checksums }}"
when:
- "('linux-' + go_arch + '.tar.gz') in item"
delegate_to: localhost
when:
- prometheus_binary_local_dir | length == 0
- not prometheus_skip_install

View file

@ -16,18 +16,18 @@ galaxy_info:
- buster
- name: EL
versions:
- 7
- 8
- '7'
- '8'
- name: Fedora
versions:
- 30
- 31
- '30'
- '31'
galaxy_tags:
- monitoring
- prometheus
- exporter
- system
- network
- metrics
- monitoring
- prometheus
- exporter
- system
- network
- metrics
dependencies: []

View file

@ -1,5 +1,6 @@
---
- hosts: all
- name: Converge
hosts: all
roles:
- snmp_exporter
vars:

View file

@ -1,5 +1,6 @@
---
- hosts: all
- name: Converge
hosts: all
roles:
- snmp_exporter
vars:

View file

@ -2,9 +2,11 @@
- name: Download snmp_exporter binary to local folder
become: false
ansible.builtin.get_url:
url: "https://github.com/prometheus/snmp_exporter/releases/download/v{{ snmp_exporter_version }}/snmp_exporter-{{ snmp_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz"
url: "https://github.com/prometheus/snmp_exporter/releases/download/v{{ snmp_exporter_version }}/
snmp_exporter-{{ snmp_exporter_version }}.linux-{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}.tar.gz"
dest: "/tmp"
checksum: "sha256:{{ snmp_exporter_checksum }}"
mode: 0644
register: _download_binary
until: _download_binary is success
retries: 5