Skip to content

Commit

Permalink
Fix playbook to handle non-existant groups in inventory,labeling
Browse files Browse the repository at this point in the history
This commit modifies labeling of the nodes to
include the index that starts from 1 instead
of 0. This also fixes the playblook to handle
the failure when a group doesn't exist in the
inventory.
  • Loading branch information
chaitanyaenr authored and portante committed Apr 17, 2017
1 parent 9645ccb commit d96c01c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
7 changes: 5 additions & 2 deletions contrib/ansible/openshift/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Pbench Ansible
Playbook to register pbench tools on openshift cluster
Playbook to register pbench tools on openshift cluster.

### Requirements
You need to have these installed
Expand All @@ -8,8 +8,11 @@ You need to have these installed

### Tools registered
master - sar, pidstat, iostat, oc, pprof

nodes - sar, pidstat, iostat, pprof

etcd - sar, pidstat, iostat

lb - sar, pidstat, iostat

### Sample inventory
Expand All @@ -36,5 +39,5 @@ You can override the variables like
```
$ ansible-playbook -i /path/to/inventory --extra-vars '{"default_tools_interval":"30"}' pbench_register.yml
```
### labeling of nodes
### Labeling of nodes
Each node has a label, <index> associated with it. Masters are labeled with svt_master_<index>, so for the first master, the label looks like svt_master_1. Similarly nodes are labeled with svt_node_<index>, etcd with svt_etcd_<index> and lb with svt_lb_<index>. If the nodes in groups are same, for example if first master and second etcd nodes are same then the label looks like svt_master_1_etcd_2.
12 changes: 8 additions & 4 deletions contrib/ansible/openshift/pbench_register.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,23 @@
group: root
mode: 0755
- name: add masters to the file
shell: echo -e {{ item.1 }} master {{ item.0 }} svt_master_{{ item.0}} >> {{ file }}
shell: echo -e {{ item.1 }} master {{ item.0 }} >> {{ file }}
with_indexed_items:
- "{{ groups['masters'] }}"
when: groups['masters']|default([])
- name: add nodes to the file
shell: echo -e {{ item.1 }} node {{ item.0 }} svt_node_{{ item.0}} >> {{ file }}
shell: echo -e {{ item.1 }} node {{ item.0 }} >> {{ file }}
with_indexed_items:
- "{{ groups['nodes'][-1] }}"
- "{{ groups['nodes'][-2] }}"
when: groups['nodes']|default([])
- name: add etcd nodes to the file
shell: echo -e {{ item.1 }} etcd {{ item.0 }} svt_etcd_{{ item.0 }} >> {{ file }}
shell: echo -e {{ item.1 }} etcd {{ item.0 }} >> {{ file }}
with_indexed_items: "{{ groups['etcd'] }}"
when: groups['etcd']|default([])
- name: add lb to the file
shell: echo -e {{ item.1}} lb {{ item.0 }} svt_lb_{{ item.0}} >> {{ file }}
shell: echo -e {{ item.1}} lb {{ item.0 }} >> {{ file }}
with_indexed_items: "{{ groups['lb'] }}"
when: groups['lb']|default([])
- name: register tools
shell: sh /run/pbench/register.sh {{ default_tools_interval }} {{ ose_master_interval }} {{ ose_node_interval }} {{ file }}
7 changes: 4 additions & 3 deletions contrib/ansible/openshift/register.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ default_tools_interval=$1
ose_master_interval=$2
ose_node_interval=$3
file=$4
label_name=svt_
hosts=/run/pbench/register.tmp.hosts
declare -a remote
declare -a group
Expand All @@ -33,7 +34,9 @@ while read -u 9 line;do
remote_name=$(echo $line | awk -F' ' '{print $1}')
group_name=$(echo $line | awk -F' ' '{print $2}')
index_value=$(echo $line | awk -F' ' '{print $3}')
label_name=$(echo $line | awk -F' ' '{print $4}')
index_value=$(( index_value + 1 ))
# Modify the label to include group and index number to make it unique
label_name="$label_name""$group_name"_"$index_value"
remote[${#remote[@]}]=$remote_name
group[${#group[@]}]=$group_name
index[${#index[@]}]=$index_value
Expand All @@ -57,8 +60,6 @@ done
while read -u 11 line;do
remote=$(echo $line | awk -F' ' '{print $1}')
group=$(echo $line | awk -F' ' '{print $2}')
index=$(echo $line | awk -F' ' '{print $3}')
index=$(( index + 1 ))
label=$(echo $line | awk -F' ' '{print $4}')
## register tools
if [ "$group" == "master" ]; then
Expand Down

0 comments on commit d96c01c

Please sign in to comment.