This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
tsg-tsg-os-buildimage/ansible/roles/exporter/tasks/main.yml

140 lines
4.1 KiB
YAML

- name: "Get freeipmi rpm path"
find:
path: /tmp/rpm_download/
pattern: "freeipmi-*"
register: freeipmi_rpm_fullname
- name: "Install freeipmi from local path"
yum:
name: "{{ freeipmi_rpm_fullname.files[0].path }}"
state: present
- name: "mkdir /opt/tsg/exporter/"
file:
path: /opt/tsg/exporter/
state: directory
- name: "copy node_exporter"
copy:
src: '{{ role_path }}/files/node_exporter'
dest: /opt/tsg/exporter/node_exporter
mode: 0755
- name: "copy systemd_exporter"
copy:
src: '{{ role_path }}/files/systemd_exporter'
dest: /opt/tsg/exporter/systemd_exporter
mode: 0755
- name: "copy redis_exporter"
copy:
src: '{{ role_path }}/files/redis_exporter'
dest: /opt/tsg/exporter/redis_exporter
mode: 0755
when: monitor.enable_redis_exporter == 1
- name: "copy ipmi_exporter"
copy:
src: '{{ role_path }}/files/ipmi_exporter'
dest: /opt/tsg/exporter/ipmi_exporter
mode: 0755
when: monitor.enable_ipmi_exporter == 1
- name: "templates atca-exporter-node.service"
template:
src: "{{role_path}}/templates/exporter-node.service.j2"
dest: /usr/lib/systemd/system/exporter-node.service
tags: template
- name: "templates atca-exporter-systemd.service"
template:
src: "{{role_path}}/templates/exporter-systemd.service.j2"
dest: /usr/lib/systemd/system/exporter-systemd.service
tags: template
- name: "templates atca-exporter-ipmi.service"
template:
src: "{{role_path}}/templates/exporter-ipmi.service.j2"
dest: /usr/lib/systemd/system/exporter-ipmi.service
tags: template
when: monitor.enable_ipmi_exporter == 1
- name: "Create /usr/lib/systemd/system/exporter-node.service.d directory if it does not exist"
file:
path: "{{ item }}"
state: directory
mode: '0755'
with_items:
- /usr/lib/systemd/system/exporter-node.service.d
- name: "Create /usr/lib/systemd/system/exporter-systemd.service.d directory if it does not exist"
file:
path: "{{ item }}"
state: directory
mode: '0755'
with_items:
- /usr/lib/systemd/system/exporter-systemd.service.d
- name: "Create /usr/lib/systemd/system/exporter-ipmi.service.d directory if it does not exist"
file:
path: "{{ item }}"
state: directory
mode: '0755'
with_items:
- /usr/lib/systemd/system/exporter-ipmi.service.d
when: monitor.enable_ipmi_exporter == 1
- name: "copy slice file to exporter-node.service.d"
copy:
src: "{{ role_path }}/templates/service_override_slice.conf.j2"
dest: /usr/lib/systemd/system/exporter-node.service.d/service_override_slice.conf
mode: 0644
- name: "copy slice file to exporter-systemd.service.d"
copy:
src: "{{ role_path }}/templates/service_override_slice.conf.j2"
dest: /usr/lib/systemd/system/exporter-systemd.service.d/service_override_slice.conf
mode: 0644
- name: "copy slice file to exporter-ipmi.service.d"
copy:
src: "{{ role_path }}/templates/service_override_slice.conf.j2"
dest: /usr/lib/systemd/system/exporter-ipmi.service.d/service_override_slice.conf
mode: 0644
when: monitor.enable_ipmi_exporter == 1
- name: "replace action: replace service WantedBy from multi-user.target to workload.target"
replace:
path: "{{ item }}"
regexp: 'WantedBy=multi-user.target'
replace: 'WantedBy=workload.target'
with_items:
- /usr/lib/systemd/system/exporter-node.service
- /usr/lib/systemd/system/exporter-systemd.service
- name: "replace action: replace service WantedBy from multi-user.target to workload.target"
replace:
path: "{{ item }}"
regexp: 'WantedBy=multi-user.target'
replace: 'WantedBy=workload.target'
with_items:
- /usr/lib/systemd/system/exporter-ipmi.service
when: monitor.enable_ipmi_exporter == 1
##################### exporter #####################
- name: 'exporter-node service start'
systemd:
name: exporter-node
enabled: yes
- name: 'exporter-systemd service start'
systemd:
name: exporter-systemd
enabled: yes
- name: 'exporter-ipmi service start'
systemd:
name: exporter-ipmi
enabled: yes
when: monitor.enable_ipmi_exporter == 1