Skip to content
This repository was archived by the owner on May 17, 2022. It is now read-only.

Commit bfc0dae

Browse files
committed
feat: move configurations from main repository
1 parent 82bdaa4 commit bfc0dae

File tree

12 files changed

+132
-46
lines changed

12 files changed

+132
-46
lines changed

README.md

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,24 @@
1-
This is a template for a [StackHead Module](https://docs.stackhead.io/technical-documentation/modules).
1+
# StackHead: Caddy webserver module
22

3-
Make sure to adjust it to your needs.
4-
5-
---
6-
7-
# StackHead: [name] module
8-
9-
StackHead module for [description].
3+
StackHead module for using Caddy as webserver.
104

115
## Installation
126

137
Install it via `ansible-galaxy`:
148

159
```
16-
ansible-galaxy install [vendor].stackhead_[type]_[name]
10+
ansible-galaxy install getstackhead.stackhead_webserver_caddy
1711
```
1812

19-
In order to use Nginx with [StackHead](https://get.stackhead.io), set `stackhead__[type]` it in your inventory file:
13+
In order to use Nginx with [StackHead](https://get.stackhead.io), set `stackhead__webserver` it in your inventory file:
2014

2115
```yaml
2216
# inventory for integration test
2317
---
2418
all:
2519
vars:
2620
# Use Nginx as webserver
27-
stackhead__[type]: [vendor].stackhead_[type]_[name]
21+
stackhead__webserver: getstackhead.stackhead_webserver_caddy
2822
hosts:
2923
myserver:
3024
ansible_host: 123.456.789 # ...

__tests__/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
*.tf
2+
Caddyfile

__tests__/test-tf-generation.yml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,15 @@
9090
src: data
9191
dest: /var/lib/mysql
9292
tasks:
93+
- set_fact:
94+
containerapp__expose: "{{ containerapp__expose|default([]) + item.expose }}"
95+
when: item.expose is defined and item.expose not in containerapp__expose|default([])
96+
with_items: "{{ app_config.domains }}"
9397
- block:
94-
- debug:
95-
msg: "Run your tests here by importing the respective tasks"
96-
#- name: Generate Server Block Terraform file
97-
# import_tasks: "../tasks/steps/generate-serverblock-tf.yml"
98+
- name: Generate Caddy Terraform file
99+
import_tasks: "../tasks/steps/generate-serverconfig-tf.yml"
100+
- name: Generate Caddyfile
101+
import_tasks: "../tasks/steps/generate-caddyfile-tf.yml"
98102
vars:
99103
role_path: ".."
104+
caddy_root: "."

meta/main.yml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
galaxy_info:
2-
role_name: stackhead_[ŧype]_[name]]
3-
author: [Your name]
4-
description: A nice module for StackHead (add proper description)
5-
issue_tracker_url: [Your GitHub URL]
2+
role_name: stackhead_webserver_caddy
3+
author: Mario Lubenka
4+
description: A StackHead for using Caddy as webserver
5+
issue_tracker_url: https://github.com/getstackhead/module-webserver-caddy
66
license: GPLv3
77

88
min_ansible_version: 2.9
99

1010
galaxy_tags:
1111
- stackhead
1212
- stackhead-module
13+
- caddy
14+
- caddyserver
1315

14-
# Place dependencies here
15-
#dependencies:
16-
# - role: nginxinc.nginx
16+
dependencies:
17+
#- name: samdoran.caddy
18+
# version: v1.0.0
19+
- src: git+https://github.com/saitho/ansible-role-caddy.git
20+
version: caddy-v2

stackhead-module.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
type: webserver
3-
#terraform:
4-
# provider:
5-
# name: nginx
6-
# url: https://github.com/getstackhead/terraform-nginx/releases/download/v1.3.0/terraform-provider-nginx
3+
terraform:
4+
provider:
5+
name: caddy
6+
url: https://github.com/getstackhead/terraform-caddy/releases/download/v1.0.0/terraform-provider-caddy

tasks/deploy.yml

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
# This task should configure the software for the given project.
1+
# This task list generates the Caddy configuration for a project
22
---
3-
- name: "Project definition contents for project named {{ project_name }}"
4-
debug:
5-
msg: "{{ app_config }}"
6-
- name: "Terraform files in this folder will be applied after during the last step of deployment"
7-
debug:
8-
msg: "{{ stackhead__tf_project_folder }}"
3+
- name: Include OS-specific variables.
4+
include_vars: "{{ ansible_os_family }}.yml"
5+
ignore_errors: yes
96

10-
# If you need to create SSL certificates for the domain
11-
#- include_tasks: "{{ stackhead__roles }}/stackhead_module_api/tasks/ssl-certificate.yml"
7+
- name: Check if authentications are defined
8+
set_fact:
9+
auths_basic: "{{ auths_basic|default([]) + item.security.authentication }}"
10+
when: item.security is defined and item.security.authentication is defined
11+
with_items: "{{ app_config.domains }}"
1212

13-
# If you need the SSL certificates to be generated right now, run Terraform
14-
# - import_tasks: "{{ stackhead__roles }}/stackhead_module_api/tasks/terraform.yml"
13+
- name: Generate Caddy Terraform file
14+
include_tasks: "{{ role_path }}/tasks/steps/generate-serverconfig-tf.yml"
1515

16-
- name: "Certificate private key will be found here after Terraform was executed"
17-
debug:
18-
msg: "{{ stackhead__certificates_project_folder }}/privkey.pem"
19-
- name: "Certificate full chain will be found here after Terraform was executed"
20-
debug:
21-
msg: "{{ stackhead__certificates_project_folder }}/fullchain.pem"

tasks/setup.yml

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1-
# This task should install the software on the server.
1+
# This task list sets up Caddy during server setup
22
---
3-
- debug:
4-
msg: "Install your software here. You may include other roles and run smoke tests"
3+
- name: Setup Caddy
4+
vars:
5+
caddy_user: "stackhead"
6+
caddy_group: "stackhead"
7+
caddy_version: "2.1.1"
8+
caddy_install_source: package
9+
include_role:
10+
#name: samdoran.caddy
11+
name: ansible-role-caddy
12+
- name: Overwrite Caddyfile
13+
include_tasks: "{{ role_path }}/tasks/steps/generate-caddyfile-tf.yml"
14+
- name: Restart Caddy
15+
command: /bin/true
16+
notify:
17+
- restart caddy
18+
- name: Check content after provisioning
19+
uri:
20+
url: "http://{{ ansible_default_ipv4.address|default(ansible_all_ipv4_addresses[0]) }}"
21+
return_content: yes
22+
register: uri_result
23+
until: '"Caddy web server" in uri_result.content'
24+
retries: 5
25+
delay: 1
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
- template:
3+
src: "{{ role_path }}/templates/caddy/Caddyfile.j2"
4+
dest: "{{ caddy_root|default('/etc/caddy') }}/Caddyfile"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
- template:
3+
src: "{{ role_path }}/templates/terraform/caddy_server.tf.j2"
4+
dest: "{{ stackhead__tf_project_folder }}/caddy_server.tf"
5+
force: true

templates/.gitcreate

Whitespace-only changes.

0 commit comments

Comments
 (0)