Skip to content

Commit

Permalink
Merge pull request #99 from SuperQ/fix_restart
Browse files Browse the repository at this point in the history
Fix restart controls
  • Loading branch information
LorenzBischof authored May 12, 2019
2 parents c9d9435 + fee72bc commit f4b5c18
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 7 deletions.
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
sudo: required
language: python
python: 2.7
cache: pip
services:
- docker
env:
- ANSIBLE=2.4
- ANSIBLE=2.5
- ANSIBLE=2.6
- ANSIBLE=2.7
install:
- pip install ansible==${ANSIBLE} ansible-lint>=3.4.15 molecule==1.25.0 docker git-semver testinfra>=1.7.0
- pip install ansible==${ANSIBLE} ansible-lint>=4.0.0 molecule==1.25.0 docker git-semver testinfra>=1.7.0
before_script:
- ansible-lint tests/playbook.yml
script:
Expand Down
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ galaxy_info:
# - GPLv3
# - Apache
# - CC-BY
license: license (GPLv2, CC-BY, etc)
license: MIT

min_ansible_version: 1.6

Expand Down
5 changes: 3 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
- include: preflight.yml
- include: packages-{{ ansible_pkg_mgr }}.yml

- name: Create Caddy user
Expand All @@ -25,12 +26,12 @@

- name: Build base URL
set_fact:
caddy_base_url: "https://{{ caddy_license_account_id }}:{{ caddy_license_api_key }}@caddyserver.com/download/linux/{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}"
caddy_base_url: "https://{{ caddy_license_account_id }}:{{ caddy_license_api_key }}@caddyserver.com/download/linux/{{ go_arch }}"
when: caddy_license != 'personal'

- name: Build base URL
set_fact:
caddy_base_url: "https://caddyserver.com/download/linux/{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}"
caddy_base_url: "https://caddyserver.com/download/linux/{{ go_arch }}"
when: caddy_license == 'personal'

- name: Build request URLs
Expand Down
17 changes: 17 additions & 0 deletions tasks/preflight.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
- name: Assert usage of systemd as an init system
assert:
that: ansible_service_mgr == 'systemd'
msg: "This module only works with systemd"

- name: Get systemd version
command: systemctl --version
changed_when: false
check_mode: false
register: __systemd_version
tags:
- skip_ansible_lint

- name: Set systemd version fact
set_fact:
caddy_systemd_version: "{{ __systemd_version.stdout_lines[0].split(' ')[-1] }}"
8 changes: 7 additions & 1 deletion templates/caddy.service
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ After=network-online.target
{% if caddy_systemd_network_dependency == true %}
Wants=network-online.target systemd-networkd-wait-online.service
{% endif %}
{% if caddy_systemd_version | int >= 230 %}
StartLimitIntervalSec={{ caddy_systemd_restart_startlimitinterval }}
StartLimitBurst={{ caddy_systemd_restart_startlimitburst }}
{% endif %}

[Service]
Restart={{ caddy_systemd_restart }}
{% if caddy_systemd_version | int < 230 %}
StartLimitInterval={{ caddy_systemd_restart_startlimitinterval }}
StartLimitBurst= {{ caddy_systemd_restart_startlimitburst }}
StartLimitBurst={{ caddy_systemd_restart_startlimitburst }}
{% endif %}

; User and group the process will run as.
User={{ caddy_user }}
Expand Down
2 changes: 2 additions & 0 deletions vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ go_arch_map:
aarch64: 'arm64'
armv7l: 'arm7'
armv6l: 'arm6'

go_arch: "{{ go_arch_map[ansible_architecture] | default(ansible_architecture) }}"

0 comments on commit f4b5c18

Please sign in to comment.