Files
hla_framework_bd/ansible/plays/service-deploy.yml
T
Benjamin Labrecque fbc4a57953
Deploy bin / deploy (push) Successful in 1s
Deploy, build and restart MASTER / deploy (push) Successful in 9s
Deploy agebd python package / deploy (push) Successful in 1s
refactor: move all services under current/
2026-07-07 09:29:04 +02:00

37 lines
1.6 KiB
YAML

- name: "[{{ service_dir_name }}] Define service specific paths and names"
ansible.builtin.set_fact:
# 1. The literal directory name on disk (e.g., "000-master")
svc_current_dir: "/sls/bd/hla/{{ agebd_env }}/services/{{ service_dir_name }}/current"
# 2. Extract logical service name by dropping the first 4 characters and converting to UPPERCASE (e.g., "MASTER")
service_unit_name: "AGEBD-SERVICE-{{ service_dir_name[4:] | upper }}.service"
- name: "[{{ service_dir_name }}] Ensure target directory structure exists"
ansible.builtin.file:
path: "{{ svc_current_dir }}"
state: directory
mode: '0755'
- name: "[{{ service_dir_name }}] Sync service deployment files"
ansible.builtin.copy:
src: "{{ playbook_dir }}/../services/{{ service_dir_name }}/current/"
dest: "{{ svc_current_dir }}/"
mode: 'preserve'
- name: "[{{ service_dir_name }}] Substitute environment variable inline"
ansible.builtin.replace:
path: "{{ svc_current_dir }}/systemd/{{ service_unit_name }}"
regexp: '\{\{\s*agebd_env\s*\}\}'
replace: "{{ agebd_env }}"
- name: "[{{ service_dir_name }}] Restart Systemd Service using Relative Paths"
ansible.builtin.shell: |
# 1. Tell systemd to link the service file into its registry relatively
systemctl --user link "./{{ service_unit_name }}"
systemctl --user daemon-reload
systemctl --user enable "{{ service_unit_name }}"
systemctl --user restart "{{ service_unit_name }}"
args:
chdir: "{{ svc_current_dir }}/systemd"
environment:
XDG_RUNTIME_DIR: "/run/user/{{ ansible_effective_user_id }}"