Only install to virtual environment

Remove all tasks and variables related to toggling between installation
of cloudkitty inside or outside of a Python virtual environment.
Installing within a venv is now the only supported deployment.

Additionally, a few changes have been made to make the creation of the
venv more resistant to interruptions during a run of the role.
* unarchiving a pre-built venv will now also occur when the venv
  directory is created, not only after being downloaded
* virtualenv-tools is run against both pre-built and non pre-built venvs
  to account for interruptions during or prior to unarchiving

Change-Id: I84dd86e4e8244de5a6ac55a302df0c9737d6388e
Implements: blueprint only-install-venvs
This commit is contained in:
Jimmy McCrory
2016-07-07 11:34:20 -07:00
committed by Anton Khaldin
parent 3828fccefe
commit f76b9ee74b
6 changed files with 18 additions and 80 deletions

View File

@@ -28,15 +28,7 @@ cloudkitty_system_shell: /bin/false
cloudkitty_system_home_folder: "/var/lib/{{ cloudkitty_system_user_name }}" cloudkitty_system_home_folder: "/var/lib/{{ cloudkitty_system_user_name }}"
cloudkitty_venv_tag: untagged cloudkitty_venv_tag: untagged
cloudkitty_venv_bin: "/openstack/venvs/cloudkitty-{{ cloudkitty_venv_tag }}/bin" cloudkitty_bin: "/openstack/venvs/cloudkitty-{{ cloudkitty_venv_tag }}/bin"
# Set this to enable or disable installing in a venv
cloudkitty_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.
cloudkitty_bin: "{{ cloudkitty_venv_bin }}"
cloudkitty_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/cloudkitty.tgz cloudkitty_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/cloudkitty.tgz

View File

@@ -0,0 +1,5 @@
---
upgrade:
- Installation of cloudkitty and its dependent pip packages will now only
occur within a Python virtual environment. The ``cloudkitty_venv_bin``
and ``cloudkitty_venv_enabled`` variables have been removed.

View File

@@ -79,7 +79,6 @@
get_md5: False get_md5: False
when: when:
- not cloudkitty_developer_mode | bool - not cloudkitty_developer_mode | bool
- cloudkitty_venv_enabled | bool
register: local_venv_stat register: local_venv_stat
tags: tags:
- cloudkitty-install - cloudkitty-install
@@ -91,7 +90,6 @@
return_content: True return_content: True
when: when:
- not cloudkitty_developer_mode | bool - not cloudkitty_developer_mode | bool
- cloudkitty_venv_enabled | bool
register: remote_venv_checksum register: remote_venv_checksum
tags: tags:
- cloudkitty-install - cloudkitty-install
@@ -111,7 +109,6 @@
register: get_venv register: get_venv
when: when:
- not cloudkitty_developer_mode | bool - not cloudkitty_developer_mode | bool
- cloudkitty_venv_enabled | bool
- (local_venv_stat.stat.exists == False or - (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 }}) {{ local_venv_stat.stat.checksum is defined and local_venv_stat.stat.checksum != remote_venv_checksum.content | trim }})
tags: tags:
@@ -121,17 +118,15 @@
- name: Set cloudkitty get_venv fact - name: Set cloudkitty get_venv fact
set_fact: set_fact:
cloudkitty_get_venv: "{{ get_venv }}" cloudkitty_get_venv: "{{ get_venv }}"
when: cloudkitty_venv_enabled | bool
tags: tags:
- cloudkitty-install - cloudkitty-install
- cloudkitty-pip-packages - cloudkitty-pip-packages
- name: Remove existing venv - name: Remove existing venv
file: file:
path: "{{ cloudkitty_venv_bin | dirname }}" path: "{{ cloudkitty_bin | dirname }}"
state: absent state: absent
when: when:
- cloudkitty_venv_enabled | bool
- cloudkitty_get_venv | changed - cloudkitty_get_venv | changed
tags: tags:
- cloudkitty-install - cloudkitty-install
@@ -139,12 +134,9 @@
- name: Create cloudkitty venv dir - name: Create cloudkitty venv dir
file: file:
path: "{{ cloudkitty_venv_bin | dirname }}" path: "{{ cloudkitty_bin | dirname }}"
state: directory state: directory
when: register: cloudkitty_venv_dir
- not cloudkitty_developer_mode | bool
- cloudkitty_venv_enabled | bool
- cloudkitty_get_venv | changed
tags: tags:
- cloudkitty-install - cloudkitty-install
- cloudkitty-pip-packages - cloudkitty-pip-packages
@@ -152,34 +144,22 @@
- name: Unarchive pre-built venv - name: Unarchive pre-built venv
unarchive: unarchive:
src: "/var/cache/{{ cloudkitty_venv_download_url | basename }}" src: "/var/cache/{{ cloudkitty_venv_download_url | basename }}"
dest: "{{ cloudkitty_venv_bin | dirname }}" dest: "{{ cloudkitty_bin | dirname }}"
copy: "no" copy: "no"
when: when:
- not cloudkitty_developer_mode | bool - not cloudkitty_developer_mode | bool
- cloudkitty_venv_enabled | bool - cloudkitty_get_venv | changed or cloudkitty_venv_dir | changed
- cloudkitty_get_venv | changed
notify: notify:
- Restart cloudkitty services - Restart cloudkitty services
tags: tags:
- cloudkitty-install - cloudkitty-install
- cloudkitty-pip-packages - cloudkitty-pip-packages
- name: Update virtualenv path - name: Install pip packages
command: >
virtualenv-tools --update-path=auto {{ cloudkitty_venv_bin | dirname }}
when:
- not cloudkitty_developer_mode | bool
- cloudkitty_venv_enabled | bool
- cloudkitty_get_venv | success
tags:
- cloudkitty-install
- cloudkitty-pip-packages
- name: Install pip packages (venv)
pip: pip:
name: "{{ item }}" name: "{{ item }}"
state: latest state: latest
virtualenv: "{{ cloudkitty_venv_bin | dirname }}" virtualenv: "{{ cloudkitty_bin | dirname }}"
virtualenv_site_packages: "no" virtualenv_site_packages: "no"
extra_args: "{{ pip_install_options_fact }}" extra_args: "{{ pip_install_options_fact }}"
register: install_packages register: install_packages
@@ -188,7 +168,6 @@
delay: 2 delay: 2
with_items: cloudkitty_pip_packages with_items: cloudkitty_pip_packages
when: when:
- cloudkitty_venv_enabled | bool
- cloudkitty_get_venv | failed or cloudkitty_developer_mode | bool - cloudkitty_get_venv | failed or cloudkitty_developer_mode | bool
notify: notify:
- Restart cloudkitty services - Restart cloudkitty services
@@ -196,21 +175,12 @@
- cloudkitty-install - cloudkitty-install
- cloudkitty-pip-packages - cloudkitty-pip-packages
- name: Install pip packages (no venv) - name: Update virtualenv path
pip: command: >
name: "{{ item }}" virtualenv-tools --update-path=auto {{ cloudkitty_bin | dirname }}
state: latest
extra_args: "{{ pip_install_options_fact }}"
register: install_packages
until: install_packages|success
retries: 5
delay: 2
with_items: cloudkitty_pip_packages
when: when:
- not cloudkitty_developer_mode | bool - not cloudkitty_developer_mode | bool
- not cloudkitty_venv_enabled | bool - cloudkitty_get_venv | success
notify:
- Restart cloudkitty services
tags: tags:
- cloudkitty-install - cloudkitty-install
- cloudkitty-pip-packages - cloudkitty-pip-packages

View File

@@ -41,19 +41,3 @@
- Restart cloudkitty services - Restart cloudkitty services
tags: tags:
- cloudkitty-config - cloudkitty-config
- name: Get cloudkitty command path
command: which cloudkitty
register: cloudkitty_command_path
when:
- not cloudkitty_venv_enabled | bool
tags:
- cloudkitty-command-bin
- name: Set cloudkitty command path
set_fact:
cloudkitty_bin: "{{ cloudkitty_command_path.stdout | dirname }}"
when:
- not cloudkitty_venv_enabled | bool
tags:
- cloudkitty-command-bin

View File

@@ -48,17 +48,6 @@
tags: tags:
- cloudkitty-dirs - cloudkitty-dirs
- name: Create cloudkitty venv dir
file:
path: "{{ item.path }}"
state: directory
with_items:
- { path: "/openstack/venvs" }
- { path: "{{ cloudkitty_venv_bin | dirname }}" }
when: cloudkitty_venv_enabled | bool
tags:
- cloudkitty-dirs
- name: Test for log directory or link - name: Test for log directory or link
shell: | shell: |
if [ -h "/var/log/cloudkitty" ]; then if [ -h "/var/log/cloudkitty" ]; then

View File

@@ -23,9 +23,7 @@ chown {{ system_user }}:{{ system_group }} "/var/run/{{ program_name }}"
mkdir -p "/var/lock/{{ program_name }}" mkdir -p "/var/lock/{{ program_name }}"
chown {{ system_user }}:{{ system_group }} "/var/lock/{{ program_name }}" chown {{ system_user }}:{{ system_group }} "/var/lock/{{ program_name }}"
{% if cloudkitty_venv_enabled | bool -%} . {{ cloudkitty_bin }}/activate
. {{ cloudkitty_venv_bin }}/activate
{%- endif %}
end script end script