library/roles/springboot-config: Installs a startup script (upstart only right now) and a logrotate file to support springboot applications.

This commit is contained in:
Andrea Dell'Amico 2017-04-12 11:43:01 +02:00
parent 2681e0574d
commit 94672dbdb9
4 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,6 @@
---
springboot_config: False
springboot_apps:
- { name: 'foo', log_dir: '/var/log/foo', install_dir: '/usr/lib/foo', state: 'present', user: 'foo', java_opts: '' }

View File

@ -0,0 +1,13 @@
---
- block:
- name: Install the springboot app upstart init file
template: src=springboot-upstart.conf.j2 dest=/etc/init/{{ item.name }}.conf owner=root group=root mode=0644
with_items: '{{ springboot_apps }}'
when: is_trusty
- name: Install the springboot logrotate configuration
template: src=springboot-logrotate.j2 dest=/etc/logrotate.d/{{ item.name }} owner=root group=root mode=0444
with_items: '{{ springboot_apps }}'
when: springboot_config
tags: [ 'springboot', 'springboot_config' ]

View File

@ -0,0 +1,8 @@
{{ item.log_dir }}/{{ item.name }}.log {
copytruncate
daily
rotate 10
compress
missingok
create 640 {{ item.user }} adm
}

View File

@ -0,0 +1,17 @@
# {{ item.name }}
description "{{ item.name }}"
start on runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
setuid {{ item.user }}
setgid {{ item.user }}
script
cd {{ item.install_dir }}
exec java {{ item.java_opts }} -jar ./{{ item.name }}.jar
end script