Skip to content

Commit

Permalink
Merge pull request #87 from SuperQ/systemd
Browse files Browse the repository at this point in the history
Remove support for upstart
  • Loading branch information
LorenzBischof committed Oct 21, 2018
2 parents b90a37a + 82f8140 commit c41176a
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 153 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ RHEL/CentOS has no release that supports systemd capability controls at this tim

**Add additional environment variables**<br>

Add environment variables to the systemd/upstart script
Add environment variables to the systemd script

```
caddy_environment_variables:
Expand Down Expand Up @@ -139,10 +139,10 @@ Example with Cloudflare DNS for TLS
Debugging
---------
If the service fails to start you can figure out why by looking at the output of Caddy.<br>
**Upstart (ubuntu, debian wheezy, centos/rhel 6)**<br>
`tail /var/log/upstart/caddy.log`<br>
**Systemd (debian jessie, centos/rhel 7)**<br>
`systemctl status caddy -l`

```console
systemctl status caddy -l
```

If something doesn't seem right, open an issue!

Expand Down
14 changes: 7 additions & 7 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
# handlers file for caddy-ansible
- name: Restart Caddy
service:
- name: restart caddy
systemd:
daemon_reload: true
name: caddy
state: restarted

- name: Reload systemd service file
command: systemctl daemon-reload
notify: Restart Caddy
ignore_errors: yes
tags: skip_ansible_lint
- name: reload caddy
systemd:
name: caddy
state: reloaded
30 changes: 7 additions & 23 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
dest: "{{ caddy_bin }}"
mode: 0755
remote_src: true
notify: Restart Caddy
notify: restart caddy

- name: Create directories
file:
Expand All @@ -151,32 +151,16 @@
content: "{{ caddy_config }}"
dest: "{{ caddy_conf_dir }}/Caddyfile"
owner: "{{ caddy_user }}"
notify: Restart Caddy

- name: Check if systemd is running
stat:
path: /run/systemd/system
register: systemd

- name: Upstart service
template:
src: "{{ item }}"
dest: /etc/init/caddy.conf
mode: 0644
when: not systemd.stat.exists
with_first_found:
- "caddy.conf.{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version }}"
- "caddy.conf.{{ ansible_distribution | lower }}-{{ ansible_distribution_version }}"
- "caddy.conf"
notify: Restart Caddy
notify: reload caddy

- name: Systemd service
template:
src: caddy.service
dest: /etc/systemd/system/caddy.service
owner: root
group: root
mode: 0644
when: systemd.stat.exists
notify: Reload systemd service file
notify: restart caddy

- name: Set capability on the binary file to be able to bind to TCP port <1024
capabilities:
Expand All @@ -186,7 +170,7 @@
when: caddy_setcap

- name: Start Caddy service
service:
systemd:
name: caddy
state: started
enabled: yes
enabled: true
38 changes: 0 additions & 38 deletions templates/caddy.conf

This file was deleted.

41 changes: 0 additions & 41 deletions templates/caddy.conf.centos-6

This file was deleted.

39 changes: 0 additions & 39 deletions templates/caddy.conf.ubuntu-12.04

This file was deleted.

0 comments on commit c41176a

Please sign in to comment.