Implement swift venv support
This commit conditionally allows the os_swift role to install build and deploy within a venv. This is the new default behavior of the role however the functionality can be disabled. In this PR, like all of the other venv related PRs, the `is_metal` flag was removed from the role however unlike some of the other PRs this removal required moving some of the `is_metal` logic out of the role and into the play. This was done for consistency as well as making the role more standalone. The only thing that the role should care about, in terms of installation, is whether or not to install in a venv. Change-Id: I6f5b883a853611659567bd12e8bcf572189854b7 Implements: blueprint enable-venv-support-within-the-roles Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
@@ -13,9 +13,6 @@
|
||||
# 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
|
||||
|
||||
# Enable/Disable Ceilometer
|
||||
swift_ceilometer_enabled: False
|
||||
|
||||
@@ -23,6 +20,22 @@ swift_ceilometer_enabled: False
|
||||
debug: False
|
||||
verbose: True
|
||||
|
||||
# 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 }}"
|
||||
|
||||
# Set the full path to the swift recon cron
|
||||
recon_cron_path: "{{ swift_bin }}/swift-recon-cron"
|
||||
|
||||
|
||||
## Swift User / Group
|
||||
swift_system_user_name: swift
|
||||
swift_system_group_name: swift
|
||||
@@ -138,6 +151,34 @@ swift_proxy_server_program_config_options: /etc/swift/proxy-server/proxy-server.
|
||||
# of available VCPUS to compute the number of api workers to use.
|
||||
# swift_proxy_server_workers: 16
|
||||
|
||||
# This is the storage addressed used to define the network for swift replication
|
||||
swift_storage_address: 127.0.0.1
|
||||
swift_replication_address: 127.0.0.1
|
||||
|
||||
# Basic swift configuration for the cluster
|
||||
swift: {}
|
||||
|
||||
# Example basic swift configuration for the cluster
|
||||
# swift:
|
||||
# part_power: 8
|
||||
# storage_network: 'br-storage'
|
||||
# replication_network: 'br-storage'
|
||||
# drives:
|
||||
# - name: swift1.img
|
||||
# - name: swift2.img
|
||||
# - name: swift3.img
|
||||
# mount_point: /srv
|
||||
# storage_policies:
|
||||
# - policy:
|
||||
# name: default
|
||||
# index: 0
|
||||
# default: True
|
||||
|
||||
# swift packages that must be installed before anything else
|
||||
swift_requires_pip_packages:
|
||||
- virtualenv
|
||||
- python-keystoneclient # Keystoneclient needed to OSA keystone lib
|
||||
|
||||
swift_pip_packages:
|
||||
- ceilometermiddleware
|
||||
- dnspython
|
||||
|
@@ -37,7 +37,40 @@
|
||||
- swift-install
|
||||
- swift-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:
|
||||
- "{{ swift_requires_pip_packages }}"
|
||||
tags:
|
||||
- swift-install
|
||||
- swift-pip-packages
|
||||
|
||||
- name: Install pip packages (venv)
|
||||
pip:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
virtualenv: "{{ swift_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:
|
||||
- "{{ swift_pip_packages }}"
|
||||
when: swift_venv_enabled | bool
|
||||
tags:
|
||||
- swift-install
|
||||
- swift-pip-packages
|
||||
|
||||
- name: Install pip packages (no venv)
|
||||
pip:
|
||||
name: "{{ item }}"
|
||||
state: present
|
||||
@@ -48,6 +81,7 @@
|
||||
delay: 2
|
||||
with_items:
|
||||
- "{{ swift_pip_packages }}"
|
||||
when: not swift_venv_enabled | bool
|
||||
tags:
|
||||
- swift-install
|
||||
- swift-pip-packages
|
||||
- swift-pip-packages
|
@@ -56,3 +56,19 @@
|
||||
tags:
|
||||
- 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
|
||||
|
@@ -55,7 +55,9 @@
|
||||
state: directory
|
||||
owner: "{{ item.owner|default(swift_system_user_name) }}"
|
||||
group: "{{ item.group|default(swift_system_group_name) }}"
|
||||
mode: "{{ item.mode|default('0755') }}"
|
||||
with_items:
|
||||
- { path: "/openstack", owner: "root", group: "root" }
|
||||
- { path: "/etc/sudoers.d", mode: "0750", owner: "root", group: "root" }
|
||||
- { path: "/etc/swift" }
|
||||
- { path: "/etc/swift/account-server" }
|
||||
@@ -71,6 +73,17 @@
|
||||
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
|
||||
|
@@ -47,17 +47,12 @@
|
||||
regexp: "^RSYNC_ENABLE*"
|
||||
notify: ["Ensure rsync service stopped", "Ensure rsync service running"]
|
||||
|
||||
# We need the location of swift-recon-cron
|
||||
- name: "Get location of swift-recon-cron"
|
||||
shell: which swift-recon-cron
|
||||
register: recon_cron_path
|
||||
|
||||
- name: "Setup swift-recon-cron cron job"
|
||||
cron:
|
||||
name: "swift-recon-cron run"
|
||||
minute: "*/5"
|
||||
user: "swift"
|
||||
job: "{{ recon_cron_path.stdout }} /etc/swift/object-server/object-server.conf"
|
||||
job: "{{ recon_cron_path }} /etc/swift/object-server/object-server.conf"
|
||||
cron_file: "swift_recon_cron"
|
||||
|
||||
- name: "Set ownership on mounted drives"
|
||||
|
@@ -3,13 +3,8 @@
|
||||
{% set _api_threads = ansible_processor_vcpus|default(2) // 2 %}
|
||||
{% set api_threads = _api_threads if _api_threads > 0 else 1 %}
|
||||
|
||||
{% if is_metal == true or is_metal == "True" and swift.storage_network is defined %}
|
||||
{% set storage_bridge = 'ansible_' + swift.storage_network|replace('-', '_') %}
|
||||
{% set swift_storage_address = hostvars[inventory_hostname][storage_bridge]['ipv4']['address'] %}
|
||||
{% endif %}
|
||||
|
||||
[DEFAULT]
|
||||
bind_ip = {{ swift_storage_address | default(ansible_ssh_host) }}
|
||||
bind_ip = {{ swift_storage_address }}
|
||||
bind_port = {{ swift_account_port }}
|
||||
workers = {{ swift_account_server_workers | default(api_threads) }}
|
||||
|
||||
|
@@ -3,13 +3,8 @@
|
||||
{% set _api_threads = ansible_processor_vcpus|default(2) // 2 %}
|
||||
{% set api_threads = _api_threads if _api_threads > 0 else 1 %}
|
||||
|
||||
{% if is_metal == true or is_metal == "True" and swift.storage_network is defined %}
|
||||
{% set storage_bridge = 'ansible_' + swift.storage_network|replace('-', '_') %}
|
||||
{% set swift_storage_address = hostvars[inventory_hostname][storage_bridge]['ipv4']['address'] %}
|
||||
{% endif %}
|
||||
|
||||
[DEFAULT]
|
||||
bind_ip = {{ swift_storage_address | default(ansible_ssh_host) }}
|
||||
bind_ip = {{ swift_storage_address }}
|
||||
bind_port = {{ swift_container_port }}
|
||||
workers = {{ swift_container_server_workers | default(api_threads) }}
|
||||
|
||||
|
@@ -3,13 +3,8 @@
|
||||
{% set _api_threads = ansible_processor_vcpus|default(2) // 2 %}
|
||||
{% set api_threads = _api_threads if _api_threads > 0 else 1 %}
|
||||
|
||||
{% if is_metal == true or is_metal == "True" and swift.storage_network is defined %}
|
||||
{% set storage_bridge = 'ansible_' + swift.storage_network|replace('-', '_') %}
|
||||
{% set swift_storage_address = hostvars[inventory_hostname][storage_bridge]['ipv4']['address'] %}
|
||||
{% endif %}
|
||||
|
||||
[DEFAULT]
|
||||
bind_ip = {{ swift_storage_address | default(ansible_ssh_host) }}
|
||||
bind_ip = {{ swift_storage_address }}
|
||||
bind_port = {{ swift_object_port }}
|
||||
workers = {{ swift_object_server_workers | default(api_threads) }}
|
||||
|
||||
|
@@ -1,19 +1,10 @@
|
||||
# {{ ansible_managed }}
|
||||
|
||||
{% if is_metal == true or is_metal == "True" and swift.replication_network is defined %}
|
||||
{% set repl_bridge = 'ansible_' + swift.replication_network|replace('-', '_') %}
|
||||
{% set bind_ip = hostvars[inventory_hostname][repl_bridge]['ipv4']['address'] %}
|
||||
|
||||
{% elif is_metal == true or is_metal == "True" and swift.storage_network is defined %}
|
||||
{% set storage_bridge = 'ansible_' + swift.storage_network|replace('-', '_') %}
|
||||
{% set bind_ip = hostvars[inventory_hostname][storage_bridge]['ipv4']['address'] %}
|
||||
{% endif %}
|
||||
|
||||
uid = {{ swift_system_user_name }}
|
||||
gid = {{ swift_system_group_name }}
|
||||
log file = /var/log/rsyncd.log
|
||||
pid file = /var/run/rsyncd.pid
|
||||
address = {{ bind_ip | default(ansible_ssh_host) }}
|
||||
address = {{ swift_replication_address }}
|
||||
|
||||
[account]
|
||||
max connections = 2
|
||||
|
@@ -14,7 +14,7 @@ respawn
|
||||
respawn limit 10 5
|
||||
|
||||
# Set the RUNBIN environment variable
|
||||
env RUNBIN="/usr/local/bin/{{ program_binary | default(program_name) }}"
|
||||
env RUNBIN="{{ swift_bin }}/{{ program_binary | default(program_name) }}"
|
||||
|
||||
# Change directory to service users home
|
||||
chdir "{{ service_home }}"
|
||||
@@ -26,6 +26,11 @@ 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 %}
|
||||
|
||||
end script
|
||||
|
||||
# Post stop actions
|
||||
|
Reference in New Issue
Block a user