New role happydomain
This commit is contained in:
parent
41fbf3cfd9
commit
75c384cee5
63
roles/happydomain/README.md
Normal file
63
roles/happydomain/README.md
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
Ansible Role: happydomain
|
||||||
|
=========
|
||||||
|
|
||||||
|
Ansible Role to deploy happyDomain on Linux hosts.
|
||||||
|
|
||||||
|
Requirements
|
||||||
|
------------
|
||||||
|
|
||||||
|
* Ansible >= 2.9
|
||||||
|
* Docker installed on the remote host
|
||||||
|
* Cron ready
|
||||||
|
|
||||||
|
Role Variables
|
||||||
|
--------------
|
||||||
|
|
||||||
|
All variables which can be overridden are stored in [./defaults/main.yaml](./defaults/main.yaml) file as well as in table below.
|
||||||
|
|
||||||
|
| Variable | Default | Description |
|
||||||
|
| :------ | :------ | :--------- |
|
||||||
|
| `instance_name` | `happyDomain` | name of this instance |
|
||||||
|
| `happydomain_version` | `latest` | version of happyDomain to use |
|
||||||
|
| `happydomain_data_dir` | `/var/lib/happydomain` | Local directory used to store happyDomain data |
|
||||||
|
| `happydomain_inner_data_dir` | `/data` | Directory used inside the container |
|
||||||
|
| `happydomain_admin_bind` | `./happydomain.sock` | Bind port/socket for administration interface |
|
||||||
|
| `happydomain_baseurl` | `` | URL prepended to each URL |
|
||||||
|
| `happydomain_bind` | `:8081` | Bind port/socket |
|
||||||
|
| `happydomain_custom_body_html` | `` | Add custom HTML right before `</body>` |
|
||||||
|
| `happydomain_custom_head_html` | `` | Add custom HTML right before `</head>` |
|
||||||
|
| `happydomain_default_nameserver` | `127.0.0.1:53` | Adress to the default name server (used for resolutions) |
|
||||||
|
| `happydomain_external_auth` | `` | Base URL to use for login and registration (use embedded forms if left empty) |
|
||||||
|
| `happydomain_external_url` | `http://localhost:8081` | Begining of the URL, before the base, that should be used eg. in mails |
|
||||||
|
| `happydomain_jwt_secret_key` | `` | Secret key used to verify JWT authentication tokens (a random secret is used if undefined) |
|
||||||
|
| `happydomain_storage_leveldb_path` | `./happydomain.db` | Path to the LevelDB Database |
|
||||||
|
| `happydomain_mail_from` | `happyDomain <happydomain@localhost>` | Define the sender name and address for all e-mail sent |
|
||||||
|
| `happydomain_mail_smtp_host` | `` | Use the given SMTP server as default way to send emails |
|
||||||
|
| `happydomain_mail_smtp_port` | `465` | Define the port to use to send e-mail through SMTP method |
|
||||||
|
| `happydomain_mail_smtp_username` | `` | If the SMTP server requires authentication, fill with the username to authenticate with |
|
||||||
|
| `happydomain_mail_smtp_password` | `` | Password associated with the given username for SMTP authentication |
|
||||||
|
| `happydomain_mail_smtp_tls_no_verify` | `` | Do not verify certificate validity on SMTP connection |
|
||||||
|
| `happydomain_no_auth` | `false` | Disable user access control, use default account |
|
||||||
|
| `happydomain_ovh_application_key` | `` | Application Key for using the OVH API |
|
||||||
|
| `happydomain_ovh_application_secret` | `` | Application Secret for using the OVH API |
|
||||||
|
| `happydomain_storage_engine` | `leveldb` | Select the storage engine to use |
|
||||||
|
|
||||||
|
|
||||||
|
Example Playbook
|
||||||
|
----------------
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
---
|
||||||
|
- hosts: happydomain-host
|
||||||
|
roles:
|
||||||
|
- name: happydns.happydomain.happydomain
|
||||||
|
happydomain_version: linux-amd64
|
||||||
|
happydomain_no_auth: "true"
|
||||||
|
happydomain_mail_from: "Demo User <demo@localhost>"
|
||||||
|
happydomain_mail_smtp_host: smtp.example.com
|
||||||
|
```
|
||||||
|
|
||||||
|
License
|
||||||
|
-------
|
||||||
|
|
||||||
|
CECILL-2.1
|
26
roles/happydomain/defaults/main.yml
Normal file
26
roles/happydomain/defaults/main.yml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
instance_name: "happyDomain"
|
||||||
|
happydomain_version: "latest"
|
||||||
|
|
||||||
|
happydomain_data_dir: "" # defaults to /var/lib/happydomain.{{ instance_name }} if not filled
|
||||||
|
happydomain_inner_data_dir: "/data"
|
||||||
|
|
||||||
|
happydomain_admin_bind: "./happydomain.sock"
|
||||||
|
happydomain_baseurl: ""
|
||||||
|
happydomain_custom_body_html: ""
|
||||||
|
happydomain_custom_head_html: ""
|
||||||
|
happydomain_default_nameserver: "127.0.0.1:53"
|
||||||
|
happydomain_endpoint: ":8081"
|
||||||
|
happydomain_external_auth: ""
|
||||||
|
happydomain_external_url: "http://localhost:8081"
|
||||||
|
happydomain_jwt_secret_key: ""
|
||||||
|
happydomain_storage_leveldb_path: "./happydomain.db"
|
||||||
|
happydomain_mail_from: "happyDomain <happydomain@localhost>"
|
||||||
|
happydomain_mail_smtp_host: ""
|
||||||
|
happydomain_mail_smtp_port: "465"
|
||||||
|
happydomain_mail_smtp_username: ""
|
||||||
|
happydomain_mail_smtp_password: ""
|
||||||
|
happydomain_no_auth: "false"
|
||||||
|
happydomain_ovh_application_key: ""
|
||||||
|
happydomain_ovh_application_secret: ""
|
||||||
|
happydomain_storage_engine: "leveldb"
|
9
roles/happydomain/meta/main.yml
Normal file
9
roles/happydomain/meta/main.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
galaxy_info:
|
||||||
|
author: Pierre-Olivier Mercier <nemunaire@nemunai.re>
|
||||||
|
description: Setup or upgrade a happyDomain instance
|
||||||
|
company: happyDNS
|
||||||
|
license: CECILL-2.1
|
||||||
|
min_ansible_version: 2.9
|
||||||
|
galaxy_tags: ["happydomain", "domains", "dns"]
|
||||||
|
dependencies: []
|
34
roles/happydomain/tasks/docker.yml
Normal file
34
roles/happydomain/tasks/docker.yml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
---
|
||||||
|
- name: "launch happyDomain container ({{ instance_name }})"
|
||||||
|
docker_container:
|
||||||
|
name: "{{ instance_name }}"
|
||||||
|
image: "happydomain/happydomain:{{ happydomain_version }}"
|
||||||
|
pull: true
|
||||||
|
volumes:
|
||||||
|
- "{% if happydomain_data_dir != "" %}{{ happydomain_data_dir }}{% else %}/var/lib/{% if instance_name != "happyDomain" %}happydomain.{% endif %}{{ instance_name }}{% endif %}:{{ happydomain_inner_data_dir }}"
|
||||||
|
state: started
|
||||||
|
restart_policy: unless-stopped
|
||||||
|
memory: 256M
|
||||||
|
memory_swap: 512M
|
||||||
|
env:
|
||||||
|
HAPPYDOMAIN_ADMIN_BIND: "{{ happydomain_admin_bind }}"
|
||||||
|
HAPPYDOMAIN_BIND: "0.0.0.0:8081"
|
||||||
|
HAPPYDOMAIN_BASEURL: "{{ happydomain_baseurl }}"
|
||||||
|
HAPPYDOMAIN_CUSTOM_HEAD_HTML: "{{ happydomain_custom_head_html }}"
|
||||||
|
HAPPYDOMAIN_DEFAULT_NS: "{{ happydomain_default_nameserver }}"
|
||||||
|
HAPPYDOMAIN_EXTERNAL_AUTH: "{{ happydomain_external_auth }}"
|
||||||
|
HAPPYDOMAIN_EXTERNALURL: "{{ happydomain_external_url }}"
|
||||||
|
HAPPYDOMAIN_JWT_SECRET_KEY: "{{ happydomain_jwt_secret_key }}"
|
||||||
|
HAPPYDOMAIN_LEVELDB_PATH: "{{ happydomain_storage_leveldb_path }}"
|
||||||
|
HAPPYDOMAIN_MAIL_FROM: "{{ happydomain_mail_from }}"
|
||||||
|
HAPPYDOMAIN_MAIL_SMTP_HOST: "{{ happydomain_mail_smtp_host }}"
|
||||||
|
HAPPYDOMAIN_MAIL_SMTP_PORT: "{{ happydomain_mail_smtp_port }}"
|
||||||
|
HAPPYDOMAIN_MAIL_SMTP_USERNAME: "{{ happydomain_mail_smtp_username }}"
|
||||||
|
HAPPYDOMAIN_MAIL_SMTP_PASSWORD: "{{ happydomain_mail_smtp_password }}"
|
||||||
|
HAPPYDOMAIN_MAIL_SMTP_TLS_NO_VERIFY: "{{ happydomain_mail_smtp_tls_no_verify }}"
|
||||||
|
HAPPYDOMAIN_NO_AUTH: "{{ happydomain_no_auth }}"
|
||||||
|
HAPPYDOMAIN_OVH_APPLICATION_KEY: "{{ happydomain_ovh_application_key }}"
|
||||||
|
HAPPYDOMAIN_OVH_APPLICATION_SECRET: "{{ happydomain_ovh_application_secret }}"
|
||||||
|
HAPPYDOMAIN_STORAGE_ENGINE: "{{ happydomain_storage_engine }}"
|
||||||
|
published_ports:
|
||||||
|
- "{{ happydomain_bind }}:8081"
|
9
roles/happydomain/tasks/main.yml
Normal file
9
roles/happydomain/tasks/main.yml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
- include_tasks: docker.yml
|
||||||
|
|
||||||
|
- name: Ensure cleaning job runs every day.
|
||||||
|
cron:
|
||||||
|
name: "run {{ instance_name }} database cleaning"
|
||||||
|
hour: "3"
|
||||||
|
minute: "0"
|
||||||
|
job: "docker exec {{ instance_name }} hadmin /api/tidy -X POST"
|
Loading…
Reference in New Issue
Block a user