From 58db0ed2e076bce75b0f9bd8f3d4fcf426caec8a Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Fri, 14 Feb 2020 14:59:24 +0000 Subject: [PATCH] Avoid writing out requirements.txt in kolla-ansible role We can use the Ansible pip module's support for specifying a list of packages with version constraints. Change-Id: If5d3c7117175732c54e38025692eb4c036053ebc --- ansible/roles/kolla-ansible/defaults/main.yml | 3 +++ ansible/roles/kolla-ansible/tasks/install.yml | 24 ++++++++++++++----- .../templates/requirements.txt.j2 | 18 -------------- 3 files changed, 21 insertions(+), 24 deletions(-) delete mode 100644 ansible/roles/kolla-ansible/templates/requirements.txt.j2 diff --git a/ansible/roles/kolla-ansible/defaults/main.yml b/ansible/roles/kolla-ansible/defaults/main.yml index 13e1eb94d..3ee66b606 100644 --- a/ansible/roles/kolla-ansible/defaults/main.yml +++ b/ansible/roles/kolla-ansible/defaults/main.yml @@ -23,6 +23,9 @@ kolla_ansible_venv_python: "python{{ kolla_ansible_venv_python_major_version }}" # FIXME(mgoddard): Use ansible_python when Kayobe supports Python 3. kolla_ansible_venv_python_major_version: 3 +# Extra requirements to install inside the kolla-ansible virtualenv. +kolla_ansible_venv_extra_requirements: [] + # Virtualenv directory where Kolla-ansible's ansible modules will execute # remotely on the target nodes. If None, no virtualenv will be used. kolla_ansible_target_venv: diff --git a/ansible/roles/kolla-ansible/tasks/install.yml b/ansible/roles/kolla-ansible/tasks/install.yml index 24def5d02..64b225f4e 100644 --- a/ansible/roles/kolla-ansible/tasks/install.yml +++ b/ansible/roles/kolla-ansible/tasks/install.yml @@ -69,14 +69,26 @@ with_items: - { name: pip } -- name: Ensure python requirements file exists - template: - src: requirements.txt.j2 - dest: "{{ kolla_ansible_venv }}/requirements.txt" - - name: Ensure required Python packages are installed + vars: + kolla_ansible_packages: + # Install Kolla Ansible from source or PyPI. + - >- + {% if kolla_ansible_ctl_install_type == 'source' %} + {{ kolla_ansible_source_path }} + {% else %} + kolla-ansible=={{ kolla_openstack_release }} + {% endif %} + # Limit the version of ansible used by kolla-ansible to avoid new + # releases from breaking tested code. Changes to this limit should be + # tested. + - ansible>=2.8,<2.10,!=2.8.9 + - >- + {%- if ansible_os_family == 'RedHat' and ansible_distribution_major_version | int >= 8 %} + selinux + {% endif -%} pip: - requirements: "{{ kolla_ansible_venv }}/requirements.txt" + name: "{{ (kolla_ansible_packages + kolla_ansible_venv_extra_requirements) | select | list }}" state: latest extra_args: "{% if kolla_upper_constraints_file %}-c {{ kolla_upper_constraints_file }}{% endif %}" virtualenv: "{{ kolla_ansible_venv }}" diff --git a/ansible/roles/kolla-ansible/templates/requirements.txt.j2 b/ansible/roles/kolla-ansible/templates/requirements.txt.j2 deleted file mode 100644 index 1917f0556..000000000 --- a/ansible/roles/kolla-ansible/templates/requirements.txt.j2 +++ /dev/null @@ -1,18 +0,0 @@ -{% if kolla_ansible_ctl_install_type == 'source' %} -# Install Kolla Ansible from source. -{{ kolla_ansible_source_path }} -{% else %} -# Install Kolla Ansible from PyPI. -kolla-ansible=={{ kolla_openstack_release }} -{% endif %} -# Limit the version of ansible used by kolla-ansible to avoid new releases from -# breaking tested code. Changes to this limit should be tested. -ansible>=2.8,<2.10,!=2.8.9 -{% if ansible_os_family == 'RedHat' and ansible_distribution_major_version | int >= 8 %} -selinux -{% endif %} -{% if kolla_ansible_venv_extra_requirements is defined %} -{% for item in kolla_ansible_venv_extra_requirements %} -{{ item }} -{% endfor %} -{% endif %}