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
This commit is contained in:
Monty Taylor 2017-07-08 06:50:10 -05:00
parent ab6e3f5fd9
commit 1ba3e583f3
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
4 changed files with 36 additions and 3 deletions

View File

@ -1,2 +1,4 @@
---
zuul_work_dir: "src/{{ zuul.project.canonical_name }}"
bindep_command: /usr/bindep-env/bin/bindep
bindep_file: ""

View File

@ -0,0 +1,4 @@
- name: remove bindep temp dir
file:
path: "{{ bindep_temp_dir }}"
state: absent

View File

@ -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"

View File

@ -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"
}