diff --git a/contrib/ci-workers/files/bashrc b/contrib/ci-workers/files/bashrc new file mode 100644 index 000000000..aaad18b92 --- /dev/null +++ b/contrib/ci-workers/files/bashrc @@ -0,0 +1,2 @@ +export PATH=$HOME/venv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin +export EDITOR=vim diff --git a/contrib/ci-workers/templates/buildbot-worker.service.j2 b/contrib/ci-workers/templates/buildbot-worker.service.j2 index ffe497bcf..d77e9559d 100644 --- a/contrib/ci-workers/templates/buildbot-worker.service.j2 +++ b/contrib/ci-workers/templates/buildbot-worker.service.j2 @@ -7,9 +7,9 @@ After=network.target Type=forking PIDFile=/home/{{ buildbot_worker_user }}/{{ buildbot_worker_name }}/twistd.pid WorkingDirectory=/home/{{ buildbot_worker_user }} -ExecStart={{ pip_bin_dir }}/buildbot-worker start {{ buildbot_worker_name }} -ExecReload={{ pip_bin_dir }}/buildbot-worker restart {{ buildbot_worker_name }} -ExecStop={{ pip_bin_dir }}/buildbot-worker stop {{ buildbot_worker_name }} +ExecStart=/home/{{ buildbot_worker_user }}/venv/bin/buildbot-worker start {{ buildbot_worker_name }} +ExecReload=/home/{{ buildbot_worker_user }}/venv/bin/buildbot-worker restart {{ buildbot_worker_name }} +ExecStop=/home/{{ buildbot_worker_user }}/venv/bin/buildbot-worker stop {{ buildbot_worker_name }} Restart=always User={{ buildbot_worker_user }} diff --git a/contrib/ci-workers/unix.yml b/contrib/ci-workers/unix.yml index 6e6cc49c4..17c46d6e0 100644 --- a/contrib/ci-workers/unix.yml +++ b/contrib/ci-workers/unix.yml @@ -88,12 +88,11 @@ include: tasks/install-pip.yml when: ansible_distribution == 'CentOS' - - name: Install required Python modules + - name: Install required Python system modules pip: name: "{{ item }}" state: latest - with_items: "{{ python_modules }}" - notify: restart buildbot-worker + with_items: "{{ system_modules }}" - name: Set up the Buildbot worker user user: @@ -102,9 +101,18 @@ shell: /bin/bash 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 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_worker_name|quote }} {{ buildbot_worker_password|quote }} args: @@ -127,6 +135,14 @@ group: "{{ buildbot_worker_user }}" 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 template: src: templates/buildbot-worker.service.j2 diff --git a/contrib/ci-workers/vars/Archlinux.yml b/contrib/ci-workers/vars/Archlinux.yml index ac4a44e5b..896a10304 100644 --- a/contrib/ci-workers/vars/Archlinux.yml +++ b/contrib/ci-workers/vars/Archlinux.yml @@ -4,4 +4,3 @@ buildbot_deps: build_deps: - multilib/gcc - make -pip_bin_dir: /usr/bin diff --git a/contrib/ci-workers/vars/CentOS.yml b/contrib/ci-workers/vars/CentOS.yml index 7e09b0717..906f53a42 100644 --- a/contrib/ci-workers/vars/CentOS.yml +++ b/contrib/ci-workers/vars/CentOS.yml @@ -10,4 +10,3 @@ dist_deps: - pkgconfig # Required until b556beda264308e040f8d88aca4f2f386a0183d9 is pulled in - python-devel - redhat-rpm-config -pip_bin_dir: /usr/bin diff --git a/contrib/ci-workers/vars/default.yml b/contrib/ci-workers/vars/default.yml index 38c5afc8e..b3e861932 100644 --- a/contrib/ci-workers/vars/default.yml +++ b/contrib/ci-workers/vars/default.yml @@ -34,6 +34,10 @@ grind_deps: - lcov - valgrind +# Python modules required on the system +system_modules: + - virtualenv + # Python modules required for a Zcash Buildbot worker buildbot_modules: - pip # Needs to be updated first so Buildbot installs @@ -44,6 +48,3 @@ buildbot_modules: rpc_test_modules: - pyblake2 - pyzmq - -# Environment variables -pip_bin_dir: /usr/local/bin