Karan Singh

Where there's a Cloud , there's a way !!

Deploy COSBench Using Ansible

| Comments

ansible-role-cosbench

In my previous blog about COSBench , i gave an introduction to this tool and have explained how you can install it and get it working.

Recently i automated COSBench installation and configuration using ansible and have created an ansible role. With this blog i will demonstrate how you can get COSBench up and running with minimal steps … because Ansible Rocks 8-)

I have 3 nodes to set up for COSBench in the following way

  • COSBench controller node : bench-node1
  • COSBench driver node: bench-node1, bench-node2, bench-node3

  • First step, make sure ansible is installed and all nodes are reachable via ansible

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[[email protected] ~]$ ansible all -m ping  -s
bench-node3 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}
bench-node1 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}
bench-node2 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}
[[email protected] ~]$
1
2
3
4
5
6
[[email protected] ~]$ sudo ansible-galaxy install ksingh7.cosbench
 - downloading role 'cosbench', owned by ksingh7
 - downloading role from https://github.com/ksingh7/ansible-role-cosbench/archive/master.tar.gz
 - extracting ksingh7.cosbench to /etc/ansible/roles/ksingh7.cosbench
 - ksingh7.cosbench was installed successfully
[[email protected] ~]$
  • Next create an ansible inventory file where you will define cosbench controller node and cosbench driver node. Based on these host groups ansible will configure these nodes accordingly.
1
2
3
4
5
6
7
8
9
10
11
12
13
[[email protected] ~]$ cat cosbench-inventory
[cosbench-controller]
bench-node1

[cosbench-driver]
bench-node1
bench-node2
bench-node3

[cosbench:children]
cosbench-controller
cosbench-driver
[[email protected] ~]$
  • Create ansible yml file and fed cosbench ansible role to it
1
2
3
4
5
6
[[email protected] ~]$ cat cosbench_install.yml
 - hosts: cosbench
  become: true
  roles:
     - { role: ksingh7.cosbench }
[[email protected] ~]$
  • Verify using --list-hosts option
1
2
3
4
5
6
7
8
9
10
11
[[email protected] ~]$ ansible-playbook -i cosbench-inventory cosbench_install.yml --list-hosts

playbook: cosbench_install.yml

  play #1 (cosbench): cosbench    TAGS: []
    pattern: [u'cosbench']
    hosts (3):
      bench-node2
      bench-node3
      bench-node1
[[email protected] ~]$
  • Finally run ansible playbook against the inventory file
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
[[email protected] ~]$ ansible-playbook -i cosbench-inventory cosbench_install.yml

PLAY [cosbench] ****************************************************************

TASK [setup] *******************************************************************
ok: [bench-node3]
ok: [bench-node1]
ok: [bench-node2]

TASK [ksingh7.cosbench : install cosbench dependencies] ************************
changed: [bench-node3] => (item=[u'java', u'nmap-ncat', u'unzip'])
changed: [bench-node1] => (item=[u'java', u'nmap-ncat', u'unzip'])
changed: [bench-node2] => (item=[u'java', u'nmap-ncat', u'unzip'])

TASK [ksingh7.cosbench : create directory for cosbench] ************************
changed: [bench-node3]
changed: [bench-node1]
changed: [bench-node2]

TASK [ksingh7.cosbench : Downloading and extracting cosbench binaries] *********
changed: [bench-node3]
changed: [bench-node1]
changed: [bench-node2]

TASK [ksingh7.cosbench : Add executable permission] ****************************
changed: [bench-node3]
 [WARNING]: Consider using file module with mode rather than running chmod

changed: [bench-node1]
changed: [bench-node2]

TASK [ksingh7.cosbench : correcting nc parameters in cosbench startup script] **
changed: [bench-node3]
changed: [bench-node1]
changed: [bench-node2]

TASK [ksingh7.cosbench : include] **********************************************
skipping: [bench-node3]
skipping: [bench-node2]
included: /etc/ansible/roles/ksingh7.cosbench/tasks/cosbench_controller.yml for bench-node1

TASK [ksingh7.cosbench : Configuring controller configuration file] ************
changed: [bench-node1]

TASK [ksingh7.cosbench : start cosbench controller] ****************************
changed: [bench-node1]

TASK [ksingh7.cosbench : include] **********************************************
included: /etc/ansible/roles/ksingh7.cosbench/tasks/cosbench_driver.yml for bench-node1, bench-node3, bench-node2

TASK [ksingh7.cosbench : Configuring cosbench driver configuration file] *******
changed: [bench-node3]
changed: [bench-node1]
changed: [bench-node2]

TASK [ksingh7.cosbench : start cosbench driver] ********************************
changed: [bench-node3]
changed: [bench-node2]
changed: [bench-node1]

PLAY RECAP *********************************************************************
bench-node1                : ok=12   changed=6    unreachable=0    failed=0
bench-node2                : ok=9    changed=4    unreachable=0    failed=0
bench-node3                : ok=9    changed=4    unreachable=0    failed=0
  • Once ansible run is completed verify the open ports for COSBench controller and driver
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[[email protected] ~]$ sudo netstat -plunt | grep -i java
tcp        0      0 0.0.0.0:18088           0.0.0.0:*               LISTEN      396/java
tcp        0      0 0.0.0.0:18089           0.0.0.0:*               LISTEN      396/java
tcp        0      0 0.0.0.0:19088           0.0.0.0:*               LISTEN      586/java
tcp        0      0 0.0.0.0:19089           0.0.0.0:*               LISTEN      586/java
[[email protected] ~]$
[[email protected] ~]$

[[email protected] ~]$ sudo netstat -plunt | grep -i java
tcp        0      0 0.0.0.0:18088           0.0.0.0:*               LISTEN      30093/java
tcp        0      0 0.0.0.0:18089           0.0.0.0:*               LISTEN      30093/java
[[email protected] ~]$

[[email protected] ~]$ sudo netstat -plunt | grep -i java
tcp6       0      0 :::18088                :::*                    LISTEN      17874/java
tcp6       0      0 :::18089                :::*                    LISTEN      17874/java
[[email protected] ~]$

So all done, open your browser and navigate to COSBench GUI

I hope this cosbench ansible role will give you a thrust to quickly get your COSBench environment running so that you can concentrate on benchmarking ;)

Comments