Compare commits

..

4 Commits

Author SHA1 Message Date
6dd44dfe87 Prepare 0.2.3
All checks were successful
continuous-integration/drone/tag Build is passing
2023-04-12 15:46:11 +02:00
6cb84cba9a Add tasks to remove happydomain 2023-04-12 15:46:03 +02:00
a58a122836 Can install happyDomain as a deamon without docker 2023-04-12 15:46:03 +02:00
ff04988f01 Use FQCN 2023-04-12 10:39:24 +02:00
10 changed files with 225 additions and 9 deletions

View File

@ -1,7 +1,7 @@
---
namespace: happydns
name: happydomain
version: 0.2.2
version: 0.2.3
readme: README.md
authors:
- happyDomain Team <happydomain.org>

View File

@ -1,4 +1,7 @@
---
use_container: false
state: present
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

@ -1,6 +1,6 @@
---
- name: "launch happyDomain container ({{ instance_name }})"
docker_container:
community.general.docker_container:
name: "{{ instance_name }}"
image: "happydomain/happydomain:{{ happydomain_version }}"
pull: 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,9 +1,19 @@
---
- include_tasks: docker.yml
- block:
- include_tasks: download.yml
when: not use_container
- 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"
- include_tasks: docker.yml
when: use_container
- name: Ensure cleaning job runs every day.
ansible.builtin.cron:
name: "run {{ instance_name }} database cleaning"
hour: "3"
minute: "0"
job: "docker exec {{ instance_name }} hadmin /api/tidy -X POST"
when: state == 'present'
- include_tasks: remove.yml
when: state == 'absent'

View File

@ -0,0 +1,33 @@
---
- name: Stop the service
ansible.builtin.service:
name: happydomain
state: stopped
enabled: false
- name: Remove happydomain binary
ansible.builtin.file:
path: /usr/bin/happydomain
state: absent
- name: Remove happydomain user
ansible.builtin.user:
name: happydomain
state: absent
- name: Remove happydomain group
ansible.builtin.group:
name: happydomain
state: absent
- name: Remove init script
ansible.builtin.file:
path: /etc/init.d/happydomain
state: absent
- name: Remove systemd service
ansible.builtin.file:
path: /lib/systemd/system/happydomain.service
state: absent
notify:
- reload systemd

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