This guide installs Clusto into a Python virtual environment and exposes it with Gunicorn.
It supports Debian 10 to latest stable, Ubuntu LTS, and RHEL 9+ compatible systems.
- name: Install Clusto with Gunicorn
hosts: clusto
become: true
vars:
clusto_user: clusto
clusto_group: clusto
clusto_home: /opt/clusto
venv_dir: /opt/clusto-venv
clusto_bind: 127.0.0.1:8085
tasks:
- name: Install dependencies on Debian/Ubuntu
apt:
name:
- python3
- python3-venv
- python3-pip
- git
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Install dependencies on RHEL family
dnf:
name:
- python3
- python3-pip
- python3-virtualenv
- git
state: present
when: ansible_os_family == "RedHat"
- name: Create service group
group:
name: "{{ clusto_group }}"
state: present
- name: Create service user
user:
name: "{{ clusto_user }}"
group: "{{ clusto_group }}"
home: "{{ clusto_home }}"
shell: /usr/sbin/nologin
create_home: true
- name: Create virtual environment
command: python3 -m venv {{ venv_dir }}
args:
creates: "{{ venv_dir }}"
- name: Install Clusto and Gunicorn
pip:
name:
- clusto
- gunicorn
virtualenv: "{{ venv_dir }}"
- name: Create systemd service for Clusto
copy:
dest: /etc/systemd/system/clusto.service
mode: "0644"
content: |
[Unit]
Description=Clusto (Gunicorn)
After=network.target
[Service]
User={{ clusto_user }}
Group={{ clusto_group }}
WorkingDirectory={{ clusto_home }}
Environment=PATH={{ venv_dir }}/bin
ExecStart={{ venv_dir }}/bin/gunicorn --bind {{ clusto_bind }} clustoapi:app
Restart=on-failure
[Install]
WantedBy=multi-user.target
- name: Reload systemd
systemd:
daemon_reload: true
- name: Enable and start Clusto
service:
name: clusto
state: started
enabled: true
pip.Beyond this playbook, we offer:
Contact our automation team: office@linux-server-admin.com