Skip to content

Commit c300f78

Browse files
author
arknoll
committed
Add selenium and firefox to vm.
1 parent 3a4ebb1 commit c300f78

File tree

4 files changed

+94
-1
lines changed

4 files changed

+94
-1
lines changed

meta/main.yml

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ galaxy_info:
66
license: Apache V2
77
min_ansible_version: 1.3
88
platforms:
9+
- name: EL
10+
versions:
11+
- 6
12+
- 7
913
- name: Ubuntu
1014
versions:
1115
- all

tasks/main.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,17 @@
1313
with_items:
1414
- xvfb
1515
- firefox
16+
when: ansible_os_family == 'Debian'
17+
18+
- name: Install browser
19+
yum: name={{item}}
20+
with_items:
21+
- xorg-x11-server-Xvfb
22+
- firefox
23+
when: ansible_os_family == 'RedHat'
1624

1725
- name: install
18-
template: src=init.j2 dest=/etc/init.d/selenium owner=root group=root mode=0755
26+
template: src=selenium-init-{{ ansible_os_family }}.j2 dest=/etc/init.d/selenium owner=root group=root mode=0755
1927
tags: [configuration, selenium, selenium-install]
2028

2129
- name: run
File renamed without changes.

templates/selenium-init-RedHat.j2

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#!/bin/bash
2+
#
3+
# Selenium
4+
#
5+
# chkconfig: 345 90 25
6+
# description: Selenium service
7+
8+
# Source function library.
9+
. /etc/init.d/functions
10+
11+
java_bin=/usr/bin/java
12+
13+
xvfb_bin=/usr/bin/xvfb-run
14+
15+
selenium_dir={{ selenium_install_dir }}/selenium
16+
selenium_jar_file="$selenium_dir/selenium-server-standalone-{{ selenium_version }}.jar"
17+
user=root
18+
exec="$xvfb_bin $java_bin"
19+
args=" -client -jar $selenium_jar_file"
20+
lockfile="/var/lock/subsys/selenium"
21+
pidfile="$selenium_dir/selenium.pid"
22+
logfile="$selenium_dir/selenium.log"
23+
prog="selenium"
24+
display=":1"
25+
port="4444"
26+
27+
RETVAL=0
28+
29+
start() {
30+
echo -n $"Starting $prog: "
31+
32+
touch $pidfile
33+
chown $user $pidfile
34+
35+
touch $logfile
36+
chown $user $logfile
37+
38+
/bin/su - $user -c "DISPLAY=\"$display\" $exec $args >> $logfile 2>&1 & echo \$! > $pidfile"
39+
40+
sleep 2
41+
42+
pgrep -fl $prog
43+
RETVAL=$?
44+
[ $RETVAL -eq 0 ] && echo_success || echo_failure
45+
46+
return $RETVAL
47+
}
48+
49+
stop() {
50+
echo -n $"Stopping $prog: "
51+
killproc -p $pidfile $prog
52+
RETVAL=$?
53+
echo
54+
[ $RETVAL -eq 0 ] && rm -f $lockfile $pidfile
55+
return $RETVAL
56+
}
57+
58+
restart() {
59+
stop
60+
sleep 2
61+
start
62+
}
63+
64+
case "$1" in
65+
start)
66+
start
67+
;;
68+
stop)
69+
stop
70+
;;
71+
status)
72+
status -p ${pidfile} ${prog}
73+
RETVAL=$?
74+
;;
75+
restart)
76+
restart
77+
;;
78+
*)
79+
echo $"Usage: $0 {start|stop|restart}"
80+
exit 1
81+
esac

0 commit comments

Comments
 (0)