This guide deploys Errbot using Docker containers managed by Ansible. It combines container isolation with automated deployment.
- name: Deploy Errbot with Docker
hosts: errbot
become: true
vars:
errbot_name: errbot
errbot_image: local/errbot:6.2.0
errbot_config_dir: /opt/errbot
errbot_container_name: errbot
errbot_version: "6.2.0"
tasks:
- name: Install prerequisites on Debian family
ansible.builtin.apt:
update_cache: true
name:
- apt-transport-https
- ca-certificates
- curl
- gnupg
- lsb-release
state: present
when: ansible_os_family == "Debian"
- name: Install prerequisites on RHEL family
ansible.builtin.dnf:
name:
- dnf-utils
state: present
when: ansible_os_family == "RedHat"
- name: Add Docker GPG key (Debian/Ubuntu)
ansible.builtin.apt_key:
url: https://download.docker.com/linux/ubuntu/gpg
state: present
when: ansible_os_family == "Debian"
- name: Add Docker repository (Debian/Ubuntu)
ansible.builtin.apt_repository:
repo: "deb [arch=amd64] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable"
state: present
filename: docker
when: ansible_os_family == "Debian"
- name: Add Docker repository (RHEL)
ansible.builtin.yum_repository:
name: docker-ce-stable
description: Docker CE Stable
baseurl: https://download.docker.com/linux/centos/$releasever/$basearch/stable
enabled: true
gpgcheck: true
gpgkey: https://download.docker.com/linux/centos/gpg
when: ansible_os_family == "RedHat"
- name: Install Docker Engine
ansible.builtin.apt:
update_cache: true
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-compose-plugin
state: present
when: ansible_os_family == "Debian"
- name: Install Docker Engine (RHEL)
ansible.builtin.dnf:
name:
- docker-ce
- docker-ce-cli
- containerd.io
- docker-compose-plugin
state: present
when: ansible_os_family == "RedHat"
- name: Ensure Docker service is running
ansible.builtin.systemd:
name: docker
enabled: true
state: started
- name: Ensure Errbot config directory exists
ansible.builtin.file:
path: "{{ errbot_config_dir }}"
state: directory
mode: "0755"
- name: Create Dockerfile for Errbot
ansible.builtin.copy:
dest: "{{ errbot_config_dir }}/Dockerfile"
content: |
FROM python:3.12-slim
WORKDIR /opt/errbot
RUN pip install --no-cache-dir errbot=={{ errbot_version }}
COPY config.py /opt/errbot/config.py
COPY plugins/ /opt/errbot/plugins/
CMD ["errbot", "-c", "/opt/errbot/config.py"]
mode: "0644"
- name: Create default Errbot config if missing
ansible.builtin.copy:
dest: "{{ errbot_config_dir }}/config.py"
content: |
# Errbot Configuration
# Backend: Text, IRC, Slack, Telegram, Mattermost, etc.
BACKEND = 'Text'
BOT_DATA_DIR = '/opt/errbot/data'
BOT_EXTRA_PLUGIN_DIR = '/opt/errbot/plugins'
BOT_PREFIX = '!'
BOT_ADMINS = ['admin@example.com']
force: false
mode: "0644"
- name: Ensure plugins directory exists
ansible.builtin.file:
path: "{{ errbot_config_dir }}/plugins"
state: directory
mode: "0755"
- name: Build Errbot Docker image
community.docker.docker_image:
name: "{{ errbot_image }}"
source: build
build:
path: "{{ errbot_config_dir }}"
pull: false
state: present
- name: Run Errbot container
community.docker.docker_container:
name: "{{ errbot_container_name }}"
image: "{{ errbot_image }}"
state: started
restart_policy: unless-stopped
volumes:
- "{{ errbot_config_dir }}/data:/opt/errbot/data"
- "{{ errbot_config_dir }}/plugins:/opt/errbot/plugins"
working_dir: /opt/errbot
- name: Verify container is running
community.docker.docker_container_info:
name: "{{ errbot_container_name }}"
register: errbot_container_info
- name: Show container status
ansible.builtin.debug:
var: errbot_container_info.container.State.Status
For environments without Docker Compose plugin, use this alternative:
- name: Deploy Errbot with Docker (Native)
hosts: errbot
become: true
vars:
errbot_image: local/errbot:6.2.0
errbot_config_dir: /opt/errbot
errbot_container_name: errbot
errbot_version: "6.2.0"
tasks:
- name: Install Docker on Debian family
ansible.builtin.apt:
update_cache: true
name:
- docker.io
- docker-compose
state: present
when: ansible_os_family == "Debian"
- name: Ensure Docker service is running
ansible.builtin.systemd:
name: docker
enabled: true
state: started
- name: Ensure Errbot config directory exists
ansible.builtin.file:
path: "{{ errbot_config_dir }}"
state: directory
mode: "0755"
- name: Create Dockerfile for Errbot
ansible.builtin.copy:
dest: "{{ errbot_config_dir }}/Dockerfile"
content: |
FROM python:3.12-slim
WORKDIR /opt/errbot
RUN pip install --no-cache-dir errbot=={{ errbot_version }}
COPY config.py /opt/errbot/config.py
CMD ["errbot", "-c", "/opt/errbot/config.py"]
mode: "0644"
- name: Create default Errbot config if missing
ansible.builtin.copy:
dest: "{{ errbot_config_dir }}/config.py"
content: |
BACKEND = 'Text'
BOT_DATA_DIR = '/opt/errbot/data'
BOT_PREFIX = '!'
BOT_ADMINS = ['admin@example.com']
force: false
mode: "0644"
- name: Build Errbot Docker image
community.docker.docker_image:
name: "{{ errbot_image }}"
source: build
build:
path: "{{ errbot_config_dir }}"
pull: false
state: present
- name: Run Errbot container
community.docker.docker_container:
name: "{{ errbot_container_name }}"
image: "{{ errbot_image }}"
state: started
restart_policy: unless-stopped
volumes:
- "{{ errbot_config_dir }}/data:/opt/errbot/data"
working_dir: /opt/errbot
ansible-playbook -i inventory.ini errbot-docker-install.yml
# Check container status
docker ps | grep errbot
# View container logs
docker logs errbot
# Execute commands in running container
docker exec -it errbot cat /opt/errbot/data/errbot.botids
config.py