Skip to content
This repository has been archived by the owner on Nov 17, 2024. It is now read-only.

Commit

Permalink
Fixes geerlingguy#1101: Update Selenium role to work on systemd systems.
Browse files Browse the repository at this point in the history
  • Loading branch information
geerlingguy authored and sonfd committed May 19, 2017
1 parent 70bb533 commit 8c10290
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 3 deletions.
2 changes: 1 addition & 1 deletion provisioning/requirements.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
- src: arknoll.selenium
version: 2.0.0
version: 2.1.0
- src: thom8.php-upload-progress
version: 1.0.1
- src: franklinkim.newrelic
Expand Down
6 changes: 6 additions & 0 deletions provisioning/roles/arknoll.selenium/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ env:
- distro: ubuntu1604
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
- distro: debian8
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
- distro: ubuntu1404
init: /sbin/init
run_opts: "--privileged"
Expand All @@ -27,6 +30,9 @@ script:
# Run container in detached state.
- 'sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"'

# Install dependencies.
- 'sudo docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/role_under_test/tests/requirements.yml'

# Ansible syntax check.
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check'

Expand Down
43 changes: 42 additions & 1 deletion provisioning/roles/arknoll.selenium/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,24 @@
when: selenium_install_firefox
tags: [configuration, selenium, selenium-firefox]

- name: Add Chrome key (if configured, Debian)
apt_key:
url: "https://dl-ssl.google.com/linux/linux_signing_key.pub"
state: present
when: ansible_os_family == 'Debian' and selenium_install_chrome
tags: [configuration, selenium, selenium-chrome]

- name: Add Chrome repo (if configured, Debian)
apt_repository:
repo: "deb http://dl.google.com/linux/chrome/deb/ stable main"
state: present
update_cache: yes
when: ansible_os_family == 'Debian' and selenium_install_chrome
tags: [configuration, selenium, selenium-chrome]

- name: Install Chrome (if configured, Debian)
apt:
deb: https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
name: google-chrome-stable
state: present
when: ansible_os_family == 'Debian' and selenium_install_chrome
tags: [configuration, selenium, selenium-chrome]
Expand Down Expand Up @@ -67,6 +82,32 @@
mode: 0755
tags: [configuration, selenium, selenium-install]

- name: Install systemd unit file (for systemd systems)
template:
src: "selenium-unit.j2"
dest: /etc/systemd/system/selenium.service
owner: root
group: root
mode: 0755
when: >
(ansible_distribution == 'Ubuntu' and ansible_distribution_version.split(".")[0]|int >= 16) or
(ansible_distribution == 'Debian' and ansible_distribution_version.split(".")[0]|int >= 8) or
(ansible_distribution == 'CentOS' and ansible_distribution_version.split(".")[0]|int >= 7) or
(ansible_distribution == 'Fedora')
tags: [configuration, selenium, selenium-install]

- name: Register systemd service status (for systemd systems)
shell: 'systemctl status selenium | grep "active (running)"'
when: >
(ansible_distribution == 'Ubuntu' and ansible_distribution_version.split(".")[0]|int >= 16) or
(ansible_distribution == 'Debian' and ansible_distribution_version.split(".")[0]|int >= 8) or
(ansible_distribution == 'CentOS' and ansible_distribution_version.split(".")[0]|int >= 7) or
(ansible_distribution == 'Fedora')
register: selenium_running
ignore_errors: yes
changed_when: false

- name: Ensure selenium is running
service: name=selenium state=started enabled=yes
tags: [configuration, selenium, selenium-run]
when: selenium_running.failed is defined and selenium_running.failed == true
11 changes: 11 additions & 0 deletions provisioning/roles/arknoll.selenium/templates/selenium-unit.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=selenium test framework
After=syslog.target network.target

[Service]
ExecStart=/usr/bin/xvfb-run /usr/bin/java -client -jar {{ selenium_install_dir }}/selenium/selenium-server-standalone-{{ selenium_version }}.jar
Restart=on-failure
RestartSec=20s

[Install]
WantedBy=multi-user.target
2 changes: 2 additions & 0 deletions provisioning/roles/arknoll.selenium/tests/requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
- src: geerlingguy.java
11 changes: 10 additions & 1 deletion provisioning/roles/arknoll.selenium/tests/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,17 @@

pre_tasks:
- name: Update apt cache.
apt: update_cache=yes
apt: update_cache=yes cache_valid_time=3600
when: ansible_os_family == 'Debian'

- name: Don't install Chrome on old OSes.
set_fact:
selenium_install_firefox: yes
selenium_install_chrome: no
when: >
(ansible_distribution == 'Ubuntu' and ansible_distribution_version == '12.04')
or (ansible_os_family == 'RedHat' and ansible_distribution_version.split('.')[0] == '6')
roles:
- geerlingguy.java
- role_under_test

0 comments on commit 8c10290

Please sign in to comment.