This guide installs PostHog self-hosted with Docker Compose and the official PostHog deployment script.
It includes package handling for Debian 10 to latest stable, Ubuntu LTS, and RHEL 9+ compatible systems.
- name: Install PostHog self-hosted
hosts: posthog
become: true
vars:
posthog_install_dir: /opt/posthog
tasks:
- name: Install dependencies on Debian/Ubuntu
apt:
name:
- docker.io
- docker-compose-plugin
- curl
- git
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Install dependencies on RHEL family
dnf:
name:
- docker
- git
- curl
state: present
when: ansible_os_family == "RedHat"
- name: Enable and start Docker
service:
name: docker
state: started
enabled: true
- name: Create PostHog install directory
file:
path: "{{ posthog_install_dir }}"
state: directory
mode: "0755"
- name: Run official PostHog hobby deployment installer
shell: |
set -euo pipefail
cd "{{ posthog_install_dir }}"
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/posthog/posthog/HEAD/bin/deploy-hobby)"
args:
creates: "{{ posthog_install_dir }}/docker-compose.yml"
We develop tailored automation solutions for:
Let’s discuss your requirements: office@linux-server-admin.com | Contact