[ci-workers] Install Python modules in a virtualenv

This commit is contained in:
Jack Grigg
2017-10-20 15:34:11 +13:00
parent 0952b02585
commit c9c2650456
6 changed files with 29 additions and 12 deletions

View File

@@ -0,0 +1,2 @@
export PATH=$HOME/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
export EDITOR=vim

View File

@@ -7,9 +7,9 @@ After=network.target
Type=forking Type=forking
PIDFile=/home/{{ buildbot_worker_user }}/{{ buildbot_worker_name }}/twistd.pid PIDFile=/home/{{ buildbot_worker_user }}/{{ buildbot_worker_name }}/twistd.pid
WorkingDirectory=/home/{{ buildbot_worker_user }} WorkingDirectory=/home/{{ buildbot_worker_user }}
ExecStart={{ pip_bin_dir }}/buildbot-worker start {{ buildbot_worker_name }} ExecStart=/home/{{ buildbot_worker_user }}/venv/bin/buildbot-worker start {{ buildbot_worker_name }}
ExecReload={{ pip_bin_dir }}/buildbot-worker restart {{ buildbot_worker_name }} ExecReload=/home/{{ buildbot_worker_user }}/venv/bin/buildbot-worker restart {{ buildbot_worker_name }}
ExecStop={{ pip_bin_dir }}/buildbot-worker stop {{ buildbot_worker_name }} ExecStop=/home/{{ buildbot_worker_user }}/venv/bin/buildbot-worker stop {{ buildbot_worker_name }}
Restart=always Restart=always
User={{ buildbot_worker_user }} User={{ buildbot_worker_user }}

View File

@@ -88,12 +88,11 @@
include: tasks/install-pip.yml include: tasks/install-pip.yml
when: ansible_distribution == 'CentOS' when: ansible_distribution == 'CentOS'
- name: Install required Python modules - name: Install required Python system modules
pip: pip:
name: "{{ item }}" name: "{{ item }}"
state: latest state: latest
with_items: "{{ python_modules }}" with_items: "{{ system_modules }}"
notify: restart buildbot-worker
- name: Set up the Buildbot worker user - name: Set up the Buildbot worker user
user: user:
@@ -102,9 +101,18 @@
shell: /bin/bash shell: /bin/bash
state: present state: present
- name: Install required Python modules
pip:
name: "{{ item }}"
state: latest
virtualenv: "~{{ buildbot_worker_user }}/venv"
with_items: "{{ python_modules }}"
become_user: "{{ buildbot_worker_user }}"
notify: restart buildbot-worker
- name: Create Buildbot worker - name: Create Buildbot worker
command: > command: >
buildbot-worker create-worker ~/{{ buildbot_worker_name }} ~{{ buildbot_worker_user }}/venv/bin/buildbot-worker create-worker ~/{{ buildbot_worker_name }}
{{ buildbot_master_host }}:{{ buildbot_master_port }} {{ buildbot_master_host }}:{{ buildbot_master_port }}
{{ buildbot_worker_name|quote }} {{ buildbot_worker_password|quote }} {{ buildbot_worker_name|quote }} {{ buildbot_worker_password|quote }}
args: args:
@@ -127,6 +135,14 @@
group: "{{ buildbot_worker_user }}" group: "{{ buildbot_worker_user }}"
mode: "0644" mode: "0644"
- name: Install custom bashrc for virtualenv
copy:
src: bashrc
dest: "~{{ buildbot_worker_user }}/.bashrc"
owner: "{{ buildbot_worker_user }}"
group: "{{ buildbot_worker_user }}"
mode: "0644"
- name: Copy Buildbot worker systemd service unit - name: Copy Buildbot worker systemd service unit
template: template:
src: templates/buildbot-worker.service.j2 src: templates/buildbot-worker.service.j2

View File

@@ -4,4 +4,3 @@ buildbot_deps:
build_deps: build_deps:
- multilib/gcc - multilib/gcc
- make - make
pip_bin_dir: /usr/bin

View File

@@ -10,4 +10,3 @@ dist_deps:
- pkgconfig # Required until b556beda264308e040f8d88aca4f2f386a0183d9 is pulled in - pkgconfig # Required until b556beda264308e040f8d88aca4f2f386a0183d9 is pulled in
- python-devel - python-devel
- redhat-rpm-config - redhat-rpm-config
pip_bin_dir: /usr/bin

View File

@@ -34,6 +34,10 @@ grind_deps:
- lcov - lcov
- valgrind - valgrind
# Python modules required on the system
system_modules:
- virtualenv
# Python modules required for a Zcash Buildbot worker # Python modules required for a Zcash Buildbot worker
buildbot_modules: buildbot_modules:
- pip # Needs to be updated first so Buildbot installs - pip # Needs to be updated first so Buildbot installs
@@ -44,6 +48,3 @@ buildbot_modules:
rpc_test_modules: rpc_test_modules:
- pyblake2 - pyblake2
- pyzmq - pyzmq
# Environment variables
pip_bin_dir: /usr/local/bin