From 507517bec0b6bc89d531190cc3a2e7b03b0cf141 Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Thu, 24 Oct 2024 13:59:14 -0400 Subject: [PATCH] ansible: Reduce verbosity of prometheus-node-exporter logs Change-Id: Ife6e81686e0235ac7fa291f4a6d9c843d0d13823 Signed-off-by: Kienan Stewart --- automation/ansible/README.md | 1 + ...ci-host-amd64-1a.internal.efficios.com.yml | 2 ++ .../ansible/roles/common/defaults/main.yml | 1 + .../ansible/roles/common/tasks/main.yml | 14 ++++++++++++ .../roles/common/tasks/setup-Debian.yml | 22 +++++++++++++++---- 5 files changed, 36 insertions(+), 4 deletions(-) diff --git a/automation/ansible/README.md b/automation/ansible/README.md index faf76d5..1204bac 100644 --- a/automation/ansible/README.md +++ b/automation/ansible/README.md @@ -33,6 +33,7 @@ ansible-playbook -i hosts [-l SUBSET] site.yaml ## Tags * access: Any user / ssh access tasks +* monitoring: Any tasks related to installing or configuring monitoring services * slow: Any tasks that may take a long time ### Example: Skip slow tasks diff --git a/automation/ansible/host_vars/ci-host-amd64-1a.internal.efficios.com.yml b/automation/ansible/host_vars/ci-host-amd64-1a.internal.efficios.com.yml index 3f2c675..eebb724 100644 --- a/automation/ansible/host_vars/ci-host-amd64-1a.internal.efficios.com.yml +++ b/automation/ansible/host_vars/ci-host-amd64-1a.internal.efficios.com.yml @@ -1,4 +1,6 @@ --- +common_prometheus_node_exporter_args: "--log.level=error --no-collector.nfsd" + lxd_cluster_ip: 172.18.0.190 lxd_cluster: server_name: ci-host-amd64-1a diff --git a/automation/ansible/roles/common/defaults/main.yml b/automation/ansible/roles/common/defaults/main.yml index 321fbfc..ec35d2b 100644 --- a/automation/ansible/roles/common/defaults/main.yml +++ b/automation/ansible/roles/common/defaults/main.yml @@ -4,5 +4,6 @@ common_certificate_cert_path_prefix: '/etc/ssl/certs' common_certificate_key_path_prefix: '/etc/ssl/private' common_certificate_deploy_combined_pem: true +common_prometheus_node_exporter_args: "--log.level=error" common_install_promtail: false common_promtail_client: 'http://graph01:3500/loki/api/v1/push' diff --git a/automation/ansible/roles/common/tasks/main.yml b/automation/ansible/roles/common/tasks/main.yml index c77b473..ff3ed65 100644 --- a/automation/ansible/roles/common/tasks/main.yml +++ b/automation/ansible/roles/common/tasks/main.yml @@ -12,27 +12,41 @@ # Setup/install tasks. - ansible.builtin.include_tasks: setup-RedHat.yml + tags: + - always when: ansible_os_family in ['RedHat', 'Rocky'] - ansible.builtin.include_tasks: setup-Debian.yml + tags: + - always when: ansible_os_family == 'Debian' - ansible.builtin.include_tasks: setup-Alpine.yml + tags: + - always when: ansible_os_family == 'Alpine' - ansible.builtin.include_tasks: setup-Suse.yml + tags: + - always when: ansible_os_family == 'Suse' - ansible.builtin.include_tasks: setup-Windows.yml + tags: + - always when: ansible_os_family == 'Windows' # Setup user accounts - ansible.builtin.include_tasks: users.yml + tags: + - always tags: - access when: ansible_os_family != 'Windows' - ansible.builtin.include_tasks: users-Windows.yml + tags: + - always tags: - access when: ansible_os_family == 'Windows' diff --git a/automation/ansible/roles/common/tasks/setup-Debian.yml b/automation/ansible/roles/common/tasks/setup-Debian.yml index 70ab6e5..e2c4bb2 100644 --- a/automation/ansible/roles/common/tasks/setup-Debian.yml +++ b/automation/ansible/roles/common/tasks/setup-Debian.yml @@ -81,10 +81,22 @@ mode: '0644' - name: Install prometheus node exporter for physical hosts when: "'hosts' in group_names" - ansible.builtin.apt: - name: - - prometheus-node-exporter - - prometheus-node-exporter-collectors + tags: + - monitoring + block: + - ansible.builtin.apt: + name: + - prometheus-node-exporter + - prometheus-node-exporter-collectors + - ansible.builtin.lineinfile: + line: "ARGS={{common_prometheus_node_exporter_args|quote}}" + path: /etc/default/prometheus-node-exporter + register: node_exporter_config + - when: node_exporter_config.changed + ansible.builtin.service: + name: prometheus-node-exporter + state: restarted + enabled: true - name: Work-around for git hanging during checkouts # @see https://support.efficios.com/issues/1532 @@ -97,6 +109,8 @@ value: 'HTTP/1.1' - when: common_install_promtail + tags: + - monitoring block: - name: Add apt source block: -- 2.34.1