Skip to content

Commit

Permalink
Add selenium and firefox to vm.
Browse files Browse the repository at this point in the history
  • Loading branch information
arknoll committed Jul 10, 2015
1 parent 3a4ebb1 commit c300f78
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 1 deletion.
4 changes: 4 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ galaxy_info:
license: Apache V2
min_ansible_version: 1.3
platforms:
- name: EL
versions:
- 6
- 7
- name: Ubuntu
versions:
- all
Expand Down
10 changes: 9 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,17 @@
with_items:
- xvfb
- firefox
when: ansible_os_family == 'Debian'

- name: Install browser
yum: name={{item}}
with_items:
- xorg-x11-server-Xvfb
- firefox
when: ansible_os_family == 'RedHat'

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

- name: run
Expand Down
File renamed without changes.
81 changes: 81 additions & 0 deletions templates/selenium-init-RedHat.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
#!/bin/bash
#
# Selenium
#
# chkconfig: 345 90 25
# description: Selenium service

# Source function library.
. /etc/init.d/functions

java_bin=/usr/bin/java

xvfb_bin=/usr/bin/xvfb-run

selenium_dir={{ selenium_install_dir }}/selenium
selenium_jar_file="$selenium_dir/selenium-server-standalone-{{ selenium_version }}.jar"
user=root
exec="$xvfb_bin $java_bin"
args=" -client -jar $selenium_jar_file"
lockfile="/var/lock/subsys/selenium"
pidfile="$selenium_dir/selenium.pid"
logfile="$selenium_dir/selenium.log"
prog="selenium"
display=":1"
port="4444"

RETVAL=0

start() {
echo -n $"Starting $prog: "

touch $pidfile
chown $user $pidfile

touch $logfile
chown $user $logfile

/bin/su - $user -c "DISPLAY=\"$display\" $exec $args >> $logfile 2>&1 & echo \$! > $pidfile"

sleep 2

pgrep -fl $prog
RETVAL=$?
[ $RETVAL -eq 0 ] && echo_success || echo_failure

return $RETVAL
}

stop() {
echo -n $"Stopping $prog: "
killproc -p $pidfile $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $lockfile $pidfile
return $RETVAL
}

restart() {
stop
sleep 2
start
}

case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} ${prog}
RETVAL=$?
;;
restart)
restart
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac

0 comments on commit c300f78

Please sign in to comment.