Skip to content

Commit

Permalink
Telemetry installer
Browse files Browse the repository at this point in the history
  • Loading branch information
nguptaopensds committed Mar 18, 2020
1 parent ab0beaf commit 19259ba
Show file tree
Hide file tree
Showing 27 changed files with 477 additions and 17 deletions.
6 changes: 3 additions & 3 deletions ansible/group_vars/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ dummy:
###########

# This field indicates local machine host ip
host_ip: 127.0.0.1
host_ip: 192.168.1.12

# This field indicates which project should be deploy
# 'hotpot', 'gelato' or 'all'
deploy_project: all
deploy_project: telemetry

# This field indicates which way user prefers to install, currently support
# 'repository', 'release' and 'container'
install_from: release
install_from: repository
# These fields below will specify the tag based on install_from type
repo_branch: master
release_version: v0.10.0
Expand Down
2 changes: 1 addition & 1 deletion ansible/group_vars/osdsdock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dummy:
# Change it according to your backend, currently support 'lvm', 'ceph', 'cinder', 'nfs', 'netapp_ontap_san'
# DISABLE OR COMMENT "enabled_backends: lvm" IF YOU WANT TO INSTALL DIFFERENT BACKENDS ON MULTI-NODES AND mention it in "local.hosts" file
# Comment this part if you want to use different backends on different nodes
enabled_backends: lvm,nfs #For Multi-backend add backends here, for eg. enabled_backends: lvm,ceph,cinder,nfs
enabled_backends: lvm #For Multi-backend add backends here, for eg. enabled_backends: lvm,ceph,cinder,nfs

# Change it according to your node type (host or target), currently support
# 'provisioner', 'attacher'
Expand Down
26 changes: 23 additions & 3 deletions ansible/group_vars/telemetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,30 @@ dummy:
###########
# GENERAL #
###########
apiserver_endpoint: "{{ host_ip }}:50040"
controller_endpoint: "{{ host_ip }}:50049"

# Do you need to install or clean up telemetry tools?
enable_telemetry_tools: false

# These fields are NOT suggested to be modified
telemetry_work_dir: /opt/opensds-telemetry-linux-amd64
opensds_config_dir: /etc/opensds
opensds_driver_config_dir: "{{ opensds_config_dir }}/driver"
opensds_log_dir: /var/log/opensds
apiserver_log_file: "{{ opensds_log_dir }}/osdsapiserver.log"
controller_log_file: "{{ opensds_log_dir }}/osdslet.log"
dock_log_file: "{{ opensds_log_dir }}/osdsdock.log"


##############
# REPOSITORY #
##############

# If user specifies intalling from repository, then he can choose the specific
# repository branch
telemetry_repo_branch: "{{ repo_branch }}"

# These fields are NOT suggested to be modified
telemetry_remote_url: https://github.com/NajmudheenCT/telemetry

# Grafana Repository config
grafana_repositroy: "deb https://packages.grafana.com/oss/deb stable main"
Expand Down Expand Up @@ -50,4 +71,3 @@ kafka_endpoint: '{{ host_ip }}:9092'
kafka_topic: metrics

opensds_conf_file: /etc/opensds/opensds.conf
telemetry_work_dir: /opt/opensds-telemetry-linux-amd64
10 changes: 5 additions & 5 deletions ansible/roles/osdsdock/scenarios/lvm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

- name: create directory to volume group file
file:
path: "{{ hotpot_work_dir }}/volumegroups"
path: "{{ telemetry_work_dir }}/volumegroups"
state: directory
recurse: yes

Expand All @@ -63,7 +63,7 @@
local vg=$1
local size=$2
local backing_file={{ hotpot_work_dir }}/volumegroups/${vg}.img
local backing_file={{ telemetry_work_dir }}/volumegroups/${vg}.img
if ! sudo vgs $vg; then
# Only create if the file doesn't already exists
[[ -f $backing_file ]] || truncate -s $size $backing_file
Expand All @@ -87,9 +87,9 @@
if [[ -e {{ lvm_nvme_device }} ]]; then
local vg={{ opensds_volume_group_nvme }}
local size={{ opensds_volume_group_nvme_size }}
sudo mkdir -p {{ hotpot_work_dir }}/volumegroups/{{ opensds_volume_group_nvme }}
sudo mount {{ lvm_nvme_device }} {{ hotpot_work_dir }}/volumegroups/{{ opensds_volume_group_nvme }}
local backing_file={{ hotpot_work_dir }}/volumegroups/{{ opensds_volume_group_nvme }}/${vg}.img
sudo mkdir -p {{ telemetry_work_dir }}/volumegroups/{{ opensds_volume_group_nvme }}
sudo mount {{ lvm_nvme_device }} {{ telemetry_work_dir }}/volumegroups/{{ opensds_volume_group_nvme }}
local backing_file={{ telemetry_work_dir }}/volumegroups/{{ opensds_volume_group_nvme }}/${vg}.img
if ! sudo vgs $vg; then
# Only create if the file doesn't already exists
[[ -f $backing_file ]] || truncate -s $size $backing_file
Expand Down
2 changes: 1 addition & 1 deletion ansible/roles/osdsdock/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
ps aux | grep osdsdock | grep -v grep && break
done
args:
chdir: "{{ hotpot_work_dir }}"
chdir: "{{ telemetry_work_dir }}"
when:
- install_from != "container"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,50 @@

---
# ----Stop all services to all ansible re-run in case of failure-----
- set_fact:
go_path: "/root/gopath"

- name: check go_path
shell: "{{ item }}"
with_items:
- echo "The environment variable GOPATH must be set and cannot be an empty string!"
- /bin/false
when: go_path == ""

- name: check for telemetry source code existed
stat:
path: "{{ go_path }}/src/github.com/sodafoundation/telemetry"
register: telemetryexisted

- name: download telemetry source code if not exists
git:
repo: "{{ telemetry_remote_url }}"
dest: "{{ go_path }}/src/github.com/sodafoundation/telemetry"
version: "{{ telemetry_repo_branch }}"
when: telemetryexisted.stat.exists is undefined or telemetryexisted.stat.exists == false

- name: build telemetry binary file
shell: make
environment:
GOPATH: "{{ go_path }}"
args:
chdir: "{{ go_path }}/src/github.com/sodafoundation/telemetry"

- name: copy telemetry binary and openapi files into telemetry work directory
copy:
src: "{{ item.src }}"
dest: "{{ item.dest }}"
with_items:
- { src: "{{ go_path }}/src/github.com/sodafoundation/telemetry/build/out/", dest: "{{ telemetry_work_dir }}" }
- { src: "{{ go_path }}/src/github.com/opensds/opensds/openapi-spec/", dest: "{{ telemetry_work_dir }}" }

- name: change the permissions of telemetry executable files
file:
path: "{{ telemetry_work_dir }}/bin"
state: directory
mode: 0755
recurse: yes

- name: stop all services
shell: "{{ item }}"
with_items:
Expand Down
44 changes: 44 additions & 0 deletions ansible/roles/telemetry-installer/scenarios/source-code.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2019 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: run osdslet daemon service
shell:
cmd: |
i=0
while
i="$((i+1))"
[ "$i" -lt 4 ]
do
nohup bin/osdslet > osdslet.out 2> osdslet.err < /dev/null &
sleep 5
ps aux | grep osdslet | grep -v grep && break
done
args:
chdir: "{{ telemetry_work_dir }}"

- name: run osdsapiserver daemon service
shell:
cmd: |
i=0
while
i="$((i+1))"
[ "$i" -lt 4 ]
do
nohup bin/osdsapiserver > osdsapiserver.out 2> osdsapiserver.err < /dev/null &
sleep 5
ps aux | grep osdsapiserver | grep -v grep && break
done
args:
chdir: "{{ telemetry_work_dir }}"
193 changes: 190 additions & 3 deletions ansible/roles/telemetry-installer/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,194 @@
# limitations under the License.

---
- name: include scenarios/install_telemetry_tools.yml
tags:
- telemetry
- name: set script dir permissions
file:
path: ./script
mode: 0755
recurse: yes
become: yes

- name: check ansible version
shell: "{{ item }}"
with_items:
- bash ./script/check_ansible_version.sh
become: yes

- name: run the equivalent of "apt-get update" as a separate step
apt:
update_cache: yes

- name: install system packages
package:
name: "{{ item }}"
state: present
with_items:
- make
- gcc
- python-pip
- open-iscsi

- name: install requests package with pip
pip:
name: requests

- name: install Ubuntu system packages
package:
name: "{{ item }}"
state: present
with_items:
- librados-dev
- librbd-dev
when: ansible_os_family == "Debian" and deploy_project == "telemetry"

- name: create telemetry work directory if it doesn't exist
file:
path: "{{ item }}"
state: directory
mode: 0755
with_items:
- "{{ telemetry_work_dir }}"
- "{{ opensds_config_dir }}"
- "{{ opensds_driver_config_dir }}"
- "{{ opensds_log_dir }}"
when: deploy_project == "telemetry"

- name: copy config templates into opensds global config folder
copy:
src: ../../../../conf/
dest: "{{ opensds_config_dir }}"
when: deploy_project == "telemetry"

- name: generate certificates
shell: "{{ item }}"
with_items:
- bash ./script/create_cert.sh "{{ opensds_certs_dir }}"
become: yes

- name: hotpot keystone configuration when keystone is installed by docker
shell: "{{ item }}"
with_items:
- bash ./script/keystone.sh config hotpot docker
when: opensds_auth_strategy == "keystone" and install_keystone_with_docker == true
become: yes

- name: configure openapi specification
copy:
src: "/opt/opensds-hotpot-linux-amd64/swagger.yaml"
dest: "{{ opensds_config_dir }}"
become: yes
ignore_errors: true

# ---------update opensds config file with opensds global info---------
- name: configure opensds global info osdslet
ini_file:
path: "{{ opensds_conf_file }}"
section: osdslet
option: "{{ item.option }}"
value: "{{ item.value }}"
with_items:
- { option: api_endpoint, value: "{{ controller_endpoint }}" }
- { option: log_file, value: "{{ controller_log_file }}" }
become: yes

- name: configure opensds global info osdsapiserver
ini_file:
create: no
path: "{{ opensds_conf_file }}"
section: osdsapiserver
option: "{{ item.option }}"
value: "{{ item.value }}"
with_items:
- { option: api_endpoint, value: "{{ apiserver_endpoint }}" }
- { option: log_file, value: "{{ apiserver_log_file }}" }
- { option: auth_strategy, value: "{{ opensds_auth_strategy }}" }
- { option: https_enabled, value: False }
- { option: beego_https_cert_file, value: "" }
- { option: beego_https_key_file, value: "" }
become: yes

- name: configure opensds global info database
ini_file:
create: no
path: "{{ opensds_conf_file }}"
section: database
option: "{{ item.option }}"
value: "{{ item.value }}"
with_items:
- { option: endpoint, value: "{{ db_endpoint }}" }
- { option: driver, value: "{{ db_driver }}" }
become: yes

# ---------update opensds config file with telemtetry configs---------
- name: Set opensds.conf with telemetry options in osdsapiserver
ini_file:
create: no
path: "{{ opensds_conf_file }}"
section: osdsapiserver
option: "{{ item.option }}"
value: "{{ item.value }}"
with_items:
- { option: prometheus_conf_home, value: "{{ prometheus_conf_home }}" }
- { option: prometheus_url, value: "{{ prometheus_url }}" }
- { option: prometheus_conf_file, value: "{{ prometheus_conf_file }}" }
- { option: alertmgr_conf_home, value: "{{ alertmgr_conf_home }}" }
- { option: alertmgr_url, value: "{{ alertmgr_url }}" }
- { option: alertmgr_conf_file, value: "{{ alertmgr_conf_file }}" }
- { option: grafana_conf_home, value: "{{ grafana_conf_home }}" }
- { option: grafana_restart_cmd, value: "{{ grafana_restart_cmd }}" }
- { option: grafana_conf_file, value: "{{ grafana_conf_file }}" }
- { option: grafana_url, value: "{{ grafana_url }}" }
- { option: conf_reload_url, value: "{{ conf_reload_url }}" }
become: yes
tags: telemetry_conf

- name: Set opensds.conf with telemetry options in osdslet
ini_file:
create: no
path: "{{ opensds_conf_file }}"
section: osdslet
option: "{{ item.option }}"
value: "{{ item.value }}"
with_items:
- { option: prometheus_push_mechanism, value: "{{ prometheus_push_mechanism }}" }
- { option: kafka_endpoint, value: "{{ kafka_endpoint }}" }
- { option: kafka_topic, value: "{{ kafka_topic }}" }
- { option: alertmgr_url, value: "{{ alertmgr_url }}" }
- { option: grafana_url, value: "{{ grafana_url }}" }
become: yes
tags: telemetry_conf

- name: Set push mechanism when NodeExporter is selected
ini_file:
create: no
path: "{{ opensds_conf_file }}"
section: osdslet
option: "{{ item.option }}"
value: "{{ item.value }}"
with_items:
- { option: node_exporter_watch_folder, value: "{{ node_exporter_watch_folder }}" }
become: yes
when: prometheus_push_mechanism == 'NodeExporter'
tags: telemetry_conf

- name: Set push mechanism when PushGateway is selected
ini_file:
create: no
path: "{{ opensds_conf_file }}"
section: osdslet
option: "{{ item.option }}"
value: "{{ item.value }}"
with_items:
- { option: prometheus_push_gateway_url, value: "{{ prometheus_push_gateway_url }}" }
become: yes
when: prometheus_push_mechanism == 'PushGateway'
tags: telemetry_conf

- name: include scenarios/repository.yml when installing from repository
include: scenarios/install_telemetry_tools.yml
when: install_from == "repository" and deploy_project == "telemetry"

- name: include scenarios/source-code.yml when not installing from container
include: scenarios/source-code.yml
when: install_from != "container"

Empty file modified ansible/script/check_ceph_exist.sh
100644 → 100755
Empty file.
Empty file modified ansible/script/check_ceph_version.sh
100644 → 100755
Empty file.
Empty file modified ansible/script/create_cert.sh
100644 → 100755
Empty file.
Empty file modified ansible/script/global_vars.sh
100644 → 100755
Empty file.
Loading

0 comments on commit 19259ba

Please sign in to comment.