Setup Hydra systemd service
- run migrations before start - register systemd unit - start service - define localhost as default listening address
This commit is contained in:
parent
9791658838
commit
f0d279789a
5 changed files with 44 additions and 3 deletions
|
@ -3,6 +3,13 @@
|
||||||
hosts: pgsqlserver
|
hosts: pgsqlserver
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
|
pre_tasks:
|
||||||
|
|
||||||
|
- name: Install python3-psycopg2
|
||||||
|
ansible.builtin.package:
|
||||||
|
name: python3-psycopg2
|
||||||
|
state: present
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- hydra_database
|
- hydra_database
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,7 @@
|
||||||
---
|
---
|
||||||
# handlers file for roles/hydra_server
|
- name: hydra_systemd_reload
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
state: started
|
||||||
|
name: hydra
|
||||||
|
daemon_reload: true
|
||||||
|
enabled: true
|
||||||
|
|
|
@ -117,3 +117,17 @@
|
||||||
content: "{{ hydra_tls.keydata }}"
|
content: "{{ hydra_tls.keydata }}"
|
||||||
|
|
||||||
when: not use_mkcert
|
when: not use_mkcert
|
||||||
|
|
||||||
|
- name: Run Hydra SQL migrations
|
||||||
|
ansible.builtin.command:
|
||||||
|
cmd: "{{ hydra_home }}/bin/hydra migrate sql --yes --read-from-env --config {{ hydra_home }}/etc/hydra.yml"
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Create systemd unit file
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: hydra.service.j2
|
||||||
|
dest: /etc/systemd/system/hydra.service
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0640"
|
||||||
|
notify: hydra_systemd_reload
|
||||||
|
|
13
deployment/roles/hydra_server/templates/hydra.service.j2
Normal file
13
deployment/roles/hydra_server/templates/hydra.service.j2
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
[Unit]
|
||||||
|
Description=ORY Hydra OAuth2/OpenID Connect API server
|
||||||
|
After=network.target
|
||||||
|
Documentation=https://www.ory.sh/docs/hydra/
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart={{ hydra_home }}/bin/hydra serve all --config "{{ hydra_home }}/etc/hydra.yml"
|
||||||
|
WorkingDirectory={{ hydra_home }}
|
||||||
|
User={{ hydra_os_user }}
|
||||||
|
Group={{ hydra_os_group }}
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
|
@ -1,9 +1,11 @@
|
||||||
---
|
---
|
||||||
serve:
|
serve:
|
||||||
admin:
|
admin:
|
||||||
host: {{ oidc_urls.hydra_admin.host }}
|
host: {{ oidc_urls.hydra_admin.address | default("localhost") }}
|
||||||
|
port: {{ oidc_urls.hydra_admin.port | default("4445") }}
|
||||||
public:
|
public:
|
||||||
host: {{ oidc_urls.hydra_public.host }}
|
host: {{ oidc_urls.hydra_public.address | default("localhost") }}
|
||||||
|
port: {{ oidc_urls.hydra_public.port | default("4444") }}
|
||||||
tls:
|
tls:
|
||||||
cert:
|
cert:
|
||||||
path: {{ hydra_tls.cert }}
|
path: {{ hydra_tls.cert }}
|
||||||
|
|
Loading…
Reference in a new issue