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

[WIP]Separate installer for telemetry #342

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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: v1.1.0
Expand Down
4 changes: 2 additions & 2 deletions ansible/group_vars/osdsdock.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ dummy:
# Change it according to your backend, currently support 'lvm', 'ceph', 'cinder', 'nfs', 'netapp_ontap_san', 'netapp_ontap_nas'
# 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'
#COMMENT THIS "dock_endpoint" if you want to install on MULTI-NODE and mention it in "local.hosts" file
dock_endpoint: localhost # **For multinodes dock-point should be mentioned in local.hosts file and THIS SHOULD BE COMMENTED
dock_port: 50050
dock_port: 50062
dock_type: provisioner

###########
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 }}:50060"
controller_endpoint: "{{ host_ip }}:50061"

# 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 }}/telemetryapi.log"
controller_log_file: "{{ opensds_log_dir }}/telemetryctl.log"
dock_log_file: "{{ opensds_log_dir }}/telemetrydock.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
8 changes: 4 additions & 4 deletions ansible/roles/osdsdock/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,20 @@
- { option: driver, value: "{{ db_driver }}" }
become: yes

- name: run osdsdock daemon service
- name: run telemetrydock daemon service
shell:
cmd: |
i=0
while
i="$((i+1))"
[ "$i" -lt 4 ]
do
nohup bin/osdsdock > osdsdock.out 2> osdsdock.err < /dev/null &
nohup bin/telemetrydock > telemetrydock.out 2> telemetrydock.err < /dev/null &
sleep 5
ps aux | grep osdsdock | grep -v grep && break
ps aux | grep telemetrydock | 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 {{ hotpot_work_dir }}/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 telemetryctl daemon service
shell:
cmd: |
i=0
while
i="$((i+1))"
[ "$i" -lt 4 ]
do
nohup bin/telemetryctl > telemetryctl.out 2> telemetryctl.err < /dev/null &
sleep 5
ps aux | grep telemetryctl | grep -v grep && break
done
args:
chdir: "{{ telemetry_work_dir }}"

- name: run telemetryapi daemon service
shell:
cmd: |
i=0
while
i="$((i+1))"
[ "$i" -lt 4 ]
do
nohup bin/telemetryapi > telemetryapi.out 2> telemetryapi.err < /dev/null &
sleep 5
ps aux | grep telemetryapi | grep -v grep && break
done
args:
chdir: "{{ telemetry_work_dir }}"
Loading