Fix port conflict when deploying multiple IOCs in a single run#170
Open
Fix port conflict when deploying multiple IOCs in a single run#170
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes procServ port conflicts when deploying multiple IOCs in a single Ansible run by ensuring the “next port” counter is properly reset per loop iteration and by handling the edge case where the current max port equals the default start port.
Changes:
- Adjust port selection condition from
>to>=when computing the next available port. - Reset
deploy_ioc_nextportviaset_factat the start of each IOC deployment iteration to avoidinclude_varsbeing ignored due to Ansible precedence.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| roles/deploy_ioc/tasks/update-config.yml | Updates the conditional logic used to compute the next available procServ port. |
| roles/deploy_ioc/tasks/set-facts.yml | Adds an explicit per-iteration reset of the port counter using set_fact. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d344491 to
3cb4c1b
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3cb4c1b to
95dbeb8
Compare
jwlodek
requested changes
Feb 12, 2026
c0127e8 to
157c0ee
Compare
set_fact has higher precedence than include_vars in Ansible, so the include_vars reset at the start of each loop iteration was silently ignored after the first iteration set variables via set_fact. This caused all IOCs after the first to reuse the same port number, and could also leak deploy_ioc_executable, deploy_ioc_template_root_path, and deploy_ioc_dbpf_list between IOCs. Fix by: - Loading role defaults into a namespaced dict and resetting all default variables via set_fact each iteration (looping over dict2items), sourced from that namespace as single source of truth. deploy_ioc_default_env is excluded because it references ioc.type which is not yet available and is never set via set_fact. - Loading device type vars into a namespace and promoting them to set_fact precedence so they override the defaults reset. deploy_ioc_template_root_path is resolved separately after module installation since many device types reference deploy_ioc_required_module_path in a Jinja2 template. - Changing the port comparison from > to >= to handle the edge case where max port equals the default. - Removing deploy_ioc_loop_index from the port calculation, since the deployment is sequential and each iteration's config file is visible to the next via the find command. - Always setting install_module_leaf_executable (defaulting to empty string) so stale values from a prior deploy_ioc iteration cannot leak across mixed device types. The consumer now checks for non-empty rather than just defined. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
157c0ee to
822d66d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
set_facthas higher precedence thaninclude_varsin Ansible, so theinclude_varsreset ofdeploy_ioc_nextportat the start of each loop iteration was silently ignored after the first iteration set it viaset_factdeploy_ioc_nextportusingset_fact(which can override a priorset_fact) and change>to>=to handle the edge case where max port equals the defaultTest plan
🤖 Generated with Claude Code