diff --git a/defaults/main.yml b/defaults/main.yml index 79cd0f85..6f275890 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -29,15 +29,7 @@ swift_developer_constraints: # Name of the virtual env to deploy into swift_venv_tag: untagged -swift_venv_bin: "/openstack/venvs/swift-{{ swift_venv_tag }}/bin" - -# Set this to enable or disable installing in a venv -swift_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. -swift_bin: "{{ swift_venv_bin }}" +swift_bin: "/openstack/venvs/swift-{{ swift_venv_tag }}/bin" swift_venv_download_url: http://127.0.0.1/venvs/untagged/ubuntu/swift.tgz diff --git a/releasenotes/notes/os_swift-only-install-venv-fdd5d41759433cf8.yaml b/releasenotes/notes/os_swift-only-install-venv-fdd5d41759433cf8.yaml new file mode 100644 index 00000000..14e76d3f --- /dev/null +++ b/releasenotes/notes/os_swift-only-install-venv-fdd5d41759433cf8.yaml @@ -0,0 +1,5 @@ +--- +upgrade: + - Installation of swift and its dependent pip packages will now only + occur within a Python virtual environment. The ``swift_venv_enabled``, + ``swift_venv_bin`` variables have been removed. diff --git a/tasks/main.yml b/tasks/main.yml index dc1d5c3d..5fd8eee9 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -85,12 +85,6 @@ tags: - swift-setup -- include: swift_command_check.yml - when: - - swift_do_sync | bool - tags: - - swift-sync - - include: swift_key_setup.yml when: - swift_do_sync | bool diff --git a/tasks/swift_command_check.yml b/tasks/swift_command_check.yml deleted file mode 100644 index 56ac4bb4..00000000 --- a/tasks/swift_command_check.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -# Copyright 2015, 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. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -- name: Get swift command path - command: which swift - register: swift_command_path - when: - - not swift_venv_enabled | bool - tags: - - swift-command-bin - -- name: Set swift command path - set_fact: - swift_bin: "{{ swift_command_path.stdout | dirname }}" - when: - - not swift_venv_enabled | bool - tags: - - swift-command-bin diff --git a/tasks/swift_install.yml b/tasks/swift_install.yml index 36e46cc0..2d517550 100644 --- a/tasks/swift_install.yml +++ b/tasks/swift_install.yml @@ -84,7 +84,6 @@ when: - not swift_pypy_enabled | bool - not swift_developer_mode | bool - - swift_venv_enabled | bool register: local_venv_stat tags: - swift-install @@ -97,7 +96,6 @@ when: - not swift_pypy_enabled | bool - not swift_developer_mode | bool - - swift_venv_enabled | bool register: remote_venv_checksum tags: - swift-install @@ -118,7 +116,6 @@ when: - not swift_pypy_enabled | bool - not swift_developer_mode | bool - - swift_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: @@ -128,18 +125,16 @@ - name: Set swift get_venv fact set_fact: swift_get_venv: "{{ get_venv }}" - when: swift_venv_enabled | bool tags: - swift-install - swift-pip-packages - name: Remove existing venv file: - path: "{{ swift_venv_bin | dirname }}" + path: "{{ swift_bin | dirname }}" state: absent when: - not swift_pypy_enabled | bool - - swift_venv_enabled | bool - swift_get_venv | changed tags: - swift-install @@ -147,13 +142,9 @@ - name: Create swift venv dir file: - path: "{{ swift_venv_bin | dirname }}" + path: "{{ swift_bin | dirname }}" state: directory - when: - - not swift_pypy_enabled | bool - - not swift_developer_mode | bool - - swift_venv_enabled | bool - - swift_get_venv | changed + register: swift_venv_dir tags: - swift-install - swift-pip-packages @@ -161,13 +152,36 @@ - name: Unarchive pre-built venv unarchive: src: "/var/cache/{{ swift_venv_download_url | basename }}" - dest: "{{ swift_venv_bin | dirname }}" + dest: "{{ swift_bin | dirname }}" copy: "no" when: - not swift_pypy_enabled | bool - not swift_developer_mode | bool - - swift_venv_enabled | bool - - swift_get_venv | changed + - swift_get_venv | changed or swift_venv_dir | changed + notify: + - Restart swift account services + - Restart swift container services + - Restart swift object services + - Restart swift proxy services + tags: + - swift-install + - swift-pip-packages + +- name: Install pip packages + pip: + name: "{{ item }}" + state: latest + virtualenv: "{{ swift_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: swift_pip_packages + when: + - not swift_pypy_enabled | bool + - swift_get_venv | failed or swift_developer_mode | bool notify: - Restart swift account services - Restart swift container services @@ -179,64 +193,15 @@ - name: Update virtualenv path command: > - virtualenv-tools --update-path=auto {{ swift_venv_bin | dirname }} + virtualenv-tools --update-path=auto {{ swift_bin | dirname }} when: - not swift_pypy_enabled | bool - not swift_developer_mode | bool - - swift_venv_enabled | bool - swift_get_venv | success tags: - swift-install - swift-pip-packages -- name: Install pip packages (venv) - pip: - name: "{{ item }}" - state: latest - virtualenv: "{{ swift_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: swift_pip_packages - when: - - not swift_pypy_enabled | bool - - swift_venv_enabled | bool - - swift_get_venv | failed or swift_developer_mode | bool - notify: - - Restart swift account services - - Restart swift container services - - Restart swift object services - - Restart swift proxy services - tags: - - swift-install - - swift-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: swift_pip_packages - when: - - not swift_pypy_enabled | bool - - not swift_developer_mode | bool - - not swift_venv_enabled | bool - notify: - - Restart swift account services - - Restart swift container services - - Restart swift object services - - Restart swift proxy services - tags: - - swift-install - - swift-pip-packages - - include: swift_pypy_setup.yml when: swift_pypy_enabled | bool tags: diff --git a/tasks/swift_post_install.yml b/tasks/swift_post_install.yml index 65859ae6..c23d1c3b 100644 --- a/tasks/swift_post_install.yml +++ b/tasks/swift_post_install.yml @@ -62,18 +62,3 @@ - swift-config - swift-post-install -- name: Get swift command path - command: which swift - register: swift_command_path - when: - - not swift_venv_enabled | bool - tags: - - swift-command-bin - -- name: Set swift command path - set_fact: - swift_bin: "{{ swift_command_path.stdout | dirname }}" - when: - - not swift_venv_enabled | bool - tags: - - swift-command-bin diff --git a/tasks/swift_pre_install.yml b/tasks/swift_pre_install.yml index 0f5bf3a9..cbdaa805 100644 --- a/tasks/swift_pre_install.yml +++ b/tasks/swift_pre_install.yml @@ -73,17 +73,6 @@ tags: - swift-dirs -- name: Create swift venv dir - file: - path: "{{ item.path }}" - state: directory - with_items: - - { path: "/openstack/venvs" } - - { path: "{{ swift_venv_bin }}" } - when: swift_venv_enabled | bool - tags: - - swift-dirs - - name: Test for log directory or link shell: | if [ -h "/var/log/swift" ]; then diff --git a/tasks/swift_pypy_setup.yml b/tasks/swift_pypy_setup.yml index 2da90bb4..8142d2bd 100644 --- a/tasks/swift_pypy_setup.yml +++ b/tasks/swift_pypy_setup.yml @@ -51,13 +51,13 @@ - name: Check for pypy venv stat: - path: "{{ swift_venv_bin | dirname }}/{{ swift_pypy_version }}-inuse" + path: "{{ swift_bin | dirname }}/{{ swift_pypy_version }}-inuse" get_md5: False register: local_pypy_venv_stat - name: Remove existing venv if not pypy setup file: - path: "{{ swift_venv_bin | dirname }}" + path: "{{ swift_bin | dirname }}" state: absent when: not local_pypy_venv_stat.stat.exists | bool @@ -65,7 +65,7 @@ pip: name: "{{ item }}" state: latest - virtualenv: "{{ swift_venv_bin | dirname }}" + virtualenv: "{{ swift_bin | dirname }}" virtualenv_site_packages: "no" virtualenv_command: "{{ swift_pypy_env | dirname }}/virtualenv" extra_args: "{{ pip_install_options_fact }}" @@ -82,5 +82,5 @@ - name: Mark swift venv for use with pypy file: - path: "{{ swift_venv_bin | dirname }}/{{ swift_pypy_version }}-inuse" + path: "{{ swift_bin | dirname }}/{{ swift_pypy_version }}-inuse" state: "touch" diff --git a/tasks/swift_storage_hosts_object.yml b/tasks/swift_storage_hosts_object.yml index 2cc5462f..dd68226c 100644 --- a/tasks/swift_storage_hosts_object.yml +++ b/tasks/swift_storage_hosts_object.yml @@ -147,7 +147,7 @@ - name: Create drive-audit cron job cron: name: "Run drive-audit script" - job: "{{ swift_venv_bin }}/swift-drive-audit /etc/swift/drive-audit.conf" + job: "{{ swift_bin }}/swift-drive-audit /etc/swift/drive-audit.conf" minute: 15 cron_file: swift-drive-audit user: root diff --git a/templates/swift-upstart-init.j2 b/templates/swift-upstart-init.j2 index 1ba55521..77bcc940 100644 --- a/templates/swift-upstart-init.j2 +++ b/templates/swift-upstart-init.j2 @@ -26,9 +26,7 @@ pre-start script mkdir -p "/var/lock/{{ program_binary | default(program_name) }}" chown {{ system_user }}:{{ system_group }} "/var/lock/{{ program_binary | default(program_name) }}" - {% if swift_venv_enabled | bool -%} - . {{ swift_venv_bin }}/activate - {%- endif %} + . {{ swift_bin }}/activate end script diff --git a/templates/swift_rings.py.j2 b/templates/swift_rings.py.j2 index 30a9922b..8ea7f1a3 100644 --- a/templates/swift_rings.py.j2 +++ b/templates/swift_rings.py.j2 @@ -1,4 +1,4 @@ -#!{{ swift_venv_enabled | bool | ternary(swift_venv_bin + "/", "/usr/bin/env ") }}python +#!{{ swift_bin }}/python # Copyright 2014, Rackspace US, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/templates/swift_rings_check.py.j2 b/templates/swift_rings_check.py.j2 index 50ced583..5441a0d7 100644 --- a/templates/swift_rings_check.py.j2 +++ b/templates/swift_rings_check.py.j2 @@ -1,4 +1,4 @@ -#!{{ swift_venv_enabled | bool | ternary(swift_venv_bin + "/", "/usr/bin/env ") }}python +#!{{ swift_bin }}/python # Copyright 2014, Rackspace US, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/tests/test-swift-functional.yml b/tests/test-swift-functional.yml index fa7e4f02..8595ae8b 100644 --- a/tests/test-swift-functional.yml +++ b/tests/test-swift-functional.yml @@ -101,7 +101,7 @@ - name: Install requirements for swift pip: requirements: "{{ item }}" - virtualenv: "{{ swift_venv_bin | dirname }}" + virtualenv: "{{ swift_bin | dirname }}" with_items: - "/opt/swift/test-requirements.txt" - "/opt/swift/requirements.txt" diff --git a/tests/test-vars.yml b/tests/test-vars.yml index 84679e25..a6afe5c9 100644 --- a/tests/test-vars.yml +++ b/tests/test-vars.yml @@ -73,7 +73,7 @@ swift_service_password: "secrete" swift_developer_mode: true swift_git_install_branch: master swift_venv_tag: untagged -swift_venv_bin: "/openstack/venvs/swift-{{ swift_venv_tag }}/bin" +swift_bin: "/openstack/venvs/swift-{{ swift_venv_tag }}/bin" swift_service_publicuri: "http://10.100.100.102:8080" swift_service_adminuri: "http://10.100.100.102:8080" swift_service_internaluri: "http://10.100.100.102:8080"