{"id":16761770,"url":"https://github.com/angristan/ansible-caddy","last_synced_at":"2025-03-21T23:32:47.724Z","repository":{"id":153244646,"uuid":"170221550","full_name":"angristan/ansible-caddy","owner":"angristan","description":"Ansible role for Caddy","archived":false,"fork":false,"pushed_at":"2024-07-11T19:13:21.000Z","size":69,"stargazers_count":9,"open_issues_count":5,"forks_count":5,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-14T04:43:24.935Z","etag":null,"topics":["ansible","ansible-role","caddy","debian","ubuntu"],"latest_commit_sha":null,"homepage":"","language":"Jinja","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/angristan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-11T23:51:37.000Z","updated_at":"2024-09-09T00:00:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"42f4f56f-a515-4d12-9937-a762edd58f9e","html_url":"https://github.com/angristan/ansible-caddy","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angristan%2Fansible-caddy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angristan%2Fansible-caddy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angristan%2Fansible-caddy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/angristan%2Fansible-caddy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/angristan","download_url":"https://codeload.github.com/angristan/ansible-caddy/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221820595,"owners_count":16886222,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ansible","ansible-role","caddy","debian","ubuntu"],"created_at":"2024-10-13T04:43:26.368Z","updated_at":"2025-03-21T23:32:47.717Z","avatar_url":"https://github.com/angristan.png","language":"Jinja","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ansible role for Caddy 2\n\nThis is a role I made for myself but I tried to make it as reusable as possible while keeping it fitted to my use.\n\nThe role will handle all basic config like creating a systemd service, a user, conf folders, conf files, log folders, etc.\n\nThen, you can use it to add vhosts using templates. The role include one sample reverse proxy template.\n\nThe role should work on all Debian-based distributions.\n\n## Requirements\n\nThis role does not install Caddy from APT because I want the cloudflare module. Run `build.sh` to build a caddy binary.\n\n## Role Variables\n\nBasic configuration:\n\n- `caddy_bin_path`: caddy binary path (`/usr/bin/caddy`)\n- `caddy_log_path`: log directory (`/var/log/caddy`)\n- `caddy_config_path`: configuration directory (`/etc/caddy`)\n\nA user will be created (`caddy_user_name`), added to a group (`caddy_group_name`) with a specific UID (`caddy_user_id`) and GID (`caddy_group_id`). The default is `caddy/caddy` and `333/333`.\n\nUse this config to use the Cloudflare API for the DNS-01 ACME challenge:\n\n```yaml\ncloudflare_token: xxx\ncaddy_tls_dns_cloudflare_enabled: true\ncaddy_env_vars:\n  - \"CLOUDFLARE_API_TOKEN={{ cloudflare_token }}\"\n```\n\nOtherwise, Caddy will default to HTTP-01 or TLS-ALPN-01.\n\nVhosts configuration:\n\n- `caddy_vhosts`: list of vhosts. (`[]`)\n- `caddy_rm_unmanaged_vhosts`: remove unmanaged vhosts (default `false`)\n\nExample:\n\n```yml\ncaddy_vhosts:\n  - name: site1\n    hostname: site1.domain.tld\n    proxy_host: http://10.0.0.1\n    gzip: compress\n    security_headers: true\n    responds: [\"/forbidden 403\"]\n    rewrites: [\"* /path{uri}\"]\n  - name: site2\n    hostname: site1.domain.tld\n    ansible.builtin.template: custom_template.j2\n```\n\nBy default, the vhosts will use the `reverse.j2` template included in the role. Look at it and the `defaults/main.yml` file for all variables!\n\n- `caddy_vhost_defaults`: default vhost parameters. For each vhost in `caddy_vhosts`, it will be combined with the vhost's parameters. If a vhost defines an option that exist in `caddy_vhost_defaults`, the vhost option will overwrite the default one.\n\n## Example playbook\n\n```yaml\n---\n- hosts: myhost\n  roles:\n    - { role: angristan.caddy, tags: caddy }\n  vars:\n    caddy_vhosts:\n      - name: \"website\"\n        hostname: \"website.tld\"\n```\n\n## Usage\n\nAdd this to `requirements.yml`:\n\n```yml\n- src: https://github.com/angristan/ansible-caddy\n  name: angristan.caddy\n  version: vX.X.X\n```\n\n## Author Information\n\nSee my other Ansible roles at [angristan/ansible-roles](https://github.com/angristan/ansible-roles).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangristan%2Fansible-caddy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fangristan%2Fansible-caddy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fangristan%2Fansible-caddy/lists"}