This guide deploys a Buildbot master inside a Python virtual environment and manages it with systemd.
buildbot account and workspacebuildbot-master systemd service- name: Deploy Buildbot master
hosts: buildbot
become: true
vars:
buildbot_user: buildbot
buildbot_home: /opt/buildbot
buildbot_master_dir: /opt/buildbot/master
tasks:
- name: Install dependencies on Debian family
ansible.builtin.apt:
update_cache: true
name:
- python3
- python3-pip
- python3-venv
- build-essential
- libffi-dev
- libssl-dev
state: present
when: ansible_os_family == "Debian"
- name: Install dependencies on RHEL family
ansible.builtin.dnf:
name:
- python3
- python3-pip
- gcc
- libffi-devel
- openssl-devel
state: present
when: ansible_os_family == "RedHat"
- name: Ensure Buildbot user exists
ansible.builtin.user:
name: "{{ buildbot_user }}"
system: true
create_home: true
home: "{{ buildbot_home }}"
shell: /usr/sbin/nologin
- name: Ensure Buildbot workspace exists
ansible.builtin.file:
path: "{{ buildbot_home }}"
state: directory
owner: "{{ buildbot_user }}"
group: "{{ buildbot_user }}"
mode: "0755"
- name: Create Python virtual environment
ansible.builtin.command: python3 -m venv {{ buildbot_home }}/venv
args:
creates: "{{ buildbot_home }}/venv/bin/activate"
- name: Install Buildbot bundle
ansible.builtin.pip:
name: buildbot[bundle]
virtualenv: "{{ buildbot_home }}/venv"
- name: Initialize Buildbot master if missing
ansible.builtin.command: "{{ buildbot_home }}/venv/bin/buildbot create-master {{ buildbot_master_dir }}"
args:
creates: "{{ buildbot_master_dir }}/master.cfg"
become_user: "{{ buildbot_user }}"
- name: Install systemd unit
ansible.builtin.copy:
dest: /etc/systemd/system/buildbot-master.service
mode: "0644"
content: |
[Unit]
Description=Buildbot Master
After=network.target
[Service]
User={{ buildbot_user }}
Group={{ buildbot_user }}
WorkingDirectory={{ buildbot_master_dir }}
ExecStart={{ buildbot_home }}/venv/bin/buildbot start --nodaemon {{ buildbot_master_dir }}
ExecStop={{ buildbot_home }}/venv/bin/buildbot stop {{ buildbot_master_dir }}
Restart=on-failure
[Install]
WantedBy=multi-user.target
- name: Enable and start Buildbot
ansible.builtin.systemd:
name: buildbot-master
enabled: true
state: started
daemon_reload: true
ansible-playbook -i inventory.ini buildbot-install.yml