Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Banner per device appended to standard banner #4940

Open
1 task done
PieterL75 opened this issue Jan 28, 2025 · 5 comments
Open
1 task done

Banner per device appended to standard banner #4940

PieterL75 opened this issue Jan 28, 2025 · 5 comments
Labels
type: enhancement New feature or request

Comments

@PieterL75
Copy link

PieterL75 commented Jan 28, 2025

Enhancement summary

I would like to be able to add extra lines to the 'fabric defined banner' for some devices.

The default motd/login banners are defined in the fabric.yml
It would be great if there was a config variable that can be used to pre or append banner text per device/group

Which component of AVD is impacted

eos_cli_config_gen

Use case example

For each device I want to add extra information to the motd banner (racklocation, customer purpose, ...) without having to repeat the fabric wide general banner.

Describe the solution you would like

new variables available as structured_config under node_type_default/node_groups/nodes.

banners_prepend:
  # Multiline string without ending EOF
  login: <str>
  # Multiline string without ending EOF
  motd: <str>

banners_append:
  # Multiline string without ending EOF
  login: <str>
  # Multiline string without ending EOF
  motd: <str>

the banner_prepend is added before the 'banner', the 'banner_append' is inserted just before the EOF line

Describe alternatives you have considered

I tried to accomplish this with variable, but the Jinja is not parsed and put litterly in the config:

banners:
  login: !unsafe "{{ '\n'.join((_fabric_banner_login, _device_banner_login ,'EOF')) }}"
  motd: "{{ _fabric_banner_motd }}{{ _device_banner_motd }}\nEOF"

becomes

banner login
{{ '
'.join((_fabric_banner_login, _device_banner_login ,'EOF')) }}
EOF

!
banner motd
{{ _fabric_banner_motd }}{{ _device_banner_motd }}
EOF
!

Additional context

No response

Contributing Guide

  • I agree to follow this project's Code of Conduct
@PieterL75 PieterL75 added the type: enhancement New feature or request label Jan 28, 2025
@ClausHolbechArista
Copy link
Contributor

I think this is a good use case for inline jinja.

Something like:

banners:
  login: |-
    {{ ([device_banner | arista.avd.default(""), common_banner | arista.avd.default("")]) | join("\n") }}

@PieterL75
Copy link
Author

PieterL75 commented Jan 28, 2025

I tried that, but the jinja is not being processed, it is taken over literally.
Or do you mean as a solution to the implementation in the config_gen ?

@ClausHolbechArista
Copy link
Contributor

Your snip contains !unsafe, which will prevent ansible from templating that.

@PieterL75
Copy link
Author

forgot to remove that from the FR, but even without, the jinja is just passed to the device config without being parsed (See the banner motd)

@ClausHolbechArista
Copy link
Contributor

Something in your vars is missing. Inline jinja in Ansible returns the original template if any variable is missing. You can use our default filter to handle that.

Example with and without the default filter proving the point:

_common_banner: |
  Foo

_device_banner: |
  Bar

custom_structured_configuration_banners:
  login: "{{ _missing_banner | arista.avd.default('') }}{{ _device_banner | arista.avd.default('') }}{{ _common_banner | arista.avd.default('') }}"
  motd: "{{ _missing_banner }}{{ _device_banner }}{{ _common_banner }}"

Leads to this update in the generated config:
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants