Skip to content
This repository has been archived by the owner on Oct 10, 2021. It is now read-only.

Commit

Permalink
Merge pull request #2 from jonathangreen/tests
Browse files Browse the repository at this point in the history
Add CI Testing
  • Loading branch information
dannylamb authored Feb 7, 2018
2 parents d2e6779 + 2db1335 commit 362190b
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 29 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
tests/test.sh
*.retry
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
services: docker

env:
- distro: centos7
- distro: ubuntu1604

script:
# Download test shim.
- wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/
- chmod +x ${PWD}/tests/test.sh

# Run tests.
- ${PWD}/tests/test.sh
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Ansible Role: Apache Karaf
# Ansible Role: Apache Karaf [![Build Status](https://travis-ci.org/Islandora-Devops/ansible-role-karaf.svg?branch=master)](https://travis-ci.org/Islandora-Devops/ansible-role-karaf)

An Ansible role that installs [Karaf](https://karaf.apache.org) in a Tomcat 8 servlet container on:

Expand Down Expand Up @@ -90,4 +90,4 @@ karaf_systemd_template: karaf.service

## License

MIT
MIT
6 changes: 6 additions & 0 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
karaf_java_packages: "{{ __karaf_java_packages }}"
when: karaf_java_packages is not defined

- name: Update apt cache
apt:
update_cache: yes
cache_valid_time: 600
when: ansible_os_family == "Debian"

- name: Install Java packages
package:
name: "{{ karaf_java_packages|join(',') }}"
Expand Down
7 changes: 7 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@
- karaf-logging

- include: service.yml
become: yes
become_user: "{{ karaf_user }}"
tags:
- karaf
- karaf-service

- include: systemd.yml
tags:
- karaf
- karaf-systemd
27 changes: 0 additions & 27 deletions tasks/service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
args:
chdir: "{{ karaf_install_symlink }}/bin"
creates: "{{ karaf_install_symlink }}/bin/karaf-wrapper"
become_user: "{{ karaf_user }}"
register: karaf_service_install

- name: Wait for Karaf to start
Expand All @@ -25,43 +24,17 @@
command: ./client feature:install wrapper
args:
chdir: "{{ karaf_install_symlink }}/bin"
become_user: "{{ karaf_user }}"
when: karaf_service_install.changed is defined and karaf_service_install.changed

- name: Install wrapper
command: ./client wrapper:install
args:
chdir: "{{ karaf_install_symlink }}/bin"
become_user: "{{ karaf_user }}"
when: karaf_service_install.changed is defined and karaf_service_install.changed

- name: Stop Karaf
shell: >
{{ karaf_install_symlink }}/bin/stop && sleep 1
args:
chdir: "{{ karaf_install_symlink }}/bin"
become_user: "{{ karaf_user }}"
when: karaf_service_install.changed is defined and karaf_service_install.changed

- name: Copy templated Karaf definition
template:
src: "{{ karaf_systemd_template }}"
dest: "{{ karaf_install_symlink }}/bin/karaf.service"
owner: "{{ karaf_user }}"
group: "{{ karaf_user }}"

- name: Install Karaf service in systemd
command: systemctl enable {{ karaf_install_symlink }}/bin/karaf.service
args:
creates: /etc/systemd/system/karaf

- name: Start Karaf service
service:
name: karaf
state: started
register: karaf_start_karaf

- name: Wait for Karaf to start
wait_for:
port: 8101
when: karaf_start_karaf.changed
24 changes: 24 additions & 0 deletions tasks/systemd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---

- name: Copy templated Karaf definition
template:
src: "{{ karaf_systemd_template }}"
dest: "{{ karaf_install_symlink }}/bin/karaf.service"
owner: "{{ karaf_user }}"
group: "{{ karaf_user }}"

- name: Install Karaf service in systemd
command: systemctl enable {{ karaf_install_symlink }}/bin/karaf.service
args:
creates: /etc/systemd/system/karaf

- name: Start Karaf service
service:
name: karaf
state: started
register: karaf_start_karaf

- name: Wait for Karaf to start
wait_for:
port: 8101
when: karaf_start_karaf.changed
5 changes: 5 additions & 0 deletions tests/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- hosts: all

roles:
- role_under_test

0 comments on commit 362190b

Please sign in to comment.