From d10d8641c840b0fb2e26ac725f38cddd785eca37 Mon Sep 17 00:00:00 2001 From: sakethanne Date: Thu, 3 Oct 2024 14:15:44 -0700 Subject: [PATCH] fix(telegraf): merged the telegraf deployment code for all hosts Signed-off-by: sakethanne --- ansible/monitoring.yml | 75 ++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 51 deletions(-) diff --git a/ansible/monitoring.yml b/ansible/monitoring.yml index ae8c2d6..0e1fb33 100644 --- a/ansible/monitoring.yml +++ b/ansible/monitoring.yml @@ -21,8 +21,6 @@ # TODO: create new telegraf container or use same for Marvell card - # TODO: see if there is an opportunity to consolidate and code dup removal - - name: Nvidia | telegraf otel monitoring when: inventory_hostname == 'bf2' block: @@ -41,54 +39,33 @@ state: started name: spdk_tgt - - name: Nvidia | Run telegraf container on Nvidia BF - community.docker.docker_container: - name: telegraf - image: docker.io/library/telegraf:1.31 - state: started - restart: true - detach: true - network_mode: host - restart_policy: always - mounts: - - type: bind - source: /root/telegraf.d/telegraf.conf.bf2 - target: /etc/telegraf/telegraf.conf - read_only: true - - type: bind - source: /run/emu_param - target: /run/emu_param - read_only: true - - # TODO: see if there is an opportunity to consolidate and code dup removal - - name: Intel | telegraf otel monitoring when: inventory_hostname == 'mev' environment: "{{ proxy_env | default({}) }}" block: - name: Intel | Downgrade requests package due to bug https://github.com/ansible-collections/community.docker/issues/868 ansible.builtin.pip: - name: requests<2.32 + name: requests + version: "<2.32" - - name: Intel | Run telegraf container on Intel MEV - community.docker.docker_container: - name: telegraf - image: docker.io/library/telegraf:1.31 - state: started - restart: true - detach: true - network_mode: host - restart_policy: always - mounts: - - type: bind - source: /root/telegraf.d/telegraf.conf.mev - target: /etc/telegraf/telegraf.conf - read_only: true + - name: Initialize telegraf mounts for all hosts + ansible.builtin.set_fact: + telegraf_mounts: + - type: bind + source: "{{ '/root/telegraf.d/telegraf.conf.' + inventory_hostname if inventory_hostname in ['bf2', 'mev'] else '/root/telegraf.d' }}" + target: "{{ '/etc/telegraf/telegraf.conf' if inventory_hostname in ['bf2', 'mev'] else '/etc/telegraf/telegraf.d' }}" + read_only: true + + - name: Add additional mount for bf2 + when: inventory_hostname == 'bf2' + ansible.builtin.set_fact: + telegraf_mounts: "{{ telegraf_mounts + [{'type': 'bind', 'source': '/run/emu_param', 'target': '/run/emu_param', 'read_only': true}] }}" - - name: Run telegraf container on others - when: - - inventory_hostname != 'mev' - - inventory_hostname != 'bf2' + - name: Print the list of mounts for each host + ansible.builtin.debug: + var: telegraf_mounts + + - name: Run telegraf container on all hosts community.docker.docker_container: name: telegraf image: docker.io/library/telegraf:1.31 @@ -97,13 +74,9 @@ detach: true network_mode: host restart_policy: always - mounts: - - type: bind - source: /root/telegraf.d - target: /etc/telegraf/telegraf.d - read_only: true + mounts: "{{ telegraf_mounts }}" env: - REDFISH_HOST: "{{ bmc_vars.ansible_host }}" - REDFISH_USER: "{{ bmc_vars.ansible_user }}" - REDFISH_PASSWORD: "{{ bmc_vars.ansible_password }}" - REDFISH_SYSTEM_ID: "{{ bmc_vars.resource_id }}" + REDFISH_HOST: "{{ bmc_vars.ansible_host | default(omit) }}" + REDFISH_USER: "{{ bmc_vars.ansible_user | default(omit) }}" + REDFISH_PASSWORD: "{{ bmc_vars.ansible_password | default(omit) }}" + REDFISH_SYSTEM_ID: "{{ bmc_vars.resource_id | default(omit) }}"