commit 1338435aa3606f69be004da1b20a49391f7d3dc4 Author: Wilfried OLLIVIER Date: Thu Mar 26 17:21:02 2020 +0100 Bootstrap caddy 410 role diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5568253 --- /dev/null +++ b/LICENSE @@ -0,0 +1,13 @@ + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 + + Copyright (C) 2019 Wilfried OLLIVIER + + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. + + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/README.md b/README.md new file mode 100644 index 0000000..6f9eb22 --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +# galaxy-caddy.410 + +Push caddy config file returning a 410 status + +## Requirements + +Caddy webserver up and running + +## Role Variables + +- caddy_home: caddy home directory +- caddy_logs: caddy log directory +- caddy_conf: caddy config directory +- caddy_confd: caddy conf.d directory +- caddy_www: /var/www/caddy + +- vhost_name: name of the vhost +- vhost_url: url of the vhost + +## Dependencies + +- galaxy-caddy + +## Example Playbook + +Including an example of how to use your role (for instance, with variables passed in as parameters) is always nice for users too: + + - hosts: servers + roles: + - { role: ../galaxy-caddy.reverse, vhost_url: https://default.com } + +## Run tests + +Needs galaxy-vagrant to run tests + +Ensure galaxy-vagrant is up + + ansible-playbook -i tests/inventory tests/test.yml diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..dd07e02 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,10 @@ +--- +# defaults file for galaxy-caddy.410 + +caddy_home: /opt/caddy +caddy_logs: /var/log/caddy +caddy_conf: /etc/caddy +caddy_confd: /etc/caddy/conf.d +caddy_www: /var/www/caddy + +vhost_name: default diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..055f40c --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,13 @@ +--- +# handlers file for galaxy-caddy.reverse + +- name: start caddy + service: name=caddy + state=started + enabled=yes + daemon_reload=yes + +- name: restart caddy + service: name=caddy + state=restarted + enabled=yes diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..8f42c05 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,21 @@ +galaxy_info: + author: Wilfried OLLIVIER + description: Push caddy config file returning a 410 status + company: none + + license: WTFPL + + min_ansible_version: 2.9 + + platforms: + - name: Debian + versions: + - Stretch + - Buster + + galaxy_tags: + - caddy + - webserver + - http + +dependencies: [] \ No newline at end of file diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..90e23e7 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,16 @@ +--- +# tasks file for galaxy-caddy.reverse + +- name: Push caddy template file + template: + src: 410.caddy.j2 + dest: "{{ caddy_confd }}/{{ vhost_name }}.caddy" + owner: caddy + notify: restart caddy + + +- name: Ensure log dir + file: + path: "{{ caddy_logs }}/{{ vhost_name }}" + state: directory + owner: caddy \ No newline at end of file diff --git a/templates/410.caddy.j2 b/templates/410.caddy.j2 new file mode 100644 index 0000000..a56d17a --- /dev/null +++ b/templates/410.caddy.j2 @@ -0,0 +1,17 @@ +{{ vhost_url }} { + + status 410 / + + log {{ caddy_logs }}/{{ vhost_name }}/access.log { + rotate_size 100 + rotate_age 30 + rotate_keep 10 + } + + errors {{ caddy_logs }}/{{ vhost_name }}/errors.log { + rotate_size 100 + rotate_age 30 + rotate_keep 10 + } + +} diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..38d0757 --- /dev/null +++ b/tests/inventory @@ -0,0 +1 @@ +galaxy-vagrant.example.com diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..13bfcb5 --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: galaxy-vagrant.example.com + remote_user: root + roles: + - { role: ../galaxy-caddy.reverse, vhost_url: https://default.com } \ No newline at end of file