Skip to content

rabbitmq: honour the console_interface fallback - #2579

Merged
berendt merged 1 commit into
mainfrom
stack/5-console-interface-fallback
Aug 7, 2026
Merged

rabbitmq: honour the console_interface fallback#2579
berendt merged 1 commit into
mainfrom
stack/5-console-interface-fallback

Conversation

@ideaship

@ideaship ideaship commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

osism/defaults resolves a node's internal address as

{{ hostvars[inventory_hostname]['ansible_' +
   internal_interface|default(console_interface)]['ipv4']['address'] }}

(defaults/manager/000-defaults.yml). The expression used here left the fallback out and referenced internal_interface directly, so a host that sets console_interface explicitly and leaves internal_interface unset — a configuration that resolves in the deployment — did not resolve here.

This adds the fallback so the two agree.

Where neither variable is set it still fails, and loudly: defaults/all/099-interfaces.yml defines console_interface: "{{ internal_interface|default(loopback0) }}", and loopback0 is not defined as a variable anywhere in osism/defaults (the name occurs only as an interface key in netplan and cloud-init files), so the lookup raises 'loopback0' is undefined rather than returning an address that was never configured.

Verification. On ansible-core 2.19.11, both the case this fixes (console_interface set to a real interface, internal_interface absent → resolves to that interface's address) and the case it must not paper over (neither set → raises).

Note this widens what resolves rather than narrowing it: the code preceding this stack required internal_interface outright and skipped the host without it.

Separable — this is not needed to fix osism/issues#1425, and can be deferred or dropped without affecting the rest of the stack.

🤖 Generated with Claude Code

@berendt
berendt force-pushed the stack/5-console-interface-fallback branch from 4158b40 to 9dfeec8 Compare August 7, 2026 05:33
@ideaship
ideaship force-pushed the stack/5-console-interface-fallback branch from 9dfeec8 to 4c6b6d6 Compare August 7, 2026 05:59
@ideaship
ideaship force-pushed the stack/5-console-interface-fallback branch from 4c6b6d6 to 343c470 Compare August 7, 2026 06:54
@berendt
berendt force-pushed the stack/5-console-interface-fallback branch from 343c470 to f8d63e8 Compare August 7, 2026 07:12
@berendt
berendt force-pushed the stack/5-console-interface-fallback branch from f8d63e8 to 90aff88 Compare August 7, 2026 08:59
@ideaship
ideaship force-pushed the stack/5-console-interface-fallback branch from 90aff88 to 4551d49 Compare August 7, 2026 10:27
Base automatically changed from stack/4-template-internal-interface to main August 7, 2026 11:24
osism/defaults resolves a node's internal address as

  {{ hostvars[inventory_hostname]['ansible_' +
     internal_interface|default(console_interface)]['ipv4']['address'] }}

(defaults/manager/000-defaults.yml). The expression used here left the
fallback out and referenced internal_interface directly, so a host that
sets console_interface explicitly and leaves internal_interface unset --
a configuration that resolves in the deployment -- did not resolve here.

Add the fallback so the two agree.

Where neither variable is set this still fails, and loudly:
defaults/all/099-interfaces.yml defines

  console_interface: "{{ internal_interface|default(loopback0) }}"

and "loopback0" is not defined as a variable anywhere in osism/defaults
(the name occurs only as an interface key in netplan and cloud-init
files), so the lookup raises "'loopback0' is undefined" rather than
returning an address that was never configured. Verified on ansible-core
2.19.11, together with the case this commit fixes: console_interface set
to a real interface and internal_interface absent now resolves to that
interface's address.

The integration suite gains the case: a host with console_interface set and
internal_interface absent, resolved against real Ansible.

Note this widens what resolves rather than narrowing it. The code that
preceded this series required internal_interface outright and skipped the
host without it.

Assisted-by: Claude:claude-opus-5
Signed-off-by: Roger Luethi <luethi@osism.tech>
@berendt
berendt force-pushed the stack/5-console-interface-fallback branch from 4551d49 to 17fa97b Compare August 7, 2026 11:24
@ideaship
ideaship marked this pull request as ready for review August 7, 2026 11:40

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've left some high level feedback:

  • The unit test that asserts internal_interface | default(console_interface) is present in INTERNAL_ADDRESS_EXPRESSION is somewhat brittle; consider instead validating the behavior via a small evaluation of the expression (or via the helper that uses it) so refactors of the string layout don’t break the test while preserving behavior.
  • The Jinja expression string for INTERNAL_ADDRESS_EXPRESSION is now quite long and split across concatenated literals; you might consider using a single multi-line string or a helper builder function to improve readability and reduce the chance of subtle formatting mistakes in future changes.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The unit test that asserts `internal_interface | default(console_interface)` is present in `INTERNAL_ADDRESS_EXPRESSION` is somewhat brittle; consider instead validating the behavior via a small evaluation of the expression (or via the helper that uses it) so refactors of the string layout don’t break the test while preserving behavior.
- The Jinja expression string for `INTERNAL_ADDRESS_EXPRESSION` is now quite long and split across concatenated literals; you might consider using a single multi-line string or a helper builder function to improve readability and reduce the chance of subtle formatting mistakes in future changes.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@jklare jklare moved this from New to In progress in Human Board Aug 7, 2026
@berendt
berendt merged commit 5ef836c into main Aug 7, 2026
3 checks passed
@berendt
berendt deleted the stack/5-console-interface-fallback branch August 7, 2026 15:49
@github-project-automation github-project-automation Bot moved this from In progress to Done in Human Board Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Jinja2 variables not rendered by rabbitmq3to4

4 participants