Skip to content

Commit

Permalink
Merge pull request #24 from geerlingguy/kporras07-feature/systemd-sys…
Browse files Browse the repository at this point in the history
…tems

Kporras07 feature/systemd systems
  • Loading branch information
arknoll authored Jan 3, 2017
2 parents 626310f + bde2be7 commit c207c8a
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .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 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 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 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 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 c207c8a

Please sign in to comment.