Skip to content

Commit

Permalink
add ondemand_exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdjscott committed Jun 17, 2024
1 parent 61957c1 commit 5ea828a
Show file tree
Hide file tree
Showing 6 changed files with 135 additions and 0 deletions.
2 changes: 2 additions & 0 deletions roles/openondemand-webnode-config/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
apache_server_limit: 8
apache_threads_per_child: 32
ondemand_exporter_version: 0.10.0
ondemand_exporter_checksum: e56b0c14e2829141f94f44f35ca8577e7623305d83d7c082fb66bba945e0f321
18 changes: 18 additions & 0 deletions roles/openondemand-webnode-config/files/ondemand_exporter.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[Unit]
Description=OnDemand Prometheus Exporter
Wants=basic.target
After=basic.target network.target

[Service]
User=ondemand_exporter
Group=ondemand_exporter
SyslogIdentifier=ondemand_exporter
Environment="LISTEN_ADDRESS=:9301"
Environment="APACHE_STATUS_URL=http://localhost:81/server-status"
ExecStart=/usr/local/bin/ondemand_exporter
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always

[Install]
WantedBy=multi-user.target
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ExtendedStatus On

Listen 81
<VirtualHost *:81>
ServerName localhost

<Location /server-status>
SetHandler server-status
Require ip 127.0.0.1 ::1
</Location>

<Location "/">
<RequireAny>
Require ip 127.0.0.1 ::1
</RequireAny>
</Location>

## Logging
ErrorLog logs/ondemand_exporter_error.log
ServerSignature Off
CustomLog logs/ondemand_exporter_access.log combined
</VirtualHost>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Defaults:ondemand_exporter !syslog
Defaults:ondemand_exporter !requiretty
ondemand_exporter ALL=(ALL) NOPASSWD:/opt/ood/nginx_stage/sbin/nginx_stage nginx_list
ondemand_exporter ALL=(ALL) NOPASSWD:/usr/sbin/ondemand-passenger-status
9 changes: 9 additions & 0 deletions roles/openondemand-webnode-config/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
- name: Restart httpd
systemd:
name: apache2
state: restarted

- name: Reload systemd
systemd:
daemon_reload: true
80 changes: 80 additions & 0 deletions roles/openondemand-webnode-config/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,83 @@
owner: root
group: root
mode: '0755'

- name: Create ondemand_exporter group
ansible.builtin.group:
name: ondemand_exporter
state: present
system: true

- name: Create ondemand_exporter user
ansible.builtin.user:
name: ondemand_exporter
group: ondemand_exporter
shell: /sbin/nologin
home: /var/lib/ondemand_exporter
system: true
create_home: false

- name: Download ondemand_exporter binary
ansible.builtin.get_url:
url: "https://github.com/OSC/ondemand_exporter/releases/download/v{{ ondemand_exporter_version }}/ondemand_exporter-{{ ondemand_exporter_version }}.linux-amd64.tar.gz"
dest: "/tmp/ondemand_exporter-{{ ondemand_exporter_version }}.tar.gz"
checksum: "{{ ondemand_exporter_checksum }}"

- name: Extract ondemand_exporter binary
ansible.builtin.unarchive:
src: "/tmp/ondemand_exporter-{{ ondemand_exporter_version }}.tar.gz"
dest: /tmp
extra_opts:
- --strip-components
- 1
remote_src: true
creates: /tmp/ondemand_exporter

- name: Install ondemand_exporter binary
ansible.builtin.copy:
src: /tmp/ondemand_exporter
dest: /usr/local/bin/ondemand_exporter
remote_src: true
owner: root
group: root
mode: 0755

- name: Install ondemand_exporter sudo rule
ansible.builtin.copy:
src: ondemand_exporter_sudo
dest: /etc/sudoers.d/ondemand_exporter
mode: 0440

- name: Install Apache config for ondemand_exporter
ansible.builtin.copy:
src: ondemand_exporter_apache.conf
dest: /etc/apache2/mods-available/status.conf
notify: Restart httpd

- name: Enable apache mod_status module
ansible.builtin.command:
cmd: a2enmod status.load
creates: /etc/apache2/mods-enabled/status.load
notify: Restart httpd

- name: Enable apache ondemand_exporter conf
ansible.builtin.command:
cmd: a2enmod status.conf
creates: /etc/apache2/mods-enabled/status.conf
notify: Restart httpd

- name: Install ondemand_exporter systemd unit file
ansible.builtin.copy:
src: ondemand_exporter.service
dest: /etc/systemd/system/ondemand_exporter.service
notify:
- Reload systemd

- name: Flush handlers
meta: flush_handlers

- name: Start ondemand_exporter service
ansible.builtin.systemd:
name: ondemand_exporter
state: started
enabled: true

0 comments on commit 5ea828a

Please sign in to comment.