This guide provides an Ansible playbook to install tcollector from source for Debian 10+, Ubuntu LTS, and RHEL 9+ compatible systems.
tcollector is not available in standard distribution repositories. This playbook installs tcollector from the GitHub repository.
- name: Install tcollector
hosts: tcollector
become: true
vars:
opentsdb_host: "opentsdb"
opentsdb_port: 4242
tcollector_install_dir: /opt/tcollector
tasks:
- name: Install required packages (Debian/Ubuntu)
apt:
name:
- python3
- python3-pip
- git
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Install required packages (RHEL)
dnf:
name:
- python3
- python3-pip
- git
state: present
when: ansible_os_family == "RedHat"
- name: Clone tcollector repository
git:
repo: https://github.com/OpenTSDB/tcollector.git
dest: "{{ tcollector_install_dir }}"
version: master
- name: Create tcollector configuration
copy:
dest: "{{ tcollector_install_dir }}/etc/tcollector.conf"
content: |
[default]
opentsdb_host = {{ opentsdb_host }}
opentsdb_port = {{ opentsdb_port }}
collectors = /opt/tcollector/collectors
mode: "0644"
notify: restart tcollector
- name: Create systemd service for tcollector
copy:
dest: /etc/systemd/system/tcollector.service
content: |
[Unit]
Description=tcollector metric collector
After=network.target
[Service]
Type=simple
ExecStart={{ tcollector_install_dir }}/startstop foreground
WorkingDirectory={{ tcollector_install_dir }}
Restart=on-failure
User=root
Environment=OPENTSDB_HOST={{ opentsdb_host }}
Environment=OPENTSDB_PORT={{ opentsdb_port }}
[Install]
WantedBy=multi-user.target
mode: "0644"
notify:
- reload systemd
- restart tcollector
handlers:
- name: reload systemd
systemd:
daemon_reload: true
- name: restart tcollector
service:
name: tcollector
state: restarted
/opt/tcollector/etc/tcollector.conf4242/tcpAny questions?
Feel free to contact us. Find all contact information on our contact page.