Enable developer mode
This commit adds the ability to install magnum without a repo server. This pattern is lifted from the os_cinder role and allows us to further develop functional testing for this role. Change-Id: Idcaad65b45c932613c739b2f498f8f92acbbf53b Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
parent
bacac18263
commit
9c2e500945
|
@ -43,9 +43,27 @@ magnum_service_adminurl: "{{ magnum_service_adminuri_protocol }}://{{ internal_l
|
|||
magnum_config_overrides: {}
|
||||
magnum_policy_overrides: {}
|
||||
|
||||
# Name of the virtual env to deploy into
|
||||
magnum_venv_tag: untagged
|
||||
magnum_venv_bin: "/openstack/venvs/magnum-{{ magnum_venv_tag }}/bin"
|
||||
|
||||
# Set this to enable or disable installing in a venv
|
||||
magnum_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.
|
||||
magnum_bin: "{{ magnum_venv_bin }}"
|
||||
|
||||
magnum_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/magnum.tgz
|
||||
|
||||
magnum_git_repo: "https://git.openstack.org/openstack/magnum"
|
||||
magnum_git_install_branch: c09af59f0f06db9e74a334aaee4c493119384ea7 # master
|
||||
magnum_git_dest: "/opt/magnum_{{ magnum_git_install_branch |replace('/', '_') }}"
|
||||
magnum_git_install_branch: master
|
||||
magnum_requirements_git_repo: https://git.openstack.org/openstack/requirements
|
||||
magnum_requirements_git_install_branch: master
|
||||
magnum_developer_mode: false
|
||||
magnum_developer_constraints:
|
||||
- "git+{{ magnum_git_repo }}@{{ magnum_git_install_branch }}#egg=magnum"
|
||||
|
||||
# Database vars
|
||||
magnum_galera_database_name: magnum_service
|
||||
|
|
|
@ -22,5 +22,5 @@ dependencies:
|
|||
when:
|
||||
- ansible_pkg_mgr == 'apt'
|
||||
- galera_client
|
||||
- pip_install
|
||||
- pip_lock_down
|
||||
- role: pip_install
|
||||
pip_lock_to_internal_repo: "{{ not keystone_developer_mode | bool }}"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
---
|
||||
# Copyright 2016, Ian Cordasco
|
||||
# Copyright 2014, Rackspace US, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
@ -18,17 +18,201 @@
|
|||
- ansible_pkg_mgr == 'apt'
|
||||
tags:
|
||||
- magnum-install
|
||||
- magnum-apt-packages
|
||||
|
||||
- name: Install pip packages for Magnum
|
||||
pip:
|
||||
name: "{{ item }}"
|
||||
state: "latest"
|
||||
extra_args: "{{ pip_install_options |default('') }}"
|
||||
register: install_magnum_pip_packages
|
||||
until: install_magnum_pip_packages |success
|
||||
retries: 5
|
||||
delay: 2
|
||||
with_items: "{{ magnum_pip_packages }}"
|
||||
- name: Create developer mode constraint file
|
||||
copy:
|
||||
dest: "/opt/developer-pip-constraints.txt"
|
||||
content: |
|
||||
{% for item in magnum_developer_constraints %}
|
||||
{{ item }}
|
||||
{% endfor %}
|
||||
when:
|
||||
- magnum_developer_mode | bool
|
||||
tags:
|
||||
- magnum-install
|
||||
- magnum-pip-packages
|
||||
|
||||
- name: Clone requirements git repository
|
||||
git:
|
||||
repo: "{{ magnum_requirements_git_repo }}"
|
||||
dest: "/opt/requirements"
|
||||
clone: yes
|
||||
update: yes
|
||||
version: "{{ magnum_requirements_git_install_branch }}"
|
||||
when:
|
||||
- magnum_developer_mode | bool
|
||||
tags:
|
||||
- magnum-install
|
||||
- magnum-pip-packages
|
||||
|
||||
- name: Add constraints to pip_install_options fact for developer mode
|
||||
set_fact:
|
||||
pip_install_options_fact: "{{ pip_install_options|default('') }} --constraint /opt/developer-pip-constraints.txt --constraint /opt/requirements/upper-constraints.txt"
|
||||
when:
|
||||
- magnum_developer_mode | bool
|
||||
tags:
|
||||
- magnum-install
|
||||
- magnum-pip-packages
|
||||
|
||||
- name: Set pip_install_options_fact when not in developer mode
|
||||
set_fact:
|
||||
pip_install_options_fact: "{{ pip_install_options|default('') }}"
|
||||
when:
|
||||
- not magnum_developer_mode | bool
|
||||
tags:
|
||||
- magnum-install
|
||||
- magnum-pip-packages
|
||||
|
||||
- name: Install requires pip packages
|
||||
pip:
|
||||
name: "{{ item }}"
|
||||
state: latest
|
||||
extra_args: "{{ pip_install_options_fact }}"
|
||||
register: install_packages
|
||||
until: install_packages|success
|
||||
retries: 5
|
||||
delay: 2
|
||||
with_items: "{{ magnum_requires_pip_packages }}"
|
||||
tags:
|
||||
- magnum-install
|
||||
- magnum-pip-packages
|
||||
|
||||
- name: Get local venv checksum
|
||||
stat:
|
||||
path: "/var/cache/{{ magnum_venv_download_url | basename }}"
|
||||
get_md5: False
|
||||
when:
|
||||
- not magnum_developer_mode | bool
|
||||
- magnum_venv_enabled | bool
|
||||
register: local_venv_stat
|
||||
tags:
|
||||
- magnum-install
|
||||
- magnum-pip-packages
|
||||
|
||||
- name: Get remote venv checksum
|
||||
uri:
|
||||
url: "{{ magnum_venv_download_url | replace('tgz', 'checksum') }}"
|
||||
return_content: True
|
||||
when:
|
||||
- not magnum_developer_mode | bool
|
||||
- magnum_venv_enabled | bool
|
||||
register: remote_venv_checksum
|
||||
tags:
|
||||
- magnum-install
|
||||
- magnum-pip-packages
|
||||
|
||||
# TODO: When project moves to ansible 2 we can pass this a sha256sum which will:
|
||||
# a) allow us to remove force: yes
|
||||
# b) allow the module to calculate the checksum of dest file which would
|
||||
# result in file being downloaded only if provided and dest sha256sum
|
||||
# checksums differ
|
||||
- name: Attempt venv download
|
||||
get_url:
|
||||
url: "{{ magnum_venv_download_url }}"
|
||||
dest: "/var/cache/{{ magnum_venv_download_url | basename }}"
|
||||
force: yes
|
||||
ignore_errors: true
|
||||
register: get_venv
|
||||
when:
|
||||
- not magnum_developer_mode | bool
|
||||
- magnum_venv_enabled | bool
|
||||
- (local_venv_stat.stat.exists == False or
|
||||
{{ local_venv_stat.stat.checksum is defined and local_venv_stat.stat.checksum != remote_venv_checksum.content | trim }})
|
||||
tags:
|
||||
- magnum-install
|
||||
- magnum-pip-packages
|
||||
|
||||
- name: Set magnum get_venv fact
|
||||
set_fact:
|
||||
magnum_get_venv: "{{ get_venv }}"
|
||||
when: magnum_venv_enabled | bool
|
||||
tags:
|
||||
- magnum-install
|
||||
- magnum-pip-packages
|
||||
|
||||
- name: Remove existing venv
|
||||
file:
|
||||
path: "{{ magnum_venv_bin | dirname }}"
|
||||
state: absent
|
||||
when:
|
||||
- magnum_venv_enabled | bool
|
||||
- magnum_get_venv | changed
|
||||
tags:
|
||||
- magnum-install
|
||||
- magnum-pip-packages
|
||||
|
||||
- name: Create magnum venv dir
|
||||
file:
|
||||
path: "{{ magnum_venv_bin | dirname }}"
|
||||
state: directory
|
||||
when:
|
||||
- not magnum_developer_mode | bool
|
||||
- magnum_venv_enabled | bool
|
||||
- magnum_get_venv | changed
|
||||
tags:
|
||||
- magnum-install
|
||||
- magnum-pip-packages
|
||||
|
||||
- name: Unarchive pre-built venv
|
||||
unarchive:
|
||||
src: "/var/cache/{{ magnum_venv_download_url | basename }}"
|
||||
dest: "{{ magnum_venv_bin | dirname }}"
|
||||
copy: "no"
|
||||
when:
|
||||
- not magnum_developer_mode | bool
|
||||
- magnum_venv_enabled | bool
|
||||
- magnum_get_venv | changed
|
||||
notify: Restart magnum services
|
||||
tags:
|
||||
- magnum-install
|
||||
- magnum-pip-packages
|
||||
|
||||
- name: Update virtualenv path
|
||||
command: >
|
||||
virtualenv-tools --update-path=auto {{ magnum_venv_bin | dirname }}
|
||||
when:
|
||||
- not magnum_developer_mode | bool
|
||||
- magnum_venv_enabled | bool
|
||||
- magnum_get_venv | success
|
||||
tags:
|
||||
- magnum-install
|
||||
- magnum-pip-packages
|
||||
|
||||
- name: Install pip packages (venv)
|
||||
pip:
|
||||
name: "{{ item }}"
|
||||
state: latest
|
||||
virtualenv: "{{ magnum_venv_bin | dirname }}"
|
||||
virtualenv_site_packages: "no"
|
||||
extra_args: "{{ pip_install_options_fact }}"
|
||||
register: install_packages
|
||||
until: install_packages|success
|
||||
retries: 5
|
||||
delay: 2
|
||||
with_items: "{{ magnum_pip_packages }}"
|
||||
when:
|
||||
- magnum_venv_enabled | bool
|
||||
- magnum_get_venv | failed or magnum_developer_mode | bool
|
||||
notify: Restart magnum services
|
||||
tags:
|
||||
- magnum-install
|
||||
- magnum-pip-packages
|
||||
|
||||
- name: Install pip packages (no venv)
|
||||
pip:
|
||||
name: "{{ item }}"
|
||||
state: latest
|
||||
extra_args: "{{ pip_install_options_fact }}"
|
||||
register: install_packages
|
||||
until: install_packages|success
|
||||
retries: 5
|
||||
delay: 2
|
||||
with_items: "{{ magnum_pip_packages }}"
|
||||
when:
|
||||
- not magnum_developer_mode | bool
|
||||
- not magnum_venv_enabled | bool
|
||||
notify: Restart magnum services
|
||||
tags:
|
||||
- magnum-install
|
||||
- magnum-pip-packages
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
# {{ ansible_managed }}
|
||||
|
||||
# vim:set ft=upstart ts=2 et:
|
||||
|
||||
description "{{ program_name }}"
|
||||
author "Kevin Carter <kevin.carter@rackspace.com>"
|
||||
|
||||
|
@ -12,7 +10,7 @@ respawn
|
|||
respawn limit 10 5
|
||||
|
||||
# Set the RUNBIN environment variable
|
||||
env RUNBIN="/usr/local/bin/{{ program_name }}"
|
||||
env RUNBIN="{{ magnum_bin }}/{{ program_name }}"
|
||||
|
||||
# Change directory to service users home
|
||||
chdir "{{ service_home }}"
|
||||
|
@ -24,6 +22,11 @@ pre-start script
|
|||
|
||||
mkdir -p "/var/lock/{{ program_name }}"
|
||||
chown {{ system_user }}:{{ system_group }} "/var/lock/{{ program_name }}"
|
||||
|
||||
{% if magnum_venv_enabled | bool -%}
|
||||
. {{ magnum_venv_bin }}/activate
|
||||
{%- endif %}
|
||||
|
||||
end script
|
||||
|
||||
# Post stop actions
|
||||
|
@ -36,6 +39,6 @@ exec start-stop-daemon --start \
|
|||
--chuid {{ system_user }} \
|
||||
--make-pidfile \
|
||||
--pidfile /var/run/{{ program_name }}/{{ program_name }}.pid \
|
||||
--exec "{{ program_override |default('$RUNBIN') }}" \
|
||||
-- {{ program_config_options |default('') }} \
|
||||
--log-file={{ log_directory }}/{{ program_name }}.log
|
||||
--exec "{{ program_override|default('$RUNBIN') }}" \
|
||||
-- {{ program_config_options|default('') }} \
|
||||
--log-file=/var/log/magnum/{{ program_name }}.log
|
||||
|
|
Loading…
Reference in New Issue