Skip to content

Commit

Permalink
fix(telegraf): merged the telegraf deployment code for all hosts
Browse files Browse the repository at this point in the history
Signed-off-by: sakethanne <[email protected]>
  • Loading branch information
Sakethanne committed Oct 3, 2024
1 parent 51e1c57 commit d10d864
Showing 1 changed file with 24 additions and 51 deletions.
75 changes: 24 additions & 51 deletions ansible/monitoring.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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) }}"

0 comments on commit d10d864

Please sign in to comment.