Skip to content

Commit

Permalink
Merge pull request #461 from joseph-v/delfin-containerized
Browse files Browse the repository at this point in the history
Add installer support for delfin containerized deployment
  • Loading branch information
kumarashit authored Jun 22, 2021
2 parents 955b368 + 5fad922 commit 827cb2b
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 29 deletions.
8 changes: 7 additions & 1 deletion ansible/group_vars/delfin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ venv: "{{ delfin_work_dir }}/venv"
delfin_redis_ip: 127.0.0.1
delfin_redis_port: 26379

delfin_rabbitmq_user: delfinuser
delfin_rabbitmq_pass: delfinpass

# Configurable Perf collection interval in seconds
performance_collection_interval: 900

# Exporter configurations for Kafka, Prometheus & Alert Manager
# Uncomment exporters to enable
performance_exporters: #PerformanceExporterPrometheus, PerformanceExporterKafka
Expand All @@ -49,7 +55,7 @@ delfin_exporter_kafka_topic: 'delfin-kafka'
# Exporter configurations for Prometheus
delfin_exporter_prometheus_ip: 0.0.0.0
delfin_exporter_prometheus_port: 8195
delfin_exporter_prometheus_cache_file: '/var/lib/delfin/delfin_exporter.txt'
delfin_exporter_prometheus_metrics_dir: '/var/lib/delfin/metrics'

# Exporter configurations for Alert Manager
delfin_exporter_alertmanager_host: 'localhost'
Expand Down
9 changes: 9 additions & 0 deletions ansible/roles/cleaner/scenarios/delfin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
# limitations under the License.

---
- name: Stop delfin containers, if started
shell: "{{ item }}"
with_items:
- docker-compose down
become: yes
ignore_errors: yes
args:
chdir: "{{ delfin_work_dir }}"

- name: Get running delfin processes
shell: "ps -ef | grep -v grep | grep -i 'python3 /opt/delfin-linux-amd64/delfin/' | awk '{print $2}'"
register: running_processes
Expand Down
23 changes: 23 additions & 0 deletions ansible/roles/delfin-installer/scenarios/container.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright 2021 The OpenSDS Authors.
#
# 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: build and install delfin using containerized deployment
shell: "{{ item }}"
with_items:
- docker build -t sodafoundation/delfin .
- DELFIN_METRICS_DIR={{ delfin_exporter_prometheus_metrics_dir }} DELFIN_HOST_IP={{ host_ip }} DELFIN_RABBITMQ_USER={{ delfin_rabbitmq_user }} DELFIN_RABBITMQ_PASS={{ delfin_rabbitmq_pass }} docker-compose up -d
become: yes
args:
chdir: "{{ delfin_work_dir }}"
65 changes: 38 additions & 27 deletions ansible/roles/delfin-installer/scenarios/source-code.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
dest: "{{ delfin_work_dir }}"
version: "{{ delfin_repo_branch }}"
when:
- delfin_installation_type == "repository"
- delfin_installation_type != "release"
- delfinexisted.stat.exists is undefined or delfinexisted.stat.exists == false

- name: ensure delfin directory exists
Expand Down Expand Up @@ -56,38 +56,32 @@
- delfin_installation_type == "release"
- delfinexisted.stat.exists is undefined or delfinexisted.stat.exists == false

- name: Create delfin config dir in host
file:
path: "{{ delfin_config_dir }}"
state: directory
mode: 0755
become: yes

- name: copy delfin configs to host
copy:
src: "{{ delfin_work_dir }}/etc/delfin/{{ item }}"
dest: "{{ delfin_config_dir }}/{{ item }}"
mode: 0755
become: yes
with_items:
- delfin.conf
- api-paste.ini

- name: Update redis ip & port configuration
ini_file:
create: no
path: "{{ delfin_config_dir }}/delfin.conf"
path: "{{ delfin_work_dir }}/etc/delfin/delfin.conf"
section: coordination
option: backend_server
value: "{{ delfin_redis_ip }}:{{ delfin_redis_port }}"
become: yes
when: delfin_installation_type != "container"

# Telemetry option for perf collection interval
- name: Update Performance collection interval
ini_file:
create: no
path: "{{ delfin_work_dir }}/etc/delfin/delfin.conf"
section: TELEMETRY
option: performance_collection_interval
value: "{{ performance_collection_interval }}"
become: yes

# Performance Export Configurations
- name: Check and remove performance exporters configs
ini_file:
create: no
state: absent
path: "{{ delfin_config_dir }}/delfin.conf"
path: "{{ delfin_work_dir }}/etc/delfin/delfin.conf"
section: DEFAULT
option: performance_exporters
value: ""
Expand All @@ -98,7 +92,7 @@
- name: Enable Performance Exporter configuration
ini_file:
create: no
path: "{{ delfin_config_dir }}/delfin.conf"
path: "{{ delfin_work_dir }}/etc/delfin/delfin.conf"
section: DEFAULT
option: "{{ item.option }}"
value: "{{ item.value }}"
Expand All @@ -112,7 +106,7 @@
- name: Update Kafka Exporter configuration
ini_file:
create: no
path: "{{ delfin_config_dir }}/delfin.conf"
path: "{{ delfin_work_dir }}/etc/delfin/delfin.conf"
section: KAFKA_EXPORTER
option: "{{ item.option }}"
value: "{{ item.value }}"
Expand All @@ -129,14 +123,14 @@
- name: Update Prometheus Exporter configuration
ini_file:
create: no
path: "{{ delfin_config_dir }}/delfin.conf"
path: "{{ delfin_work_dir }}/etc/delfin/delfin.conf"
section: PROMETHEUS_EXPORTER
option: "{{ item.option }}"
value: "{{ item.value }}"
with_items:
- { option: metric_server_ip, value: "{{ delfin_exporter_prometheus_ip }}" }
- { option: metric_server_port, value: "{{ delfin_exporter_prometheus_port }}" }
- { option: metric_server_file, value: "{{ delfin_exporter_prometheus_cache_file }}" }
- { option: metrics_dir, value: "{{ delfin_exporter_prometheus_metrics_dir }}" }
become: yes
when:
- performance_exporters != None
Expand All @@ -147,7 +141,7 @@
ini_file:
create: no
state: absent
path: "{{ delfin_config_dir }}/delfin.conf"
path: "{{ delfin_work_dir }}/etc/delfin/delfin.conf"
section: DEFAULT
option: alert_exporters
value: ""
Expand All @@ -158,7 +152,7 @@
- name: Enable AlertManager Exporter configuration
ini_file:
create: no
path: "{{ delfin_config_dir }}/delfin.conf"
path: "{{ delfin_work_dir }}/etc/delfin/delfin.conf"
section: DEFAULT
option: "{{ item.option }}"
value: "{{ item.value }}"
Expand All @@ -171,7 +165,7 @@
- name: Update AlertManager Exporter configuration
ini_file:
create: no
path: "{{ delfin_config_dir }}/delfin.conf"
path: "{{ delfin_work_dir }}/etc/delfin/delfin.conf"
section: PROMETHEUS_ALERT_MANAGER_EXPORTER
option: "{{ item.option }}"
value: "{{ item.value }}"
Expand All @@ -182,3 +176,20 @@
when:
- alert_exporters != None
- "'AlertExporterPrometheus' in alert_exporters"

- name: Create delfin config dir in host
file:
path: "{{ delfin_config_dir }}"
state: directory
mode: 0755
become: yes

- name: copy delfin configs to host
copy:
src: "{{ delfin_work_dir }}/etc/delfin/{{ item }}"
dest: "{{ delfin_config_dir }}/{{ item }}"
mode: 0755
become: yes
with_items:
- delfin.conf
- api-paste.ini
5 changes: 4 additions & 1 deletion ansible/roles/delfin-installer/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@

- name: Get delfin source code
include_tasks: scenarios/source-code.yml
when: delfin_installation_type != "container"

- name: Start delfin processes
include_tasks: scenarios/start-delfin.yml
when: delfin_installation_type != "container"

- name: containerized delfin deployment
include_tasks: scenarios/container.yml
when: delfin_installation_type == "container"

0 comments on commit 827cb2b

Please sign in to comment.