project-config/playbooks/proposal/pre.yaml
Clark Boylan 55215ac11c Set ensure_pip_virtualenv_command in Focal proposal jobs
Previously we had this error:

  No key/value pairs provided, at least one is required for this action to succeed

Which appears to be due to the default(omit) condition when setting
ensure_pip_virtualenv_command in focal proposal jobs. The issue is
default(omit) doesn't do what you think it does when defining a
variable. It is really only useful for defining module parameters that
may be omitted.

Instead we need to call ensure-tox two different ways depending on
whether or not we want to override the defaults for
ensure_pip_virtualenv_command. One method for Bionic and another for
Focal keyed off of whether or not _venv_command is defined.

Change-Id: I0cbca64f4a31c8b4eacb5e1c50f2e9fb289ce18e
2022-07-27 09:08:04 -07:00

93 lines
2.7 KiB
YAML

- hosts: all
pre_tasks:
- name: Ensure pip
include_role:
name: ensure-pip
- name: Install git-review
pip:
name: git-review
virtualenv: /opt/git-review
virtualenv_command: '{{ ensure_pip_virtualenv_command }}'
become: yes
- name: Link git-review
file:
src: /opt/git-review/bin/git-review
dest: /usr/local/bin/git-review
owner: root
group: root
state: link
become: yes
- name: Copy scripts to the script dir on the node
copy:
dest: '{{ ansible_user_dir }}/scripts/'
src: '{{ item }}'
mode: 0755
with_items:
- generate_puppetfile.sh
- propose_update.sh
- sync_openstack_ansible_common_files.sh
roles:
- role: configure-git
git_config:
user.name: OpenStack Proposal Bot
user.email: openstack-infra@lists.openstack.org
gitreview.username: proposal-bot
- copy-proposal-common-scripts
# For propose-update-constraints
- copy-release-tools-scripts
- add-sshkey
- bindep
tasks:
# NOTE: Due to a confluence of problems between requirements
# versions, java versions, zanata clients, etc. translation
# proposal jobs have to run on bionic. However, ensure-tox uses
# ensure_pip_virtualenv_command, which installs using default
# python on the system. On bionic this is 3.6, which can not deal
# with master upper-constraints.txt.
#
# So we bring in the python 3.8 packages and override ensure-tox
# to use this to create the tox environment.
- name: Setup Bionic
when: ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'bionic'
block:
- name: Ensure python
include_role:
name: ensure-python
vars:
python_version: 3.8
- name: Setup virtualenv version
set_fact:
_venv_command: '/usr/bin/python3.8 -m venv'
# The base proposal jobs require both python3.8 and python3.9.
# Bring in Python 3.9 for them here.
- name: Setup Focal
when: ansible_distribution == 'Ubuntu' and ansible_distribution_release == 'focal'
block:
- name: Ensure python
include_role:
name: ensure-python
vars:
python_version: 3.9
- name: Install tox with venv command override
include_role:
name: ensure-tox
vars:
ensure_global_symlinks: true
ensure_pip_virtualenv_command: '{{ _venv_command }}'
when: _venv_command is defined
- name: Install tox without venv command override
include_role:
name: ensure-tox
vars:
ensure_global_symlinks: true
when: _venv_command is not defined