This guide provides an Ansible playbook to install Diamond from PyPI for Debian 10+, Ubuntu LTS, and RHEL 9+ compatible systems.
Diamond is not available in standard distribution repositories. This playbook installs Diamond via pip.
- name: Install Diamond
hosts: diamond
become: true
vars:
diamond_graphite_host: "graphite"
diamond_graphite_port: 2003
tasks:
- name: Install Python and pip (Debian/Ubuntu)
apt:
name:
- python3
- python3-pip
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Install Python and pip (RHEL)
dnf:
name:
- python3
- python3-pip
state: present
when: ansible_os_family == "RedHat"
- name: Install Diamond from PyPI
pip:
name: diamond
state: present
executable: pip3
- name: Create Diamond configuration directory
file:
path: /etc/diamond
state: directory
mode: "0755"
- name: Configure Diamond
copy:
dest: /etc/diamond/diamond.conf
content: |
[server]
handlers = GraphiteHandler
handlers_config_graphite = host={{ diamond_graphite_host }} port={{ diamond_graphite_port }}
[collectors]
[[default]]
enabled = True
cpu = True
memory = True
network = True
disk = True
mode: "0644"
notify: restart diamond
- name: Create systemd service for Diamond
copy:
dest: /etc/systemd/system/diamond.service
content: |
[Unit]
Description=Diamond system metrics collector
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/diamond --configfile=/etc/diamond/diamond.conf
Restart=on-failure
User=root
[Install]
WantedBy=multi-user.target
mode: "0644"
notify:
- reload systemd
- restart diamond
handlers:
- name: reload systemd
systemd:
daemon_reload: true
- name: restart diamond
service:
name: diamond
state: restarted
/etc/diamond/diamond.conf2003/tcp (plaintext)Any questions?
Feel free to contact us. Find all contact information on our contact page.