Skip to content
20 changes: 15 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,19 @@ env:
version: 14.04
init: /sbin/init
run_opts: ""
site: itedd

- distribution: ubuntu
version: 12.04
init: /sbin/init
run_opts: ""
site: itedd

- distribution: ubuntu
version: 18.04
init: /sbin/init
run_opts: "--security-opt seccomp=unconfined --tmpfs /run --tmpfs /run/lock -v /sys/fs/cgroup:/sys/fs/cgroup:ro"
site: hrfilter
services:
- docker

Expand All @@ -36,17 +44,19 @@ before_install:
script:
- container_id=$(mktemp)
# Run container in detached state
- 'sudo docker run --ulimit nofile=1024 --detach --volume="${PWD}":"/etc/ansible/roles/dresden-weekly.Rails":ro ${run_opts} ${distribution}-${version}:ansible "${init}" > "${container_id}"'
- 'sudo docker run --privileged --ulimit nofile=1024 --detach --volume="${PWD}":"/etc/ansible/roles/dresden-weekly.Rails":ro ${run_opts} ${distribution}-${version}:ansible "${init}" > "${container_id}"'

# Ansible syntax check.
- 'sudo docker exec "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/dresden-weekly.Rails/tests/itedd.yml --syntax-check'
- 'sudo docker exec -e ANSIBLE_FORCE_COLOR=1 "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/dresden-weekly.Rails/tests/${site}/playbook.yml --syntax-check || travis_terminate 1;'

# Test role.
- 'sudo docker exec "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/dresden-weekly.Rails/tests/itedd.yml'
- 'sudo docker exec -e ANSIBLE_FORCE_COLOR=1 "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/dresden-weekly.Rails/tests/${site}/playbook.yml || travis_terminate 1;'

# Post install checks - App running?
- 'sudo docker exec "$(cat ${container_id})" env TERM=xterm bash /etc/ansible/roles/dresden-weekly.Rails/tests/${site}/check.sh || travis_terminate 1;'

# Test role idempotence.
- >-
sudo docker exec "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/dresden-weekly.Rails/tests/itedd.yml
sudo docker exec "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/dresden-weekly.Rails/tests/${site}.yml
| tee >(sed "s/\\x1B\\[\\([0-9]\\{1,2\}\\(;[0-9]\\{1,2\\}\\)\\?\\)\\?[mGK]//g" | cat >/tmp/output);
cat /tmp/output
| grep -q 'changed=0.*failed=0' && (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1)
Expand Down
4 changes: 1 addition & 3 deletions nginx/passenger/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
passenger_main_variables:
passenger_max_pool_size: 30
passenger_pool_idle_time: 0
passenger_root: "/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini"
passenger_ruby: "/usr/bin/passenger_free_ruby"

# Remove identifing headers like Passenger + Nginx version
passenger_cloak_headers: true
Expand All @@ -17,4 +15,4 @@ passenger_variables:
passenger_min_instances: 1
passenger_max_preloader_idle_time: 0

nginx_config_file: "{{app_name}}.conf"
passenger_site_config_file: "{{app_name}}.conf"
17 changes: 15 additions & 2 deletions nginx/passenger/tasks/config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
# this file will be created by passenger updates
- copy:
dest: /etc/nginx/conf.d/mod-http-passenger.conf
content: |
### Begin automatically installed Phusion Passenger config snippet ###
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini;
passenger_ruby /usr/bin/passenger_free_ruby;
### End automatically installed Phusion Passenger config snippet ###
name: "Create default passenger module config"

- template: dest=/etc/nginx/conf.d/passenger.conf src=passenger.conf.j2
notify: nginx reload
name: "Link Passenger global config"

- template: dest=/etc/nginx/sites-available/{{nginx_config_file}} src=site.conf.j2
- template: dest=/etc/nginx/sites-available/{{passenger_site_config_file}} src=site.conf.j2
notify: nginx reload
name: "Create site config"

- file: src=/etc/nginx/sites-available/{{nginx_config_file}} dest=/etc/nginx/sites-enabled/{{app_name}} state=link owner=root group=root
- file: src=/etc/nginx/sites-available/{{passenger_site_config_file}} dest=/etc/nginx/sites-enabled/{{app_name}} state=link owner=root group=root
notify: nginx reload
name: "Link site config"

6 changes: 3 additions & 3 deletions nginx/passenger/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
apt_repository: repo='deb https://oss-binaries.phusionpassenger.com/apt/passenger {{ ansible_lsb.codename }} main' state=present update_cache=yes

- name: Pkg | Install nginx passenger packages
apt:
state: present
pkg:
apt: pkg={{ item }} state=installed
with_items:
- "libnginx-mod-http-passenger"
- "nginx-extras"
- "passenger"
notify: nginx restart
Expand Down
3 changes: 3 additions & 0 deletions nginx/server/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ nginx_exclude_templates: []
# sites that should stay disabled
nginx_disabled_sites:
- default

# install from ppa on Debian system, otherwise use shipped
nginx_install_from_ppa: true
1 change: 1 addition & 0 deletions nginx/server/tasks/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- name: Debian | Repo
apt_repository:
repo: "{{ nginx_apt_repo }}"
when: nginx_install_from_ppa

- name: Debian | Packages
apt:
Expand Down
4 changes: 4 additions & 0 deletions nginx/server/templates/nginx.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ user {{ nginx_user }};
pid {{ nginx_pid }};
worker_processes {{ nginx_worker_processes }};

{% if ansible_distribution_version is version('17.04', '>=') %}
include /etc/nginx/modules-enabled/*.conf;
{% endif %}

events {
{% for k,v in nginx_events.items() | list %}
{{ k }} {{ v }};
Expand Down
3 changes: 2 additions & 1 deletion rails/jobs/sidekiq/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ sidekiq_worker_index: 0
sidekiq_rails_env: "{{ rails_env }}"
sidekiq_log_file: "{{ RAILS_APP_SHARED_PATH }}/log/sidekiq.log"
sidekiq_config_file: "{{ RAILS_APP_SHARED_PATH }}/config/sidekiq.yml"
sidekiq_concurrency: 25
sidekiq_configuration_concurrency: 25
sidekiq_configuration_redis_url: "redis://localhost:6379/0"
sidekiq_configuration_verbose: true
sidekiq_configuration_queues:
- [important, 10]
- [default, 2]
- [mailers, 1]
- [low, 1]
7 changes: 7 additions & 0 deletions rails/jobs/sidekiq/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
- name: sidekiq config
template:
src: "sidekiq.yml.j2"
dest: "{{ sidekiq_config_file }}"
become: yes
become_user: "{{ sidekiq_upstart_user }}"

- include: "upstart.yml"
when: ansible_service_mgr != "systemd"
- include: "systemd.yml"
Expand Down
7 changes: 0 additions & 7 deletions rails/jobs/sidekiq/tasks/upstart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,3 @@
become: yes
become_user: "{{ sidekiq_upstart_user }}"

- name: sidekiq config
template:
src: "sidekiq.yml.j2"
dest: "{{ sidekiq_config_file }}"
become: yes
become_user: "{{ sidekiq_upstart_user }}"

1 change: 1 addition & 0 deletions tests/Dockerfile.ubuntu-12.04
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ RUN apt-get update && apt-get install -y \
software-properties-common \
python-software-properties \
git \
curl \
sudo \
apt-transport-https \
locales \
Expand Down
1 change: 1 addition & 0 deletions tests/Dockerfile.ubuntu-16.04
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ RUN apt-get update && apt-get install -y \
software-properties-common \
python-software-properties \
git \
curl \
sudo \
apt-transport-https \
locales \
Expand Down
20 changes: 20 additions & 0 deletions tests/Dockerfile.ubuntu-18.04
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM ubuntu:bionic

RUN apt-get update && apt-get install -y \
software-properties-common \
git \
python \
curl \
sudo \
apt-transport-https \
locales \
&& apt-add-repository -y ppa:ansible/ansible \
&& apt-get update && apt-get install -y ansible

RUN curl https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/master/files/docker/systemctl.py --output /usr/bin/systemctl && \
chmod +x /usr/bin/systemctl

RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts

VOLUME [ "/sys/fs/cgroup", "/run", "/tmp" ]

1 change: 1 addition & 0 deletions tests/Dockerfile.ubuntu-upstart-14.04
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ RUN apt-get update && apt-get install -y \
python-software-properties \
git \
sudo \
curl \
apt-transport-https \
locales \
&& apt-add-repository -y ppa:ansible/ansible \
Expand Down
3 changes: 3 additions & 0 deletions tests/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[defaults]
retry_files_enabled = False
pipelining = True
8 changes: 8 additions & 0 deletions tests/hrfilter/check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
set -e

curl localhost/impressum | grep 'HRfilter.de'
echo "SUCCESS: Web app is running!"

pgrep -f sidekiq
echo "SUCCESS: Sidekiq is running!"

Loading