Can install happyDomain as a deamon without docker

This commit is contained in:
nemunaire 2023-04-12 11:16:33 +02:00
parent ff04988f01
commit a58a122836
7 changed files with 176 additions and 0 deletions

View File

@ -1,4 +1,6 @@
---
use_container: false
instance_name: "happyDomain"
happydomain_version: "latest"

View File

@ -0,0 +1,10 @@
#!/sbin/openrc-run
# Copyright 2016-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
description="happyDomain Domain Managment Server"
pidfile=${pidfile:-"/run/${SVCNAME}.pid"}
command="/usr/bin/happydomain"
command_background="true"
start_stop_daemon_args="--stdout /var/log/${SVCNAME}/${SVCNAME}.log \
--stderr /var/log/${SVCNAME}/${SVCNAME}.log -u happydomain -g happydomain"

View File

@ -0,0 +1,9 @@
---
- name: restart happyDomain
ansible.builtin.service:
name: happydomain
state: restarted
- name: reload systemd
ansible.builtin.systemd:
daemon_reload: true

View File

@ -0,0 +1,79 @@
---
- name: Download happydomain binary
ansible.builtin.get_url:
url: "https://get.happydomain.org/{% if happydomain_version == 'latest' %}master{% else %}{{ happydomain_version }}{% endif %}/happydomain-{{ ansible_system | lower }}-{% if ansible_architecture == 'armv7l' %}armv7{% elif ansible_architecture == 'aarch64' %}arm64{% elif ansible_architecture == 'x86_64' %}amd64{% else %}{{ ansible_architecture }}{% endif %}"
dest: /usr/bin/happydomain
mode: '0755'
- name: "ensure happydomain group exists"
ansible.builtin.group:
name: happydomain
gid: 533
system: true
- name: "ensure happydomain user exists"
ansible.builtin.user:
name: happydomain
comment: happyDomain user
shell: /sbin/nologin
uid: 533
group: happydomain
system: true
home: /var/lib/happydomain
- name: "configure happyDomain"
ansible.builtin.template:
src: happydomain.conf.j2
dest: "/etc/happydomain.conf"
mode: 0755
notify:
- restart happyDomain
- name: Create data directory
ansible.builtin.file:
path: "{% if happydomain_data_dir != '' %}{{ happydomain_data_dir }}{% else %}/var/lib/happydomain{% if instance_name != 'happyDomain' %}.{{ instance_name }}{% endif %}{% endif %}"
owner: happydomain
group: happydomain
state: directory
- name: "setup init script for happyDomain"
ansible.builtin.copy:
src: happydomain.initd
dest: "/etc/init.d/happydomain{% if instance_name is defined and instance_name != 'happyDomain' %}.{{ instance_name }}{% endif %}"
mode: 0755
when: ansible_service_mgr == "openrc"
- name: "create log dir for happydomain"
ansible.builtin.file:
path: "/var/log/happydomain{% if instance_name is defined and instance_name != 'happyDomain' %}.{{ instance_name }}{% endif %}"
mode: 0755
owner: happydomain
group: happydomain
state: directory
when: ansible_service_mgr == "openrc"
- name: "setup systemd service for happyDomain"
ansible.builtin.template:
src: happydomain.service.j2
dest: "/lib/systemd/system/happydomain{% if instance_name is defined and instance_name != 'happyDomain' %}-{{ instance_name }}{% endif %}.service"
mode: 0644
notify:
- reload systemd
when: ansible_service_mgr == "systemd"
- name: Flush handlers
meta: flush_handlers
- name: "ensure happyDomain is running and enabled"
ansible.builtin.service:
name: "happydomain{% if instance_name is defined and instance_name != 'happyDomain' %}.{{ instance_name }}{% endif %}"
enabled: yes
state: started
when: ansible_service_mgr == "openrc"
- name: "ensure happyDomain is running and enabled"
ansible.builtin.service:
name: "happydomain{% if instance_name is defined and instance_name != 'happyDomain' %}-{{ instance_name }}{% endif %}"
enabled: yes
state: started
when: ansible_service_mgr == "systemd"

View File

@ -1,5 +1,9 @@
---
- include_tasks: download.yml
when: not use_container
- include_tasks: docker.yml
when: use_container
- name: Ensure cleaning job runs every day.
ansible.builtin.cron:

View File

@ -0,0 +1,58 @@
{% if happydomain_admin_bind is defined and happydomain_admin_bind != "" %}
admin-bind={{ happydomain_admin_bind }}
{% endif %}
{% if happydomain_bind is defined and happydomain_bind != "" %}
bind={{ happydomain_bind }}
{% endif %}
{% if happydomain_baseurl is defined and happydomain_baseurl != "" %}
baseurl={{ happydomain_baseurl }}
{% endif %}
{% if happydomain_custom_head_html is defined and happydomain_custom_head_html != "" %}
custom-head-html={{ happydomain_custom_head_html }}
{% endif %}
{% if happydomain_custom_body_html is defined and happydomain_custom_body_html != "" %}
custom-body-html={{ happydomain_custom_body_html }}
{% endif %}
{% if happydomain_default_nameserver is defined and happydomain_default_nameserver != "" %}
default-ns={{ happydomain_default_nameserver }}
{% endif %}
{% if happydomain_external_auth is defined and happydomain_external_auth != "" %}
external-auth={{ happydomain_external_auth }}
{% endif %}
{% if happydomain_external_url is defined and happydomain_external_url != "" %}
externalurl={{ happydomain_external_url }}
{% endif %}
{% if happydomain_jwt_secret_key is defined and happydomain_jwt_secret_key != "" %}
jwt-secret-key={{ happydomain_jwt_secret_key }}
{% endif %}
leveldb-path={{ happydomain_storage_leveldb_path | default(happydomain_data_dir + '/happydomain.db') }}
{% if happydomain_mail_from is defined and happydomain_mail_from != "" %}
mail-from={{ happydomain_mail_from }}
{% endif %}
{% if happydomain_mail_smtp_host is defined and happydomain_mail_smtp_host != "" %}
mail-smtp-host={{ happydomain_mail_smtp_host }}
{% endif %}
{% if happydomain_mail_smtp_port is defined and happydomain_mail_smtp_port != "" %}
mail-smtp-port={{ happydomain_mail_smtp_port }}
{% endif %}
{% if happydomain_mail_smtp_username is defined and happydomain_mail_smtp_username != "" %}
mail-smtp-username={{ happydomain_mail_smtp_username }}
{% endif %}
{% if happydomain_mail_smtp_password is defined and happydomain_mail_smtp_password != "" %}
mail-smtp-password={{ happydomain_mail_smtp_password }}
{% endif %}
{% if happydomain_mail_smtp_tls_no_verify is defined and happydomain_mail_smtp_tls_no_verify != "" %}
mail-smtp-tls-no-verify={{ happydomain_mail_smtp_tls_no_verify }}
{% endif %}
{% if happydomain_no_auth is defined and happydomain_no_auth != "" %}
no-auth={{ happydomain_no_auth }}
{% endif %}
{% if happydomain_storage_engine is defined and happydomain_storage_engine != "" %}
storage-engine={{ happydomain_storage_engine }}
{% endif %}
{% if happydomain_ovh_application_key is defined and happydomain_ovh_application_key != "" %}
ovh-application-key={{ happydomain_ovh_application_key }}
{% endif %}
{% if happydomain_ovh_application_secret is defined and happydomain_ovh_application_secret != "" %}
ovh-application-secret={{ happydomain_ovh_application_secret }}
{% endif %}

View File

@ -0,0 +1,14 @@
[Unit]
Description=happyDomain Domain Managment Server
After=network.target nss-lookup.target
[Service]
Type=exec
ExecStart=/usr/bin/happydomain
WorkingDirectory={% if happydomain_data_dir != '' %}{{ happydomain_data_dir }}{% else %}/var/lib/happydomain{% if instance_name != 'happyDomain' %}.{{ instance_name }}{% endif %}{% endif %}
User=happydomain
Group=happydomain
[Install]
WantedBy=multi-user.target