From 1ba3e583f359af5ec5241061223449cac56d99a4 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Sat, 8 Jul 2017 06:50:10 -0500 Subject: [PATCH] Make sure bindep is on the node OpenStack nodes pre-install bindep, but other nodes may not. Check to see if bindep is on the node. If so, use it. If not, make a temp dir that we remove at the end of the role and install bindep into a virtualenv in that tempdir. Change-Id: I3f34c178254add2143dc7f1b9758844480d7d914 --- roles/bindep/defaults/main.yaml | 2 ++ roles/bindep/handlers/main.yaml | 4 ++++ roles/bindep/tasks/install.yaml | 15 +++++++++++++++ roles/bindep/tasks/main.yaml | 18 +++++++++++++++--- 4 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 roles/bindep/handlers/main.yaml create mode 100644 roles/bindep/tasks/install.yaml diff --git a/roles/bindep/defaults/main.yaml b/roles/bindep/defaults/main.yaml index a0afa22c5..6bbd4bffb 100644 --- a/roles/bindep/defaults/main.yaml +++ b/roles/bindep/defaults/main.yaml @@ -1,2 +1,4 @@ --- zuul_work_dir: "src/{{ zuul.project.canonical_name }}" +bindep_command: /usr/bindep-env/bin/bindep +bindep_file: "" diff --git a/roles/bindep/handlers/main.yaml b/roles/bindep/handlers/main.yaml new file mode 100644 index 000000000..d7bcdedbf --- /dev/null +++ b/roles/bindep/handlers/main.yaml @@ -0,0 +1,4 @@ +- name: remove bindep temp dir + file: + path: "{{ bindep_temp_dir }}" + state: absent diff --git a/roles/bindep/tasks/install.yaml b/roles/bindep/tasks/install.yaml new file mode 100644 index 000000000..d98fc7274 --- /dev/null +++ b/roles/bindep/tasks/install.yaml @@ -0,0 +1,15 @@ +- name: create temp dir for bindep + tempfile: + state: directory + prefix: bindep + register: bindep_temp_dir + notify: + - remove bindep temp dir + +- name: install bindep into temporary venv + pip: + name: bindep + virtualenv: "{{ bindep_temp_dir }}/venv" + +- set_fact: + bindep_found_command: "{{ bindep_temp_dir }}/venv/bin/bindep" diff --git a/roles/bindep/tasks/main.yaml b/roles/bindep/tasks/main.yaml index 90be192f4..3de793d07 100644 --- a/roles/bindep/tasks/main.yaml +++ b/roles/bindep/tasks/main.yaml @@ -1,12 +1,24 @@ --- +- stat: + path: "{{ bindep_command }}" + register: bindep_command_stat + failed_when: false + +- set_fact: + bindep_found_command: "{{ bindep_command }}" + when: bindep_command_stat is defined + +- include: install.yaml + when: bindep_command_stat is not defined + - name: Install distro packages from bindep args: chdir: "{{ zuul_work_dir }}" executable: /bin/bash + environment: + BINDEP: "{{ bindep_command }}" + PACKAGES: "{{ bindep_file }}" shell: | - # set a default path to the preinstalled bindep entrypoint - export BINDEP=${BINDEP:-/usr/bindep-env/bin/bindep} - function is_fedora { [ -f /usr/bin/yum ] && cat /etc/*release | grep -q -e "Fedora" }