From 30da8182561ac4b3f082b4f6055980ada6e3a825 Mon Sep 17 00:00:00 2001 From: Travis Truman Date: Thu, 7 Jul 2016 11:28:55 -0400 Subject: [PATCH] Only install to virtual environment Remove all tasks and variables related to toggling between installation of aodh 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: Icf788b07738bf03708c05929bb82c7b51605ccca Implements: blueprint only-install-venvs --- defaults/main.yml | 10 +--- ...dh-only-install-venv-3c80a0a66824fcd7.yaml | 5 ++ tasks/aodh_install.yml | 50 ++++--------------- tasks/aodh_post_install.yml | 16 ------ tasks/aodh_pre_install.yml | 11 ---- templates/aodh-upstart-init.j2 | 2 - 6 files changed, 17 insertions(+), 77 deletions(-) create mode 100644 releasenotes/notes/os_aodh-only-install-venv-3c80a0a66824fcd7.yaml diff --git a/defaults/main.yml b/defaults/main.yml index a4f24eb..802a3e7 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -26,15 +26,7 @@ aodh_developer_constraints: # Name of the virtual env to deploy into aodh_venv_tag: untagged -aodh_venv_bin: "/openstack/venvs/aodh-{{ aodh_venv_tag }}/bin" - -# Set this to enable or disable installing in a venv -aodh_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. -aodh_bin: "{{ aodh_venv_bin }}" +aodh_bin: "/openstack/venvs/aodh-{{ aodh_venv_tag }}/bin" aodh_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/aodh.tgz diff --git a/releasenotes/notes/os_aodh-only-install-venv-3c80a0a66824fcd7.yaml b/releasenotes/notes/os_aodh-only-install-venv-3c80a0a66824fcd7.yaml new file mode 100644 index 0000000..14a17b2 --- /dev/null +++ b/releasenotes/notes/os_aodh-only-install-venv-3c80a0a66824fcd7.yaml @@ -0,0 +1,5 @@ +--- +upgrade: + - Installation of aodh and its dependent pip packages will now only + occur within a Python virtual environment. The ``aodh_venv_enabled`` + and ``aodh_venv_bin`` variables have been removed. \ No newline at end of file diff --git a/tasks/aodh_install.yml b/tasks/aodh_install.yml index e0aea93..e38dfe0 100644 --- a/tasks/aodh_install.yml +++ b/tasks/aodh_install.yml @@ -83,7 +83,6 @@ get_md5: False when: - not aodh_developer_mode | bool - - aodh_venv_enabled | bool register: local_venv_stat tags: - aodh-install @@ -95,7 +94,6 @@ return_content: True when: - not aodh_developer_mode | bool - - aodh_venv_enabled | bool register: remote_venv_checksum tags: - aodh-install @@ -115,7 +113,6 @@ register: get_venv when: - not aodh_developer_mode | bool - - aodh_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: @@ -125,17 +122,15 @@ - name: Set aodh get_venv fact set_fact: aodh_get_venv: "{{ get_venv }}" - when: aodh_venv_enabled | bool tags: - aodh-install - aodh-pip-packages - name: Remove existing venv file: - path: "{{ aodh_venv_bin | dirname }}" + path: "{{ aodh_bin | dirname }}" state: absent when: - - aodh_venv_enabled | bool - aodh_get_venv | changed tags: - aodh-install @@ -143,11 +138,11 @@ - name: Create aodh venv dir file: - path: "{{ aodh_venv_bin | dirname }}" + path: "{{ aodh_bin | dirname }}" state: directory + register: aodh_venv_dir when: - not aodh_developer_mode | bool - - aodh_venv_enabled | bool - aodh_get_venv | changed tags: - aodh-install @@ -156,33 +151,21 @@ - name: Unarchive pre-built venv unarchive: src: "/var/cache/{{ aodh_venv_download_url | basename }}" - dest: "{{ aodh_venv_bin | dirname }}" + dest: "{{ aodh_bin | dirname }}" copy: "no" when: - not aodh_developer_mode | bool - - aodh_venv_enabled | bool - - aodh_get_venv | changed + - aodh_get_venv | changed or aodh_venv_dir | changed notify: Restart aodh services tags: - aodh-install - aodh-pip-packages -- name: Update virtualenv path - command: > - virtualenv-tools --update-path=auto {{ aodh_venv_bin | dirname }} - when: - - not aodh_developer_mode | bool - - aodh_venv_enabled | bool - - aodh_get_venv | success - tags: - - aodh-install - - aodh-pip-packages - -- name: Install pip packages (venv) +- name: Install pip packages pip: name: "{{ item }}" state: latest - virtualenv: "{{ aodh_venv_bin | dirname }}" + virtualenv: "{{ aodh_bin | dirname }}" virtualenv_site_packages: "no" extra_args: "{{ pip_install_options_fact }}" register: install_packages @@ -191,28 +174,17 @@ delay: 2 with_items: "{{ aodh_pip_packages }}" when: - - aodh_venv_enabled | bool - aodh_get_venv | failed or aodh_developer_mode | bool notify: Restart aodh services tags: - aodh-install - aodh-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: "{{ aodh_pip_packages }}" +- name: Update virtualenv path + command: > + virtualenv-tools --update-path=auto {{ aodh_bin | dirname }} when: - not aodh_developer_mode | bool - - not aodh_venv_enabled | bool - - notify: Restart aodh services tags: - aodh-install - - aodh-pip-packages + - aodh-pip-packages \ No newline at end of file diff --git a/tasks/aodh_post_install.yml b/tasks/aodh_post_install.yml index c319276..a25ffa0 100644 --- a/tasks/aodh_post_install.yml +++ b/tasks/aodh_post_install.yml @@ -13,22 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Get aodh command path - command: which aodh-api - register: aodh_command_path - when: - - not aodh_venv_enabled | bool - tags: - - aodh-command-bin - -- name: Set aodh command path - set_fact: - aodh_bin: "{{ aodh_command_path.stdout | dirname }}" - when: - - not aodh_venv_enabled | bool - tags: - - aodh-command-bin - - name: Copy aodh config config_template: src: "{{ item.src }}" diff --git a/tasks/aodh_pre_install.yml b/tasks/aodh_pre_install.yml index fedd315..e8eb59d 100644 --- a/tasks/aodh_pre_install.yml +++ b/tasks/aodh_pre_install.yml @@ -48,17 +48,6 @@ tags: - aodh-dirs -- name: Create aodh venv dir - file: - path: "{{ item.path }}" - state: directory - with_items: - - { path: "/openstack/venvs" } - - { path: "{{ aodh_venv_bin }}" } - when: aodh_venv_enabled | bool - tags: - - aodh-dirs - - name: Test for log directory or link shell: | if [ -h "/var/log/aodh" ]; then diff --git a/templates/aodh-upstart-init.j2 b/templates/aodh-upstart-init.j2 index 7434296..14e2035 100644 --- a/templates/aodh-upstart-init.j2 +++ b/templates/aodh-upstart-init.j2 @@ -24,9 +24,7 @@ pre-start script mkdir -p "/var/lock/{{ program_name }}" chown {{ system_user }}:{{ system_group }} "/var/lock/{{ program_name }}" - {% if aodh_venv_enabled | bool -%} . {{ aodh_bin }}/activate - {%- endif %} end script