Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TVAULT-3311: Improve the deployment of TrilioVault to OpenStack-Ansible environments by using Ansible to automate as much as possible #343

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
86 changes: 18 additions & 68 deletions ansible/environments/group_vars/all/vars.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
##common editable parameters required for installing horizon,contego,tvault-config
#ip address and port no for tvault applicance

RABBITMQ_PASSWORD: rabbit_pass
DMAPI_SERVICE_PASSWORD: dmapi_service_pass
DMAPI_MYSQL_PASSWORD: dmpai_mysql_pass

IP_ADDRESS: sample_tvault_ip_address
PORT_NO: 8085
#Need to update python version of openstack setup Example PYTHON_VERSION: python2 or PYTHON_VERSION: python3
PYTHON_VERSION: python2
PYPI_PORT: 8081

#Time Zone
TIME_ZONE: "Etc/UTC"

#Update TVAULT package version here, we will install mentioned version plugins for Example# TVAULT_PACKAGE_VERSION: 3.3.36
TVAULT_PACKAGE_VERSION: 3.3.36
DEBIAN_PACKAGE_REPO_URL: "deb [trusted=yes] https://apt.fury.io/triliodata-3-3/ /"
RPM_PACKAGE_REPO_URL: "http://trilio:[email protected]:8283/triliovault-3.3/yum/"
TVAULT_PACKAGE_VERSION: 4.1.4

#Need to add the following statement in nova sudoers file
#nova ALL = (root) NOPASSWD: /home/tvault/.virtenv/bin/privsep-helper *
Expand All @@ -18,30 +24,8 @@ RPM_PACKAGE_REPO_URL: "http://trilio:[email protected]:8283/triliovau
UPDATE_NOVA_SUDOERS_FILE: notproceed

#Set verbisity level and run playbooks with -vv option to display custom debug messages
verbosity_level: 2

#Details for Nova Compute filter
#specify NOVA_COMPUTE_FILTERS_FILE
#For Debian: /etc/nova/rootwrap.d/compute.filters
#For RHEL : /usr/share/nova/rootwrap/compute.filters
NOVA_COMPUTE_FILTERS_FILE: /usr/share/nova/rootwrap/compute.filters
verbosity_level: 3

#Name of web server service that openstack horizon node uses
#For Debian: apache2
#For RHEL: httpd
WebServer: sample_webservice

#Specify opestack dashboard path based on type of operating system of controller node
#For Debian/RHEL: /usr/share/openstack-dashboard
#For SUSE: /srv/www/openstack-dashboard
HORIZON_PATH: /usr/share/openstack-dashboard

#specify openstack's nova api service name
#For Debian: nova-api
#For RHEL : openstack-nova-api
nova_api_service: sample_name_of_nova_api_service
vault_keystone_swift_username: sample_swift_username
vault_keystone_swift_password: sample_swift_password
##### Select snapshot storage type #####
#Details for NFS as snapshot storage , NFS_SHARES should begin with "-".
NFS: False
Expand All @@ -50,16 +34,6 @@ NFS_SHARES:
- sample_nfs_server_ip2:sample_share_path
NFS_OPTS: ""

#### Details for Swift as snapshot storage
Swift: False
VAULT_SWIFT_AUTH_URL: sample_vault_swift_url
VAULT_SWIFT_TENANT: sample_vault_swift_tenant
VAULT_SWIFT_USERNAME: sample_vault_swift_username
VAULT_SWIFT_PASSWORD: sample_vault_swift_password
VAULT_SWIFT_DOMAIN_ID: sample_swift_domain_id
### TEMPAUTH / KEYSTONEV2/ KEYSTONEV3(Provide one of them value in VAULT_SWIFT_AUTH_VERSION1 variable)
VAULT_SWIFT_AUTH_VERSION1: sample_auth_version

#### Details for S3 as snapshot storage
S3: False
VAULT_S3_ACCESS_KEY: sample_s3_access_key
Expand All @@ -74,19 +48,22 @@ s3_type: sample_s3_type
#### Required field(s) for all S3 backends except Amazon
VAULT_S3_ENDPOINT_URL: sample_s3_endpoint_url
VAULT_S3_SECURE: False
VAULT_S3_SSL_CERT: sample_s3_ssl_cert


###details of datamover API
datamover_url: sample_datamover_url
dmapi_enabled_ssl_apis: ""
ssl_cert_file: ""
ssl_key_file: ""

#******************************************************************************************************************************************************************
###static fields for tvault contego extension ,Please Do not Edit Below Variables
#******************************************************************************************************************************************************************
DMAPI_USR: dmapi
DMAPI_GRP: dmapi
#tvault contego file path
TVAULT_CONTEGO_CONF: /etc/tvault-contego/tvault-contego.conf
TVAULT_OBJECT_STORE_CONF: /etc/tvault-object-store/tvault-object-store.conf
NOVA_CONF_FILE: /etc/nova/nova.conf
#Nova distribution specific configuration file path
NOVA_DIST_CONF_FILE: /usr/share/nova/nova-dist.conf
Expand All @@ -104,49 +81,22 @@ TVAULT_CONTEGO_EXT_BACKEND_TYPE: ""
TVAULT_CONTEGO_EXT_SWIFT: "{{TVAULT_CONTEGO_VIRTENV_PATH}}/lib/python2.7/site-packages/contego/nova/extension/driver/vaultfuse.py"
TVAULT_CONTEGO_EXT_S3: "{{TVAULT_CONTEGO_VIRTENV_PATH}}/lib/python2.7/site-packages/contego/nova/extension/driver/s3vaultfuse.py"
privsep_helper_file: /home/tvault/.virtenv/bin/privsep-helper
python_path: /usr/bin/python
pip_version: 7.1.2
virsh_version: "1.2.8"
contego_service_file_path: /etc/systemd/system/tvault-contego.service
contego_service_ulimits_count: 65536
contego_service_debian_path: /etc/init/tvault-contego.conf
objstore_service_file_path: /etc/systemd/system/tvault-object-store.service
objstore_service_debian_path: /etc/init/tvault-object-store.conf
mitaka: "mitaka"
newton: "newton"
premitaka: "premitaka"
queens: "queens"
gtliberty: "gtliberty"
status_200: "200"
status_201: "201"
xenial: "xenial"
willy: "willy"
bionic: "bionic"
release_13: "13"
release_2000: "2000"
release_2016: "2016"
ubuntu: "Ubuntu"
centos: "CentOS"
redhat: "RedHat"
suse: "Suse"
SLES: "SLES"
Amazon: "Amazon"
Other_S3_Compatible: "Other_S3_Compatible"
Ceph_S3: "Ceph_S3"
Minio_S3: "Minio_S3"
TEMPAUTH: "TEMPAUTH"
KEYSTONEV2: "KEYSTONEV2"
KEYSTONEV3: "KEYSTONEV3"
KEYSTONE: "KEYSTONE"
virtenv_newton_script_path: /tmp/set_virtenv_newton.sh
virtenv_mitaka_script_path: /tmp/set_virtenv_mitaka.sh
virtenv_premitaka_script_path: /tmp/set_virtenv_premitaka.sh
tvault_datamover_api: tvault-datamover-api
release_16: "16"
datamover_service_file_path: /etc/systemd/system/tvault-datamover-api.service
tvault_datmover_python: /usr/bin/python
datamover_service_debian_path: /etc/init/tvault-datamover.conf
datamover_log_dir: /var/log/dmapi
trilio_yum_repo_file_path: /etc/yum.repos.d/trilio.repo
trilio_apt_repo_file_path: /etc/apt/sources.list.d/trilio.list
release_17: "17"


25 changes: 19 additions & 6 deletions ansible/main-install.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
---
- hosts: horizon
roles:
- hosts: horizon_all
roles:
- role: ansible-horizon-plugin

- hosts: controller
- name: Installation and setup of dmapi conatiner
hosts: dmapi_all
gather_facts: "{{ osa_gather_facts | default(True) }}"
user: root
environment: "{{ deployment_environment_variables | default({}) }}"
vars_files:
- "defaults/repo_packages/openstack_services.yml"
- "defaults/{{ install_method }}_install.yml"
pre_tasks:
- include_tasks: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
when: not is_metal

- include_tasks: common-tasks/unbound-clients.yml
when:
- hostvars['localhost']['resolvconf_enabled'] | bool
roles:
- role: ansible-datamover-api

- hosts: compute
roles:
- hosts: tvault_compute_host
roles:
- role: ansible-tvault-contego-extension
3 changes: 2 additions & 1 deletion ansible/roles/ansible-horizon-plugin/files/sync_static.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import settings
import subprocess
ls = settings.openstack_dashboard.settings.INSTALLED_APPS
ls = settings.INSTALLED_APPS

data = ""
for app in ls:
if app != 'dashboards':
Expand Down
5 changes: 0 additions & 5 deletions ansible/roles/ansible-horizon-plugin/files/sync_static1.py

This file was deleted.

3 changes: 3 additions & 0 deletions ansible/roles/ansible-horizon-plugin/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
---
- name: restart webserver
service: name={{WebServer}} state=restarted

- name: update timezone
command: dpkg-reconfigure --frontend noninteractive tzdata
39 changes: 33 additions & 6 deletions ansible/roles/ansible-horizon-plugin/tasks/collect_compress.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,42 @@
---
- debug:
msg: "{{ MANAGE_FILE }}"

- name: Collect static files for horizon
command: "{{ MANAGE_FILE }} collectstatic --noinput"
verbosity: 3
shell: "{{virtual_env}} && {{PYTHON_VERSION}} {{ MANAGE_FILE }} collectstatic --noinput"
notify:
- restart webserver

- name: compress the collected files
command: "{{ MANAGE_FILE }} compress --force"
verbosity: 3
shell: "{{virtual_env}} && nohup {{PYTHON_VERSION}} {{ MANAGE_FILE }} compress --force"
rohit-keshri marked this conversation as resolved.
Show resolved Hide resolved
retries: 3
delay: 3
register: compress_result
until: compress_result.rc == 0
notify:
- restart webserver

- name: write content into destination file - sync_static.py
template: src="sync_static.py" dest="/tmp/sync_static.py"

- name: Change the working directory to horizon and excute shell command
shell: "{{virtual_env}} && {PYTHON_VERSION}} {{ MANAGE_FILE }} shell < /tmp/sync_static.py &> /dev/null"
args:
chdir: "{{HORIZON_PATH}}"
notify:
- restart webserver

- name: remove temporary file - sync_static.py
file: path=/tmp/sync_static.py state=absent

- name: Get os_local_settings_path
shell: find / -type d -path /sys -prune -o -name "*local_settings.d" 2>/dev/null | grep -E 'openstack_dashboard|horizon'
register: os_local_settings_path

- name: HORIZON_CONFIG
shell: . /openstack/venvs/horizon*/bin/activate && echo "HORIZON_CONFIG['customization_module'] = 'dashboards.overrides'" > `echo $os_local_settings_path | cut -d ' ' -f1 |{ read trilio_setting_path ; echo $trilio_setting_path/_001_trilio_dashboard.py ; }`
when: os_local_settings_path != ""

- debug:
msg: "\033[33m WARNING: Unable to locate local_settings.d on system. Trilio quota feature on dashboard may not work. \033[0m"
verbosity: "{{ verbosity_level }}"
when: os_local_settings_path == ""

12 changes: 5 additions & 7 deletions ansible/roles/ansible-horizon-plugin/tasks/find_manage_file.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
---
- name: find venv is using or not
shell: "{{ PYTHON_VERSION }} -c 'import sys; print(sys.prefix)'"
register: ENVPATH

- set_fact:
ENV_PATH : "{{ENVPATH.stdout}}"

- name: find location of manage.py
shell: "find {{ ENV_PATH }} -name '*manage.py' | grep -E 'openstack-dashboard|horizon'"
shell: "find {{ ENV_PATH }} -name '*manage.py' | grep -E 'openstack-dashboard|horizon|bin'"
register: output

- set_fact:
MANAGE_FILE : "{{output.stdout}}"

- debug:
msg: "manage.py is found at :{{MANAGE_FILE}}"
verbosity: "{{ verbosity_level }}"
23 changes: 23 additions & 0 deletions ansible/roles/ansible-horizon-plugin/tasks/get_venv.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
- set_fact:
virtual_env: ". /openstack/venvs/horizon*/bin/activate"

- name: Find ENVPATH
shell: "{{virtual_env}} && {{ PYTHON_VERSION }} -c 'import sys; print(sys.prefix)'"
register: ENVPATH

- set_fact:
ENV_PATH : "{{ENVPATH.stdout}}"
- debug:
msg: "{{ENV_PATH}}"
verbosity: "{{ verbosity_level }}"

- set_fact:
EXTRA_APT_VAR : "--no-install-recommends"
when: ENV_PATH != "/usr"

- set_fact:
EXTRA_APT_VAR : ""
when: ENV_PATH == "/usr"


17 changes: 13 additions & 4 deletions ansible/roles/ansible-horizon-plugin/tasks/install_rhel.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,29 @@
yum:
update_cache: yes
name:
- python-workloadmgrclient
- tvault-horizon-plugin
state: latest
notify:
- restart webserver
when: PYTHON_VERSION=="python2"

- name: install tvault horizon plugin packages when using python3
- name: install tvault horizon plugin packages when using python3 ansible_distribution_major_version=="7"
yum:
update_cache: yes
name:
- python3-workloadmgrclient
- python3-workloadmgrclient-el7
- python3-tvault-horizon-plugin
state: latest
notify:
- restart webserver
when: PYTHON_VERSION=="python3"
when: PYTHON_VERSION=="python3" and ansible_distribution_major_version=="7"

- name: install tvault horizon plugin packages when using python3 ansible_distribution_major_version=="8"
yum:
update_cache: yes
name:
- python3-tvault-horizon-plugin
state: latest
notify:
- restart webserver
when: PYTHON_VERSION=="python3" and ansible_distribution_major_version=="8"
32 changes: 24 additions & 8 deletions ansible/roles/ansible-horizon-plugin/tasks/install_ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,42 @@
---
- name: create apt repo file
template:
src: trilio.list
dest: "{{trilio_apt_repo_file_path}}"

- name: Install Tzdata package
shell: export DEBIAN_FRONTEND=noninteractive && apt install -y tzdata

- name: Set Time Zone
file:
src: '/usr/share/zoneinfo/{{TIME_ZONE}}'
dest: /etc/localtime
owner: root
group: root
state: link
ignore_errors: yes
when: TIME_ZONE != ""
notify:
- update timezone

- name: Install Curl Package
apt:
name: curl
state: latest
update_cache: yes

- name: install tvault-horizon-plugin and python-workloadmgrclient deb packages when using python2
shell: |
curl -Og6 http://{{ IP_ADDRESS }}:{{ PORT_NO }}/deb-repo/deb-repo/python-workloadmgrclient_{{ TVAULT_PACKAGE_VERSION }}_all.deb
apt-get install ./python-workloadmgrclient_{{ TVAULT_PACKAGE_VERSION }}_all.deb -y $EXTRA_APT_VAR
apt-get install ./python-workloadmgrclient_{{ TVAULT_PACKAGE_VERSION }}_all.deb -y {{EXTRA_APT_VAR}}
rm -rf python-workloadmgrclient_{{ TVAULT_PACKAGE_VERSION }}_all.deb
curl -Og6 http://{{ IP_ADDRESS }}:{{ PORT_NO }}/deb-repo/deb-repo/tvault-horizon-plugin_{{ TVAULT_PACKAGE_VERSION }}_all.deb
apt-get install ./tvault-horizon-plugin_{{ TVAULT_PACKAGE_VERSION }}_all.deb -y $EXTRA_APT_VAR
apt-get install ./tvault-horizon-plugin_{{ TVAULT_PACKAGE_VERSION }}_all.deb -y {{EXTRA_APT_VAR}}
rm -rf tvault-horizon-plugin_{{ TVAULT_PACKAGE_VERSION }}_all.deb
when: PYTHON_VERSION=="python2"

- name: install python3-tvault-horizon-plugin and python3-workloadmgrclient deb packages when using python3
shell: |
curl -Og6 http://{{ IP_ADDRESS }}:{{ PORT_NO }}/deb-repo/deb-repo/python3-workloadmgrclient_{{ TVAULT_PACKAGE_VERSION }}_all.deb
apt-get install ./python3-workloadmgrclient_{{ TVAULT_PACKAGE_VERSION }}_all.deb -y $EXTRA_APT_VAR
apt-get install ./python3-workloadmgrclient_{{ TVAULT_PACKAGE_VERSION }}_all.deb -y {{EXTRA_APT_VAR}}
rm -rf python3-workloadmgrclient_{{ TVAULT_PACKAGE_VERSION }}_all.deb
curl -Og6 http://{{ IP_ADDRESS }}:{{ PORT_NO }}/deb-repo/deb-repo/python3-tvault-horizon-plugin_{{ TVAULT_PACKAGE_VERSION }}_all.deb
apt-get install ./python3-tvault-horizon-plugin_{{ TVAULT_PACKAGE_VERSION }}_all.deb -y $EXTRA_APT_VAR
apt-get install ./python3-tvault-horizon-plugin_{{ TVAULT_PACKAGE_VERSION }}_all.deb -y {{EXTRA_APT_VAR}}
rm -rf python3-tvault-horizon-plugin_{{ TVAULT_PACKAGE_VERSION }}_all.deb
when: PYTHON_VERSION=="python3"
Loading