From 8ebb299d40e49c82226200243d2772ffa9994ddc Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 1 Aug 2017 12:35:58 +0100 Subject: [PATCH 1/4] ci-workers: Enable pipelining, and use root to set admin and host details Workarounds for Ansible issues when becoming an unprivileged user: https://docs.ansible.com/ansible/become.html#becoming-an-unprivileged-user --- contrib/ci-workers/ansible.cfg | 2 ++ contrib/ci-workers/unix.yml | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 contrib/ci-workers/ansible.cfg diff --git a/contrib/ci-workers/ansible.cfg b/contrib/ci-workers/ansible.cfg new file mode 100644 index 000000000..c58fea3c0 --- /dev/null +++ b/contrib/ci-workers/ansible.cfg @@ -0,0 +1,2 @@ +[ssh_connection] +pipelining = True diff --git a/contrib/ci-workers/unix.yml b/contrib/ci-workers/unix.yml index 42bcaafc2..ad78f7914 100644 --- a/contrib/ci-workers/unix.yml +++ b/contrib/ci-workers/unix.yml @@ -99,14 +99,18 @@ - name: Set admin details for Buildbot worker copy: content: "{{ buildbot_worker_admin }}" - dest: "~/{{ buildbot_worker_name }}/info/admin" - become_user: "{{ buildbot_worker_user }}" + dest: "~{{ buildbot_worker_user }}/{{ buildbot_worker_name }}/info/admin" + owner: "{{ buildbot_worker_user }}" + group: "{{ buildbot_worker_user }}" + mode: "0644" - name: Set host details for Buildbot worker template: src: "{{ buildbot_worker_host_template }}" - dest: "~/{{ buildbot_worker_name }}/info/host" - become_user: "{{ buildbot_worker_user }}" + dest: "~{{ buildbot_worker_user }}/{{ buildbot_worker_name }}/info/host" + owner: "{{ buildbot_worker_user }}" + group: "{{ buildbot_worker_user }}" + mode: "0644" - name: Copy Buildbot worker systemd service unit template: From 30cc2b846edfcc5f699afc3ca5cc0c0a5c755171 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Thu, 3 Aug 2017 14:36:08 +0100 Subject: [PATCH 2/4] Variable overrides for Arch Linux Part of #2550 --- contrib/ci-workers/templates/buildbot-worker.service.j2 | 6 +++--- contrib/ci-workers/unix.yml | 6 ++++++ contrib/ci-workers/vars/Archlinux.yml | 7 +++++++ contrib/ci-workers/vars/default.yml | 3 +++ 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 contrib/ci-workers/vars/Archlinux.yml diff --git a/contrib/ci-workers/templates/buildbot-worker.service.j2 b/contrib/ci-workers/templates/buildbot-worker.service.j2 index 1fee26aa3..ffe497bcf 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=/usr/local/bin/buildbot-worker start {{ buildbot_worker_name }} -ExecReload=/usr/local/bin/buildbot-worker restart {{ buildbot_worker_name }} -ExecStop=/usr/local/bin/buildbot-worker stop {{ buildbot_worker_name }} +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 }} Restart=always User={{ buildbot_worker_user }} diff --git a/contrib/ci-workers/unix.yml b/contrib/ci-workers/unix.yml index ad78f7914..763d8fe45 100644 --- a/contrib/ci-workers/unix.yml +++ b/contrib/ci-workers/unix.yml @@ -67,6 +67,12 @@ package_deps: "{{ buildbot_deps + fetch_deps + conf_deps + build_deps + link_deps + dist_deps }}" python_modules: "{{ buildbot_modules + rpc_test_modules }}" + - name: Update rolling release [Arch Linux] + pacman: + update_cache: yes + upgrade: yes + when: ansible_distribution == 'Archlinux' + - name: Install required packages package: name: "{{ item }}" diff --git a/contrib/ci-workers/vars/Archlinux.yml b/contrib/ci-workers/vars/Archlinux.yml new file mode 100644 index 000000000..ac4a44e5b --- /dev/null +++ b/contrib/ci-workers/vars/Archlinux.yml @@ -0,0 +1,7 @@ +--- +buildbot_deps: + - python2-pip +build_deps: + - multilib/gcc + - make +pip_bin_dir: /usr/bin diff --git a/contrib/ci-workers/vars/default.yml b/contrib/ci-workers/vars/default.yml index 13a04e7b4..67da0e51d 100644 --- a/contrib/ci-workers/vars/default.yml +++ b/contrib/ci-workers/vars/default.yml @@ -39,3 +39,6 @@ buildbot_modules: rpc_test_modules: - pyblake2 - pyzmq + +# Environment variables +pip_bin_dir: /usr/local/bin From 2e839df328b86edf7d0a1b8800a34f8612281543 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Tue, 8 Aug 2017 00:19:23 +0100 Subject: [PATCH 3/4] ci-workers: Fail if Python is not version 2.7 Ansible works with Python 2.6 and 2.7, but Buildbot requires 2.7. Both have at least preliminary Python 3 support, but until our RPC tests are migrated to Python 3, we need to use Python 2 for testing, and so this requirement stands. --- contrib/ci-workers/unix.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/contrib/ci-workers/unix.yml b/contrib/ci-workers/unix.yml index 763d8fe45..ac53ae412 100644 --- a/contrib/ci-workers/unix.yml +++ b/contrib/ci-workers/unix.yml @@ -19,7 +19,7 @@ prompt: "Buildbot worker password (provided by ZECC)" pre_tasks: - - name: Install Python 2 for Ansible and Buildbot + - name: Install Python 2.7 for Ansible and Buildbot raw: test -e /usr/bin/python || test -e /usr/bin/python2 || test -e /usr/bin/python2.7 || test -e /usr/local/bin/python2.7 || (test -e /usr/bin/apt && apt -qqy update && apt install -qqy python) || (test -e /usr/bin/dnf && dnf install -qqy python2) || (test -e /usr/sbin/pkg && pkg install -qqy python2) register: output changed_when: @@ -34,7 +34,7 @@ - name: Fail if configured Python is unavailable fail: - msg: Python is not accessible at {{ ansible_python_interpreter }} on this host! Please set the inventory variable 'ansible_python_interpreter' to the location of the Python 2 binary. + msg: "Python is not accessible at {{ ansible_python_interpreter }} on this host! Please set the inventory variable 'ansible_python_interpreter' to the location of the Python 2.7 binary." when: ansible_python_interpreter is defined and python_check.rc == 1 - name: Check if Python is in the default location @@ -45,12 +45,17 @@ - name: Fail if default Python is unavailable fail: - msg: Python is not accessible at /usr/bin/python on this host! Please set the inventory variable 'ansible_python_interpreter' to the location of the Python 2 binary. + msg: Python is not accessible at /usr/bin/python on this host! Please set the inventory variable 'ansible_python_interpreter' to the location of the Python 2.7 binary. when: ansible_python_interpreter is undefined and python_check.rc == 1 - name: Gathering Facts setup: + - name: Fail if Python is the wrong version + fail: + msg: "The Python binary at {{ ansible_python.executable }} is version {{ ansible_python_version }}! Please set the inventory variable 'ansible_python_interpreter' to the location of the Python 2.7 binary." + when: ansible_python.version.major != 2 or ansible_python.version.minor != 7 + tasks: - name: Get dependencies for distribution include_vars: "{{ item }}" From bac53a2c1d2fdb32a72fafeea8c53c0c4022152f Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Wed, 9 Aug 2017 23:41:48 +0200 Subject: [PATCH 4/4] ci-workers: Variable overrides and process tweaks for CentOS 7 Part of #2510 --- contrib/ci-workers/tasks/install-pip.yml | 8 ++++++++ contrib/ci-workers/unix.yml | 4 ++++ contrib/ci-workers/vars/CentOS.yml | 13 +++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 contrib/ci-workers/tasks/install-pip.yml create mode 100644 contrib/ci-workers/vars/CentOS.yml diff --git a/contrib/ci-workers/tasks/install-pip.yml b/contrib/ci-workers/tasks/install-pip.yml new file mode 100644 index 000000000..8beff50ef --- /dev/null +++ b/contrib/ci-workers/tasks/install-pip.yml @@ -0,0 +1,8 @@ +--- +- name: Fetch pip installer + get_url: + url: https://bootstrap.pypa.io/get-pip.py + dest: /tmp/get-pip.py + +- name: Install pip + command: "{{ ansible_python.executable }} /tmp/get-pip.py" diff --git a/contrib/ci-workers/unix.yml b/contrib/ci-workers/unix.yml index ac53ae412..6e6cc49c4 100644 --- a/contrib/ci-workers/unix.yml +++ b/contrib/ci-workers/unix.yml @@ -84,6 +84,10 @@ state: present with_items: "{{ package_deps }}" + - name: Install pip [CentOS] + include: tasks/install-pip.yml + when: ansible_distribution == 'CentOS' + - name: Install required Python modules pip: name: "{{ item }}" diff --git a/contrib/ci-workers/vars/CentOS.yml b/contrib/ci-workers/vars/CentOS.yml new file mode 100644 index 000000000..7e09b0717 --- /dev/null +++ b/contrib/ci-workers/vars/CentOS.yml @@ -0,0 +1,13 @@ +--- +buildbot_deps: [] # Empty to remove python-pip +build_deps: + - bzip2 + - gcc + - gcc-c++ + - make + - patch +dist_deps: + - pkgconfig # Required until b556beda264308e040f8d88aca4f2f386a0183d9 is pulled in + - python-devel + - redhat-rpm-config +pip_bin_dir: /usr/bin