Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions roles/deploy_ioc/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ deploy_ioc_post_deploy_step: "None"

# The two below are concatenated to form the full IOC executable path,
# and its associated dbd file. These can be overridden as needed.
deploy_ioc_template_root_path: "/usr/lib/epics"
deploy_ioc_executable: none
deploy_ioc_template_root_path: null
deploy_ioc_template_root_path_default_: "/usr/lib/epics"
deploy_ioc_executable: null
deploy_ioc_executable_default_: "softIoc"

# Use standard st.cmd file, which loads `epicsEnv.cmd`, `base.cmd`, `common.cmd`,
Expand Down
81 changes: 58 additions & 23 deletions roles/deploy_ioc/tasks/set-facts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,20 @@
and ansible_distribution == "RedHat"
and ansible_distribution_major_version | int not in deploy_ioc_supported_el_versions

- name: Initialize executable name defined in module parameters
- name: Initialize module-level overrides
ansible.builtin.set_fact:
deploy_ioc_executable_module_: none
deploy_ioc_executable_module_: null
deploy_ioc_template_root_path_module_: null

# Save whether the device role vars file set these variables.
# We check against null (the default from defaults/main.yml) to detect
# role-level overrides. We cannot eagerly evaluate the role-level values
# here because they may reference variables (e.g. deploy_ioc_required_module_path)
# that are not yet defined.
- name: Detect role-level overrides
ansible.builtin.set_fact:
deploy_ioc_executable_role_set_: "{{ deploy_ioc_executable is not none }}"
deploy_ioc_template_root_path_role_set_: "{{ deploy_ioc_template_root_path is not none }}"
Comment on lines +35 to +39

- name: Handle any module requirements
when: deploy_ioc_required_module is defined or ioc.required_module is defined
Expand All @@ -50,11 +61,55 @@
ansible.builtin.set_fact:
deploy_ioc_required_module_path: "{{ install_module_leaf_module_path }}"

- name: If specified, override ioc exe with installed module exe
- name: If specified, save module-level executable
ansible.builtin.set_fact:
deploy_ioc_executable_module_: "{{ install_module_leaf_executable }}"
when: install_module_leaf_executable is defined

- name: If specified, save module-level template root path
ansible.builtin.set_fact:
deploy_ioc_template_root_path_module_: "{{ install_module_leaf_template_root_path }}"
when: install_module_leaf_template_root_path is defined

# Resolve deploy_ioc_executable with priority (lowest to highest):
# 1. default (deploy_ioc_executable_default_ = "softIoc")
# 2. module (executable field in install_module vars)
# 3. role (deploy_ioc_executable in device role vars file)
# 4. instance (ioc.executable in host config)
#
# The role-level value is already active via include_vars. We only need
# to apply default/module when the role vars did NOT set the variable.
- name: Resolve IOC exe — apply default then module (role did not set it)
ansible.builtin.set_fact:
deploy_ioc_executable: >-
{{ deploy_ioc_executable_module_
if deploy_ioc_executable_module_ is not none
else deploy_ioc_executable_default_ }}
when: not (deploy_ioc_executable_role_set_ | bool)

- name: Override IOC exe name with instance-level value
ansible.builtin.set_fact:
deploy_ioc_executable: "{{ ioc.executable }}"
when: ioc.executable is defined

# Resolve deploy_ioc_template_root_path with priority (lowest to highest):
# 1. default ("/usr/lib/epics")
# 2. module (ioc_template_root_path field in install_module vars)
# 3. role (deploy_ioc_template_root_path in device role vars file)
# 4. instance (ioc.ioc_template_root_path in host config)
- name: Resolve IOC template root path — apply default then module (role did not set it)
ansible.builtin.set_fact:
deploy_ioc_template_root_path: >-
{{ deploy_ioc_template_root_path_module_
if deploy_ioc_template_root_path_module_ is not none
else deploy_ioc_template_root_path_default_ }}
when: not (deploy_ioc_template_root_path_role_set_ | bool)

- name: Override IOC template root path with instance-level value
ansible.builtin.set_fact:
deploy_ioc_template_root_path: "{{ ioc.ioc_template_root_path }}"
when: ioc.ioc_template_root_path is defined

- name: Get default environment variables for ioc type
ansible.builtin.set_fact:
deploy_ioc_merged_env:
Expand Down Expand Up @@ -121,26 +176,6 @@
ansible.builtin.debug:
msg: "{{ deploy_ioc_merged_env }}"

- name: Override default IOC exe root path if specified
ansible.builtin.set_fact:
deploy_ioc_template_root_path: "{{ ioc.ioc_template_root_path }}"
when: ioc.ioc_template_root_path is defined

- name: Override default IOC exe name if specified
ansible.builtin.set_fact:
deploy_ioc_executable: "{{ ioc.executable }}"
when: ioc.executable is defined

- name: Set IOC exe name to the name defined in module parameters
ansible.builtin.set_fact:
deploy_ioc_executable: "{{ deploy_ioc_executable_module_ }}"
when: deploy_ioc_executable is none and deploy_ioc_executable_module_ is not none

- name: Set IOC exe name to the default name
ansible.builtin.set_fact:
deploy_ioc_executable: "{{ deploy_ioc_executable_default_ }}"
when: deploy_ioc_executable is none

- name: Get list of substitution files
ansible.builtin.set_fact:
substitutions: "{{ ioc.substitutions }}"
Expand Down
2 changes: 0 additions & 2 deletions roles/deploy_ioc/vars/rbd9103.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
---

deploy_ioc_required_module: rbd9103_a835e1c
deploy_ioc_template_root_path:
"{{ deploy_ioc_required_module_path }}/iocs/rbd9103IOC"
deploy_ioc_device_specific_env:
SERIAL_PORT: "RBD_TTY"
PORT: "RBD"
6 changes: 6 additions & 0 deletions roles/install_module/tasks/install-module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,9 @@
install_module_leaf_executable:
"{{ install_module_config.executable }}"
when: install_module_config.executable is defined

- name: If specified, set installed leaf module IOC template root path
ansible.builtin.set_fact:
install_module_leaf_template_root_path:
"{{ install_module_dir }}/{{ install_module_config.ioc_template_root_path }}"
when: install_module_config.ioc_template_root_path is defined
1 change: 1 addition & 0 deletions roles/install_module/vars/rbd9103_a835e1c.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ rbd9103_a835e1c:
url: https://github.com/NSLS2/RBD9103
version: a835e1c
executable: "rbd9103App"
ioc_template_root_path: "iocs/rbd9103IOC"
1 change: 1 addition & 0 deletions schemas/install_module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ pkg_deps: list(str(), required=False)
config: map(str(), key=str(), required=False)
use_token: bool(required=False)
executable: str(required=False)
ioc_template_root_path: str(required=False)
compilation_command: str(required=False)
Loading