Initial commit

main
Leo Maroni 3 years ago
commit ced099de32
No known key found for this signature in database
GPG Key ID: B1ADA545CD2CBACD

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 Leo 'em0lar' Maroni
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

@ -0,0 +1,3 @@
---
caddy_config_sites_directory: "/etc/caddy/sites.d"
caddy_config_sites_clear: false

@ -0,0 +1,5 @@
---
- name: Reload caddy
systemd:
name: "caddy.service"
state: reloaded

@ -0,0 +1,53 @@
galaxy_info:
role_name: caddy
author: Leo 'em0lar' Maroni
description: Ansible role for installing and configuring caddy
# company: your company (optional)
# If the issue tracker for your role is not on github, uncomment the
# next line and provide a value
# issue_tracker_url: http://example.com/issue/tracker
# Choose a valid license ID from https://spdx.org - some suggested licenses:
# - BSD-3-Clause (default)
# - MIT
# - GPL-2.0-or-later
# - GPL-3.0-only
# - Apache-2.0
# - CC-BY-4.0
license: MIT
min_ansible_version: 2.1
# If this a Container Enabled role, provide the minimum Ansible Container version.
# min_ansible_container_version:
#
# Provide a list of supported platforms, and for each platform a list of versions.
# If you don't wish to enumerate all versions for a particular platform, use 'all'.
# To view available platforms and versions (or releases), visit:
# https://galaxy.ansible.com/api/v1/platforms/
#
platforms:
- name: Debian
versions:
- all
- name: Ubuntu
versions:
- all
galaxy_tags:
- caddy
- caddyserver
- http
- web
# List tags for your role here, one per line. A tag is a keyword that describes
# and categorizes the role. Users find roles by searching for tags. Be sure to
# remove the '[]' above, if you add tags to this list.
#
# NOTE: A tag is limited to a single word comprised of alphanumeric characters.
# Maximum 20 tags per role.
dependencies: []
# List your role dependencies here, one per line. Be sure to remove the '[]' above,
# if you add dependencies to this list.

@ -0,0 +1,36 @@
---
- name: Create Caddyfile
copy:
src: "{{ caddy_config_file }}"
dest: "/etc/caddy/Caddyfile"
owner: "caddy"
mode: 0640
notify:
- Reload caddy
- name: Clear sites.d directory before adding net configurations
file:
path: "{{ caddy_config_sites_directory }}"
owner: "caddy"
group: "caddy"
state: absent
when: caddy_config_sites_paths is defined and caddy_config_sites_clear
- name: Add sites.d directory
file:
path: "{{ caddy_config_sites_directory }}"
owner: "caddy"
group: "caddy"
state: directory
when: caddy_config_sites_paths is defined
- name: Template site configurations
template:
src: "{{ item }}"
dest: "{{ caddy_config_sites_directory }}"
owner: "caddy"
group: "caddy"
with_fileglob: "{{ caddy_config_sites_paths }}"
when: caddy_config_sites_paths is defined
notify:
- Reload caddy

@ -0,0 +1,22 @@
---
- name: Add apt signing key for caddy apt repository
apt_key:
url: "https://dl.cloudsmith.io/public/caddy/stable/cfg/gpg/gpg.155B6D79CA56EA34.key"
state: present
- name: Add caddy apt repository
apt_repository:
repo: "deb https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main"
state: present
- name: Add caddy apt source repository
apt_repository:
repo: "deb-src https://dl.cloudsmith.io/public/caddy/stable/deb/debian any-version main"
state: present
- name: Install caddy apt package
apt:
name: "caddy"
state: present

@ -0,0 +1,4 @@
---
- include_tasks: "install.yml"
- include_tasks: "configuration.yml"
Loading…
Cancel
Save