Skip to content

Commit

Permalink
fix: add support for Valkey
Browse files Browse the repository at this point in the history
  • Loading branch information
natoscott committed Aug 21, 2024
1 parent ba78246 commit f77760b
Show file tree
Hide file tree
Showing 78 changed files with 2,556 additions and 196 deletions.
2 changes: 1 addition & 1 deletion .wokeignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
roles/redis/templates/
roles/keyserver/templates/
roles/grafana/templates/
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Github Release](https://img.shields.io/github/release/performancecopilot/ansible-pcp.svg)](https://github.com/performancecopilot/ansible-pcp/releases/latest)

A collection containing roles for Performance Co-Pilot (PCP)
and related software, such as Redis and Grafana.
and related software, such as Valkey/Redis and Grafana.

The collection is arranged as follows:

Expand All @@ -16,22 +16,22 @@ The collection is arranged as follows:
analysis with a large base set of metrics from the kernel and
system services, as well as data recording and rule inference.

- performancecopilot.metrics.redis

A role for configuring a local Redis server, suitable for use
with a Performance Co-Pilot archive repository (for single or
many hosts) and fast, scalable querying of metrics.

- performancecopilot.metrics.grafana

A role for configuring a local Grafana server, providing web
frontend visuals for Performance Co-Pilot metrics, both live
and historically.
Data sources for Vector (live), Redis (historical) as well as
Data sources for Vector (live), Valkey/Redis (historical) and
interactive bpftrace (eBPF) scripts can be configured by this
role. The PCP REST API service (from the core PCP role) must
be configured in order to use this role.

- performancecopilot.metrics.keyserver

A role for configuring a local key server (Valkey/Redis) that
is suitable for use with a Performance Co-Pilot installation
(for single or many hosts) with fast, scalable metric queries.

- performancecopilot.metrics.repository

A role configuring an additional PCP packaging repository -
Expand Down
5 changes: 5 additions & 0 deletions docs/keyserver/setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Example of key server
hosts: all
roles:
- role: performancecopilot.metrics.keyserver
5 changes: 0 additions & 5 deletions docs/redis/setup.yml

This file was deleted.

1 change: 1 addition & 0 deletions galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ tags:
- instrumentation
- observability
- grafana
- valkey
- redis
- pcp
build_ignore:
Expand Down
1 change: 1 addition & 0 deletions roles/grafana/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ galaxy_info:
- pcp
- graph
- redis
- valkey
- vector
- grafana
- metrics
Expand Down
4 changes: 2 additions & 2 deletions roles/grafana/templates/grafana-pcp-datasources.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ datasources:
url: http://{{ __grafana_pmproxy_server }}
editable: true
isDefault: true
- name: PCP Redis
type: pcp-redis-datasource
- name: PCP {{ __grafana_keyserver_datasource_name }}
type: {{ __grafana_keyserver_datasource_type }}
access: proxy
orgId: 1
url: http://{{ __grafana_pmproxy_server }}
Expand Down
2 changes: 1 addition & 1 deletion roles/grafana/templates/grafana_7.ini.j2
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ disable_sanitize_html = false
enable_alpha = false
app_tls_skip_verify_insecure = false
# Enter a comma-separated list of plugin identifiers to identify plugins that are allowed to be loaded even if they lack a valid signature.
allow_loading_unsigned_plugins = performancecopilot-pcp-app,pcp-redis-datasource,pcp-vector-datasource,pcp-bpftrace-datasource,pcp-flamegraph-panel,pcp-breadcrumbs-panel,pcp-troubleshooting-panel,performancecopilot-redis-datasource,performancecopilot-vector-datasource,performancecopilot-bpftrace-datasource,performancecopilot-flamegraph-panel,performancecopilot-breadcrumbs-panel,performancecopilot-troubleshooting-panel
allow_loading_unsigned_plugins = performancecopilot-pcp-app,{{ __grafana_keyserver_datasource_type }},pcp-vector-datasource,pcp-bpftrace-datasource,pcp-flamegraph-panel,pcp-breadcrumbs-panel,pcp-troubleshooting-panel,{{ __grafana_keyserver_datasource_alttype }},performancecopilot-vector-datasource,performancecopilot-bpftrace-datasource,performancecopilot-flamegraph-panel,performancecopilot-breadcrumbs-panel,performancecopilot-troubleshooting-panel
marketplace_url = https://grafana.com/grafana/plugins/

#################################### Grafana Image Renderer Plugin ##########################
Expand Down
2 changes: 1 addition & 1 deletion roles/grafana/templates/grafana_9.ini.j2
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ min_refresh_interval = 1s
;enable_alpha = false
;app_tls_skip_verify_insecure = false
# Enter a comma-separated list of plugin identifiers to identify plugins to load even if they are unsigned. Plugins with modified signatures are never loaded.
allow_loading_unsigned_plugins = performancecopilot-pcp-app,pcp-redis-datasource,pcp-vector-datasource,pcp-bpftrace-datasource,pcp-flamegraph-panel,pcp-breadcrumbs-panel,pcp-troubleshooting-panel,performancecopilot-redis-datasource,performancecopilot-vector-datasource,performancecopilot-bpftrace-datasource,performancecopilot-flamegraph-panel,performancecopilot-breadcrumbs-panel,performancecopilot-troubleshooting-panel
allow_loading_unsigned_plugins = performancecopilot-pcp-app,{{ __grafana_keyserver_datasource_type }},pcp-vector-datasource,pcp-bpftrace-datasource,pcp-flamegraph-panel,pcp-breadcrumbs-panel,pcp-troubleshooting-panel,{{ performancecopilot-valkey-datasource }},performancecopilot-vector-datasource,performancecopilot-bpftrace-datasource,performancecopilot-flamegraph-panel,performancecopilot-breadcrumbs-panel,performancecopilot-troubleshooting-panel
# Enable or disable installing / uninstalling / updating plugins directly from within Grafana.
;plugin_admin_enabled = false
;plugin_admin_external_manage_enabled = false
Expand Down
3 changes: 3 additions & 0 deletions roles/grafana/vars/CentOS_10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
---
# Put internal variables here with CentOS 10 specific values.

__grafana_keyserver_datasource_name: Valkey
__grafana_keyserver_datasource_type: pcp-valkey-datasource
__grafana_keyserver_datasource_alttype: performancecopilot-valkey-datasource
__grafana_packages_extra:
- grafana-pcp
3 changes: 3 additions & 0 deletions roles/grafana/vars/CentOS_6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
---
# Put internal variables here with CentOS 6 specific values.

__grafana_keyserver_datasource_name: Redis
__grafana_keyserver_datasource_type: pcp-redis-datasource
__grafana_keyserver_datasource_alttype: performancecopilot-redis-datasource
__grafana_packages_extra: []
3 changes: 3 additions & 0 deletions roles/grafana/vars/CentOS_7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
---
# Put internal variables here with CentOS 7 specific values.

__grafana_keyserver_datasource_name: Redis
__grafana_keyserver_datasource_type: pcp-redis-datasource
__grafana_keyserver_datasource_alttype: performancecopilot-redis-datasource
__grafana_packages_extra: []
3 changes: 3 additions & 0 deletions roles/grafana/vars/CentOS_8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
---
# Put internal variables here with CentOS 8 specific values.

__grafana_keyserver_datasource_name: Redis
__grafana_keyserver_datasource_type: pcp-redis-datasource
__grafana_keyserver_datasource_alttype: performancecopilot-redis-datasource
__grafana_packages_extra: []
3 changes: 3 additions & 0 deletions roles/grafana/vars/CentOS_9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
---
# Put internal variables here with CentOS 9 specific values.

__grafana_keyserver_datasource_name: Redis
__grafana_keyserver_datasource_type: pcp-redis-datasource
__grafana_keyserver_datasource_alttype: performancecopilot-redis-datasource
__grafana_packages_extra:
- grafana-pcp
3 changes: 3 additions & 0 deletions roles/grafana/vars/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
---
# Put internal variables here with Debian specific values.

__grafana_keyserver_datasource_name: Valkey
__grafana_keyserver_datasource_type: pcp-valkey-datasource
__grafana_keyserver_datasource_alttype: performancecopilot-valkey-datasource
__grafana_packages: []
__grafana_packages_extra: []
3 changes: 3 additions & 0 deletions roles/grafana/vars/Fedora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
---
# Put internal variables here with Fedora specific values.

__grafana_keyserver_datasource_name: Valkey
__grafana_keyserver_datasource_type: pcp-valkey-datasource
__grafana_keyserver_datasource_alttype: performancecopilot-valkey-datasource
__grafana_packages_extra:
- grafana-pcp
3 changes: 3 additions & 0 deletions roles/grafana/vars/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
---
# Put internal variables here with Red Hat specific values.

__grafana_keyserver_datasource_name: Valkey
__grafana_keyserver_datasource_type: pcp-valkey-datasource
__grafana_keyserver_datasource_alttype: performancecopilot-valkey-datasource
__grafana_packages:
- grafana
3 changes: 3 additions & 0 deletions roles/grafana/vars/RedHat_10.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
---
# Put internal variables here with Red Hat Enterprise Linux 10 specific values.

__grafana_keyserver_datasource_name: Valkey
__grafana_keyserver_datasource_type: pcp-valkey-datasource
__grafana_keyserver_datasource_alttype: performancecopilot-valkey-datasource
__grafana_packages_extra:
- grafana-pcp
3 changes: 3 additions & 0 deletions roles/grafana/vars/RedHat_6.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
---
# Put internal variables here with Red Hat Enterprise Linux 6 specific values.

__grafana_keyserver_datasource_name: Redis
__grafana_keyserver_datasource_type: pcp-redis-datasource
__grafana_keyserver_datasource_alttype: performancecopilot-redis-datasource
__grafana_packages_extra: []
3 changes: 3 additions & 0 deletions roles/grafana/vars/RedHat_7.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
---
# Put internal variables here with Red Hat Enterprise Linux 7 specific values.

__grafana_keyserver_datasource_name: Redis
__grafana_keyserver_datasource_type: pcp-redis-datasource
__grafana_keyserver_datasource_alttype: performancecopilot-redis-datasource
__grafana_packages_extra: []
3 changes: 3 additions & 0 deletions roles/grafana/vars/RedHat_8.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
---
# Put internal variables here with Red Hat Enterprise Linux 8 specific values.

__grafana_keyserver_datasource_name: Redis
__grafana_keyserver_datasource_type: pcp-redis-datasource
__grafana_keyserver_datasource_alttype: performancecopilot-redis-datasource
__grafana_packages_extra:
- grafana-pcp
3 changes: 3 additions & 0 deletions roles/grafana/vars/RedHat_9.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
---
# Put internal variables here with Red Hat Enterprise Linux 9 specific values.

__grafana_keyserver_datasource_name: Redis
__grafana_keyserver_datasource_type: pcp-redis-datasource
__grafana_keyserver_datasource_alttype: performancecopilot-redis-datasource
__grafana_packages_extra:
- grafana-pcp
39 changes: 39 additions & 0 deletions roles/keyserver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# performancecopilot.metrics.keyserver

Installs and configures either [Valkey](https://valkey.io) or [Redis](https://redis.io) for use with the [Performance Co-Pilot](https://pcp.io/) toolkit.

## Requirements

Requires a modern version of either Valkey or Redis (preferencing the open source Valkey on latest Linux distributions). If the target platform provides it, the ValkeySearch (or RediSearch) module will also be installed.

## Role Variables

keyserver_save_to_disk: true

Incrementally save the database to disk. Default: true.

## Dependencies

None.

## Example Playbook

Central PCP setup for monitoring of several remote hosts with fast, scalable querying enabled.

```yaml
- hosts: monitoring
roles:
- role: performancecopilot.metrics.keyserver
- role: performancecopilot.metrics.pcp
vars:
pcp_target_hosts: [slip, slop, slap]
pcp_rest_api: true
```
## License
MIT
## Author Information
An official role for PCP, maintained by the PCP developers <[email protected]>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# SPDX-License-Identifier: MIT
---
redis_save_to_disk: true
keyserver_save_to_disk: true
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: MIT
---

- name: Restart redis
- name: Restart key server
service:
name: redis
name: "{{ __keyserver_name }}"
state: restarted
5 changes: 3 additions & 2 deletions roles/redis/meta/main.yml → roles/keyserver/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ dependencies: []

galaxy_info:
author: performancecopilot
description: Performance Co-Pilot Redis role
role_name: redis
description: Performance Co-Pilot key server role
role_name: keyserver
company: pcp.io
license: "license (MIT)"
min_ansible_version: "2.9"
Expand All @@ -27,6 +27,7 @@ galaxy_info:
galaxy_tags:
- pcp
- redis
- valkey
- metrics
- analysis
- monitoring
Expand Down
34 changes: 17 additions & 17 deletions roles/redis/tasks/main.yml → roles/keyserver/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,45 +28,45 @@
set_fact:
__ansible_pcp_is_ostree: "{{ __ostree_booted_stat.stat.exists }}"

- name: Install Redis packages
- name: Install key server packages
package:
name: "{{ __redis_packages + __redis_packages_extra }}"
name: "{{ __keyserver_packages + __keyserver_packages_extra }}"
state: present
use: "{{ (__ansible_pcp_is_ostree | d(false)) |
ternary('ansible.posix.rhel_rpm_ostree', omit) }}"

- name: Ensure Redis configuration directory exists
- name: Ensure key server configuration directory exists
file:
path: "{{ __redis_conf_path }}"
path: "{{ __keyserver_conf_path }}"
state: directory
owner: redis
owner: "{{ __keyserver_name }}"
group: root
mode: "0750"

# yamllint disable rule:line-length
- name: Ensure Redis service is configured
- name: Ensure key server is configured
template:
src: "{{ item }}"
dest: "{{ __redis_conf_path }}/{{ __redis_conf_file }}"
dest: "{{ __keyserver_conf_path }}/{{ __keyserver_conf_file }}"
mode: "0640"
owner: redis
owner: "{{ __keyserver_name }}"
group: root
with_first_found:
- "{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}_redis.conf.j2"
- "{{ ansible_facts['distribution'] }}_redis.conf.j2"
- "redis.conf.j2"
notify: Restart redis
- "{{ ansible_facts['distribution'] }}_{{ ansible_facts['distribution_major_version'] }}_keyserver.conf.j2"
- "{{ ansible_facts['distribution'] }}_keyserver.conf.j2"
- "keyserver.conf.j2"
notify: Restart key server
# yamllint enable rule:line-length

- name: Ensure Redis configuration symlink exists
- name: Ensure key server configuration symlink exists
file:
src: "{{ __redis_conf_path }}/{{ __redis_conf_file }}"
dest: "{{ __redis_conf_link }}/{{ __redis_conf_file }}"
src: "{{ __keyserver_conf_path }}/{{ __keyserver_conf_file }}"
dest: "{{ __keyserver_conf_link }}/{{ __keyserver_conf_file }}"
state: link
force: true

- name: Ensure Redis service is running and enabled on boot
- name: Ensure key server service is running and enabled on boot
service:
name: redis
name: "{{ __keyserver_name }}"
state: started
enabled: true
1 change: 1 addition & 0 deletions roles/keyserver/templates/CentOS_10_keyserver.conf.j2
1 change: 1 addition & 0 deletions roles/keyserver/templates/RedHat_10_keyserver.conf.j2
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#
# loadmodule /path/to/my_module.so
# loadmodule /path/to/other_module.so
{% for module in __redis_loaded_modules %}
{% for module in __keyserver_loaded_modules %}
loadmodule {{ module }}
{% endfor %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#
# loadmodule /path/to/my_module.so
# loadmodule /path/to/other_module.so
{% for module in __redis_loaded_modules %}
{% for module in __keyserver_loaded_modules %}
loadmodule {{ module }}
{% endfor %}

Expand Down
1 change: 1 addition & 0 deletions roles/keyserver/templates/valkey.conf.j2
Loading

0 comments on commit f77760b

Please sign in to comment.