forked from ISTI-ansible-roles/ansible-roles
springboot: install systemd units on systemd based OSs.
This commit is contained in:
parent
5bad5d43fa
commit
8dd7cba5e6
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
- name: systemd reload
|
||||||
|
command: systemctl daemon-reload
|
||||||
|
|
|
@ -1,13 +1,24 @@
|
||||||
---
|
---
|
||||||
- block:
|
- name: Springboot startup files management
|
||||||
|
block:
|
||||||
- name: Install the springboot app upstart init file
|
- 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
|
template: src=springboot-upstart.conf.j2 dest=/etc/init/{{ item.name }}.conf owner=root group=root mode=0644
|
||||||
with_items: '{{ springboot_apps }}'
|
with_items: '{{ springboot_apps }}'
|
||||||
when: is_trusty
|
when: ansible_service_mgr != 'systemd'
|
||||||
|
|
||||||
|
- name: Install the springboot systemd service unit
|
||||||
|
template: src=springboot.service.systemd.j2 dest=/etc/systemd/system/{{ item.name }}.service mode=0644 owner=root group=root
|
||||||
|
with_items: '{{ springboot_apps }}'
|
||||||
|
when: ansible_service_mgr == 'systemd'
|
||||||
|
notify: systemd reload
|
||||||
|
|
||||||
- name: Install the springboot logrotate configuration
|
- name: Install the springboot logrotate configuration
|
||||||
template: src=springboot-logrotate.j2 dest=/etc/logrotate.d/{{ item.name }} owner=root group=root mode=0444
|
template: src=springboot-logrotate.j2 dest=/etc/logrotate.d/{{ item.name }} owner=root group=root mode=0444
|
||||||
with_items: '{{ springboot_apps }}'
|
with_items: '{{ springboot_apps }}'
|
||||||
|
|
||||||
when: springboot_config
|
- name: Ensure that the springboot service is running and enabled
|
||||||
|
service: name={{ item.name }} state=started enabled=yes
|
||||||
|
with_items: '{{ springboot_apps }}'
|
||||||
|
|
||||||
|
when: springboot_config | bool
|
||||||
tags: [ 'springboot', 'springboot_config' ]
|
tags: [ 'springboot', 'springboot_config' ]
|
||||||
|
|
|
@ -0,0 +1,30 @@
|
||||||
|
[Unit]
|
||||||
|
Description={{ item.name }}
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
{% if item.envfile is defined %}
|
||||||
|
EnvironmentFile=/etc/myapp/environmentfile
|
||||||
|
{% endif %}
|
||||||
|
Type=simple
|
||||||
|
User={{ item.user }}
|
||||||
|
Group={{ item.user }}
|
||||||
|
|
||||||
|
WorkingDirectory={{ item.install_dir }}
|
||||||
|
{% if item.envfile is defined %}
|
||||||
|
ExecStart=/usr/bin/java $JAVA_OPTS -jar $EXEC_JAR
|
||||||
|
{% else %}
|
||||||
|
ExecStart=/usr/bin/java {{ item.java_opts }} -jar {{ item.install_dir }}/{{ item.name }}.jar
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
StandardOutput=journal
|
||||||
|
StandardError=journal
|
||||||
|
SyslogIdentifier={{ item.name }}
|
||||||
|
|
||||||
|
SuccessExitStatus=143
|
||||||
|
TimeoutStopSec=10
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=60
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
Loading…
Reference in New Issue