Skip to content

Commit

Permalink
Telemetry installer
Browse files Browse the repository at this point in the history
  • Loading branch information
nguptaopensds committed Mar 27, 2020
1 parent ab0beaf commit 8fd82d7
Show file tree
Hide file tree
Showing 27 changed files with 478 additions and 24 deletions.
4 changes: 2 additions & 2 deletions ansible/group_vars/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ host_ip: 127.0.0.1

# 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/nguptaopensds/telemetry.git

# 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: "/opt/opensds-telemetry-linux-amd64/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=/opt/opensds-telemetry-linux-amd64/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 /opt/opensds-telemetry-linux-amd64/volumegroups/{{ opensds_volume_group_nvme }}
sudo mount {{ lvm_nvme_device }} /opt/opensds-telemetry-linux-amd64/volumegroups/{{ opensds_volume_group_nvme }}
local backing_file=/opt/opensds-telemetry-linux-amd64/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
6 changes: 3 additions & 3 deletions ansible/roles/osdsdock/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@
i="$((i+1))"
[ "$i" -lt 4 ]
do
nohup bin/osdsdock > osdsdock.out 2> osdsdock.err < /dev/null &
nohup bin/osdsdok > osdsdok.out 2> osdsdok.err < /dev/null &
sleep 5
ps aux | grep osdsdock | grep -v grep && break
ps aux | grep osdsdok | grep -v grep && break
done
args:
chdir: "{{ hotpot_work_dir }}"
chdir: /opt/opensds-telemetry-linux-amd64
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 Expand Up @@ -61,7 +105,7 @@
path: "{{ telemetry_work_dir }}"
state: directory
when:
- telemetryfilesexisted.stat.exists is undefined or telemetryfilesexisted.stat.exists == false
- telemetryfilesexisted.stat.exists is undefined or telemetryfilesexisted.stat.exists == true

- name: download and extract the telemetry, prometheus
unarchive:
Expand All @@ -70,7 +114,7 @@
remote_src: yes
become: yes
when:
- telemetryfilesexisted.stat.exists is undefined or telemetryfilesexisted.stat.exists == False
- telemetryfilesexisted.stat.exists is undefined or telemetryfilesexisted.stat.exists == true

- name: download and extract the telemetry, node_exporter
unarchive:
Expand All @@ -79,7 +123,7 @@
remote_src: yes
become: yes
when:
- telemetryfilesexisted.stat.exists is undefined or telemetryfilesexisted.stat.exists == False
- telemetryfilesexisted.stat.exists is undefined or telemetryfilesexisted.stat.exists == true

- name: download and extract the telemetry, pushgateway
unarchive:
Expand All @@ -88,7 +132,7 @@
remote_src: yes
become: yes
when:
- telemetryfilesexisted.stat.exists is undefined or telemetryfilesexisted.stat.exists == False
- telemetryfilesexisted.stat.exists is undefined or telemetryfilesexisted.stat.exists == true

- name: download and extract the telemetry, alertmanager
unarchive:
Expand All @@ -97,7 +141,7 @@
remote_src: yes
become: yes
when:
- telemetryfilesexisted.stat.exists is undefined or telemetryfilesexisted.stat.exists == False
- telemetryfilesexisted.stat.exists is undefined or telemetryfilesexisted.stat.exists == true

- name: install prometheus
shell: "{{ item }}"
Expand Down Expand Up @@ -241,6 +285,7 @@
- cp /opt/opensds-hotpot-linux-amd64/bin/lvm_exporter /usr/local/bin/
- chown root:root /usr/local/bin/lvm_exporter
become: yes
ignore_errors: yes

- name: edit lvm_exporter.service
shell: "{{ item }}"
Expand All @@ -266,6 +311,7 @@
with_items:
- systemctl status lvm_exporter
become: yes
ignore_errors: yes

- name: configuring prometheus to scrape lvm_exporter
tags:
Expand All @@ -290,6 +336,8 @@
with_items:
- systemctl status prometheus
become: yes
ignore_errors: yes

# ---------start to install alertmanager---------
- name: install alertmanager
shell: "{{ item }}"
Expand Down Expand Up @@ -371,4 +419,4 @@
with_items:
- systemctl start grafana-server
- systemctl status grafana-server
become: yes
become: yes
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 }}"
Loading

0 comments on commit 8fd82d7

Please sign in to comment.