Implement glance venv support

This commit conditionally allows the os_glance role to
install build and deploy within a venv. This is the new
default behavior of the role however the functionality
can be disabled.

Change-Id: If58b1f2ebe15672602effe5c06c85524385562ba
Implements: blueprint enable-venv-support-within-the-roles
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter 2015-09-29 21:01:01 -05:00
parent 3f543ce600
commit 9b56d77546
6 changed files with 110 additions and 27 deletions

View File

@ -13,15 +13,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Defines that the role will be deployed on a host machine
is_metal: true
## Verbosity Options
debug: False
verbose: True
# Name of the virtual env to deploy into
glance_venv_tag: untagged
glance_venv_bin: "/openstack/venvs/glance-{{ glance_venv_tag }}/bin"
# Set this to enable or disable installing in a venv
glance_venv_enabled: true
# The bin path defaults to the venv path however if installation in a
# venv is disabled the bin path will be dynamically set based on the
# system path used when the installing.
glance_bin: "{{ glance_venv_bin }}"
# Enable/Disable Ceilometer
glance_ceilometer_enabled: False
## Verbosity Options
debug: False
verbose: True
glance_profiler_enabled: False
glance_fatal_deprecations: False
@ -151,6 +161,11 @@ glance_apt_packages:
- git
- nfs-common
# Cinder packages that must be installed before anything else
glance_requires_pip_packages:
- virtualenv
- python-keystoneclient # Keystoneclient needed to OSA keystone lib
# Common pip packages
glance_pip_packages:
- glance

View File

@ -40,9 +40,10 @@
- glance-db-setup
- name: Perform a Glance DB sync
command: glance-manage db_sync
command: "{{ glance_bin }}/glance-manage db_sync"
sudo: yes
sudo_user: "{{ glance_system_user_name }}"
tags:
- glance-db-sync
- glance-setup
- glance-command-bin

View File

@ -37,7 +37,40 @@
- glance-install
- glance-apt-packages
- name: Install pip packages
- name: Install requires pip packages
pip:
name: "{{ item }}"
state: present
extra_args: "{{ pip_install_options|default('') }}"
register: install_packages
until: install_packages|success
retries: 5
delay: 2
with_items:
- "{{ glance_requires_pip_packages }}"
tags:
- glance-install
- glance-pip-packages
- name: Install pip packages (venv)
pip:
name: "{{ item }}"
state: present
virtualenv: "{{ glance_venv_bin | dirname }}"
virtualenv_site_packages: "no"
extra_args: "{{ pip_install_options|default('') }}"
register: install_packages
until: install_packages|success
retries: 5
delay: 2
with_items:
- "{{ glance_pip_packages }}"
when: glance_venv_enabled | bool
tags:
- glance-install
- glance-pip-packages
- name: Install pip packages (no venv)
pip:
name: "{{ item }}"
state: present
@ -48,6 +81,7 @@
delay: 2
with_items:
- "{{ glance_pip_packages }}"
when: not glance_venv_enabled | bool
tags:
- glance-install
- glance-pip-packages

View File

@ -13,25 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Create glance cache management cron jobs
cron:
name: "{{ item.name }}"
minute: "{{ 59 |random(start=1) }}"
day: "*"
hour: "{{ item.hour }}"
month: "*"
state: present
job: "{{ item.name }}"
user: glance
with_items:
- name: /usr/local/bin/glance-cache-pruner
hour: "*"
- name: /usr/local/bin/glance-cache-cleaner
hour: "*/5"
when: glance_flavor | search("cache")
tags:
- glance-cron
- name: Drop Glance Config(s)
config_template:
src: "{{ item.src }}"
@ -112,3 +93,38 @@
tags:
- glance-nfs
- glance-nfs-local-path
- name: Get glance command path
command: which glance
register: glance_command_path
when:
- not glance_venv_enabled | bool
tags:
- glance-command-bin
- name: Set glance command path
set_fact:
glance_bin: "{{ glance_command_path.stdout | dirname }}"
when:
- not glance_venv_enabled | bool
tags:
- glance-command-bin
- name: Create glance cache management cron jobs
cron:
name: "{{ item.name }}"
minute: "{{ 59 |random(start=1) }}"
day: "*"
hour: "{{ item.hour }}"
month: "*"
state: present
job: "{{ item.name }}"
user: glance
with_items:
- name: "{{ glance_bin }}/glance-cache-pruner"
hour: "*"
- name: "{{ glance_bin }}/glance-cache-cleaner"
hour: "*/5"
when: glance_flavor | search("cache")
tags:
- glance-cron

View File

@ -41,6 +41,7 @@
group: "{{ item.group|default(glance_system_group_name) }}"
mode: "{{ item.mode|default('0755') }}"
with_items:
- { path: "/openstack", mode: "0755", owner: "root", group: "root" }
- { path: "/etc/glance" }
- { path: "/etc/sudoers.d", mode: "0755", owner: "root", group: "root" }
- { path: "/var/cache/glance" }
@ -52,6 +53,17 @@
tags:
- glance-dirs
- name: Create glance venv dir
file:
path: "{{ item.path }}"
state: directory
with_items:
- { path: "/openstack/venvs" }
- { path: "{{ glance_venv_bin }}" }
when: glance_venv_enabled | bool
tags:
- glance-dirs
- name: Test for log directory or link
shell: |
if [ -h "/var/log/glance" ]; then

View File

@ -12,7 +12,7 @@ respawn
respawn limit 10 5
# Set the RUNBIN environment variable
env RUNBIN="/usr/local/bin/{{ program_name }}"
env RUNBIN="{{ glance_bin }}/{{ program_name }}"
# Change directory to service users home
chdir "{{ service_home }}"
@ -24,6 +24,11 @@ pre-start script
mkdir -p "/var/lock/{{ program_name }}"
chown {{ system_user }}:{{ system_group }} "/var/lock/{{ program_name }}"
{% if glance_venv_enabled | bool -%}
. {{ glance_venv_bin }}/activate
{%- endif %}
end script
# Post stop actions