b80e94ca36
When using a target virtual environment for kolla-ansible [1], it is possible to get a Permission Denied error. This can occur if the permissions of /opt/kayobe or /opt/kayobe/venvs are restricted to the stack user (0700), since kolla ansible uses the kolla user. Although it makes sense for /opt/kayobe/venvs/kayobe to be 0700, /opt/kayobe and /opt/kayobe/venvs should be 0755 to allow the kolla user to access a virtualenv in /opt/kayobe/venvs/kolla-ansible. This was seen during deployment of a seed, with kayobe target virtualenvs [2] also in use. Since the kayobe-target-venv.yml playbook is one of the first playbooks to be run, it will create the /opt/kayobe and /opt/kayobe/venvs directories, and set the permissions correctly. [1] http://kayobe.readthedocs.io/en/latest/configuration/kolla-ansible.html#remote-execution-environment [2] http://kayobe.readthedocs.io/en/latest/configuration/kayobe.html#remote-execution-environment Change-Id: I124cff8f08309c1eeef78c035c4cf195367b21f2 Story: 2001968 Task: 15868
73 lines
2.3 KiB
YAML
73 lines
2.3 KiB
YAML
---
|
|
# Create a virtualenv for ansible modules to use on the remote target systems
|
|
# when running kayobe.
|
|
|
|
- name: Ensure a virtualenv exists for kayobe
|
|
hosts: seed:seed-hypervisor:overcloud
|
|
gather_facts: False
|
|
tags:
|
|
- kayobe-target-venv
|
|
tasks:
|
|
- name: Set a fact about the kayobe target virtualenv
|
|
set_fact:
|
|
virtualenv: "{{ ansible_python_interpreter | dirname | dirname }}"
|
|
when:
|
|
- ansible_python_interpreter is defined
|
|
- not ansible_python_interpreter.startswith('/bin')
|
|
- not ansible_python_interpreter.startswith('/usr/bin')
|
|
|
|
- block:
|
|
# This will cause ansible to use the system python interpreter.
|
|
- name: Deactivate the virtualenv
|
|
include_role:
|
|
name: deactivate-virtualenv
|
|
|
|
- name: Ensure the python-virtualenv package is installed
|
|
package:
|
|
name: python-virtualenv
|
|
state: installed
|
|
become: True
|
|
|
|
- name: Ensure global virtualenv directory exists
|
|
file:
|
|
path: "{{ virtualenv_path }}"
|
|
state: directory
|
|
owner: "{{ ansible_user }}"
|
|
group: "{{ ansible_user }}"
|
|
mode: 0755
|
|
# Check whether the virtualenv directory is a subdirectory of the
|
|
# global virtualenv directory.
|
|
when: virtualenv.startswith(virtualenv_path)
|
|
become: True
|
|
|
|
- name: Ensure kayobe virtualenv directory exists
|
|
file:
|
|
path: "{{ virtualenv }}"
|
|
state: directory
|
|
owner: "{{ ansible_user }}"
|
|
group: "{{ ansible_user }}"
|
|
mode: 0700
|
|
become: True
|
|
|
|
- name: Ensure kayobe virtualenv has the latest version of pip installed
|
|
pip:
|
|
name: pip
|
|
state: latest
|
|
virtualenv: "{{ virtualenv }}"
|
|
# Site packages are required for using the yum and selinux python
|
|
# modules, which are not available via PyPI.
|
|
virtualenv_site_packages: True
|
|
|
|
- name: Activate the virtualenv
|
|
include_role:
|
|
name: activate-virtualenv
|
|
vars:
|
|
activate_virtualenv_path: "{{ virtualenv }}"
|
|
when: virtualenv is defined
|
|
|
|
- name: Ensure pip is installed
|
|
easy_install:
|
|
name: pip
|
|
become: True
|
|
when: virtualenv is not defined
|