feature: parametrize install ioc with dev/prod
Deploy bin / deploy (push) Successful in 4s
Deploy, build and restart MASTER / deploy (push) Successful in 4s
Deploy agebd python package / deploy (push) Successful in 1s

This commit is contained in:
Benjamin Labrecque
2026-07-07 11:00:06 +02:00
parent 30fa133eee
commit 7e9b5fa65e
5 changed files with 77 additions and 57 deletions
+2 -2
View File
@@ -1,4 +1,4 @@
all:
hosts:
sls-lc
sls-vserv-bd-hla01-dev
sls-lc:
sls-vserv-bd-hla01-dev:
+71
View File
@@ -0,0 +1,71 @@
- name: Install an IOC and restart it
# TODO: dev/prod
hosts: sls-lc
gather_facts: false
vars:
workspace_dir: "/tmp/hla_framework_bd"
tasks:
- name: Clone this repository
ansible.builtin.git:
repo: "git@gitea.psi.ch:sls/hla_framework_bd.git"
dest: "{{ workspace_dir }}"
version: main
accept_hostkey: true
force: true
- name: "[{{ service_dir_name }}] Establish environment naming conventions"
ansible.builtin.set_fact:
# Extract MASTER from 000-master
service_name_upper: "{{ service_dir_name[4:] | upper }}"
# Set suffix to "-DEV" if dev, otherwise empty ""
env_suffix_upper: "{{ '-DEV' if agebd_env == 'dev' else '' }}"
# Set suffix to "-dev" if dev, otherwise empty ""
env_suffix_lower: "{{ '-dev' if agebd_env == 'dev' else '' }}"
- name: "[{{ service_dir_name }}] Define file paths"
ansible.builtin.set_fact:
ioc_base_dir: "{{ workspace_dir }}/services/{{ service_dir_name }}/current/ioc"
orig_subs_name: "AGEBD-CPCL-{{ service_name_upper }}_main.subs"
target_subs_name: "AGEBD-CPCL-{{ service_name_upper }}{{ env_suffix_upper }}_main.subs"
orig_params_name: "AGEBD-CPCL-{{ service_name_upper }}_parameters.yaml"
target_params_name: "AGEBD-CPCL-{{ service_name_upper }}{{ env_suffix_upper }}_parameters.yaml"
# Rename the subs file if we are in DEV
- name: "[{{ service_dir_name }}] Rename substitution file for environment"
ansible.builtin.command:
cmd: "mv {{ ioc_base_dir }}/{{ orig_subs_name }} {{ ioc_base_dir }}/{{ target_subs_name }}"
removes: "{{ ioc_base_dir }}/{{ orig_subs_name }}" # Only runs if the original file exists
# Rename the paramters file if we are in DEV
- name: "[{{ service_dir_name }}] Rename parameters file for environment"
ansible.builtin.command:
cmd: "mv {{ ioc_base_dir }}/{{ orig_params_name }} {{ ioc_base_dir }}/{{ target_params_name }}"
removes: "{{ ioc_base_dir }}/{{ orig_params_name }}" # Only runs if the original file exists
# Replace {{ agebd_env }} inside the newly renamed subs file
- name: "[{{ service_dir_name }}] Substitute environment token inside subs file"
ansible.builtin.replace:
path: "{{ ioc_base_dir }}/{{ target_subs_name }}"
regexp: '\{\{\s*agebd_env\s*\}\}'
replace: "{{ env_suffix_upper }}"
# Replace {{ agebd_env }} inside the newly renamed params file
- name: "[{{ service_dir_name }}] Substitute environment token inside params file"
ansible.builtin.replace:
path: "{{ ioc_base_dir }}/{{ target_params_name }}"
regexp: '\{\{\s*agebd_env\s*\}\}'
replace: "{{ env_suffix_lower }}"
- name: "[{{ service_dir_name }}] Run ioc install"
ansible.builtin.shell:
cmd: "ioc install -V --facility sls --ioc AGEBD-CPCL-{{ service_name_upper }}{{ env_suffix_upper }} --clean"
chdir: "{{ ioc_base_dir }}"
changed_when: true
- name: "[{{ service_dir_name }}] Restart IOC"
ansible.builtin.shell:
cmd: "ioc restart AGEBD-CPCL-{{ service_name_upper }}{{ env_suffix_upper }}"
chdir: "{{ ioc_base_dir }}"
changed_when: true
-26
View File
@@ -1,26 +0,0 @@
- name: Install an IOC
# TODO: dev/prod
hosts: sls-lc
gather_facts: false
# TODO: checkout repo, cd to services/<svc>/ioc, 'ioc install -V --ioc AGEBD-CPCL-<SVC> clean'
vars:
- workspace_dir: "/tmp/hla_framework_bd"
- service_id: "{{ service_id }}"
- service_name_lower: "{{ service_name_lower }}"
- service_name_upper: "{{ service_name_upper }}"
tasks:
- name: Clone this repository
ansible.builtin.git:
repo: "git@gitea.psi.ch:sls/hla_framework_bd.git"
dest: "{{ workspace_dir }}"
version: main
accept_hostkey: true
- name: Run ioc install
ansible.builtin.shell:
# TODO: prod/dev
cmd: "ioc install -V --facility sls --ioc AGEBD-CPCL-{{ service_name_upper }}-DEV --clean"
chdir: "{{ workspace_dir }}/services/{{ service_id }}-{{ service_name_lower }}/ioc"
changed_when: true
+3 -28
View File
@@ -1,31 +1,6 @@
- name: Restart Master IOC
# TODO: dev/prod
hosts: localhost
gather_facts: false
vars:
- workspace_dir: "/tmp/hla_framework_bd"
service_dir_name: 000-master
import_playbook: ioc-install-and-restart.yml
tasks:
- name: Clone this repository
ansible.builtin.git:
repo: "git@gitea.psi.ch:sls/hla_framework_bd.git"
dest: "{{ workspace_dir }}"
version: main
accept_hostkey: true
- name: Reinstall MASTER IOC
ansible.builtin.shell:
# TODO: prod/dev
cmd: "ioc install -V --facility sls --ioc AGEBD-CPCL-MASTER-DEV --clean"
chdir: "{{ workspace_dir }}/services/000-master/ioc"
changed_when: true
- name: Restart MASTER IOC
ansible.builtin.shell:
# TODO: prod/dev
cmd: "ioc restart AGEBD-CPCL-MASTER-DEV"
chdir: "{{ workspace_dir }}/services/000-master/ioc"
changed_when: true
# TODO: restart systemd master service?
# TODO: restart systemd master service?
+1 -1
View File
@@ -15,7 +15,7 @@ def add(
):
init_logging()
ServiceCreator(
ioc_host="ex-host", # TODO
ioc_host="ex-host", # TODO: "sls-vserv-bd-01{{ agebd_env }}"
ioc_port=9999, # TODO
user="user", # TODO
).add_service(name=name)