Skip to content

[DNM] Fixed issue where new/empty lines are stripped at the top of a banner#1237

Draft
derrickma06 wants to merge 1 commit into
ansible-collections:mainfrom
derrickma06:ios-banner
Draft

[DNM] Fixed issue where new/empty lines are stripped at the top of a banner#1237
derrickma06 wants to merge 1 commit into
ansible-collections:mainfrom
derrickma06:ios-banner

Conversation

@derrickma06

Copy link
Copy Markdown
SUMMARY

Fixes #1178

This change allows banner text to have leading empty lines ("\n") which can be helpful for formatting. Before this change, this was not possible because the empty lines would be stripped before being converted into a CLI command.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

ios_banner

ADDITIONAL INFORMATION

The fix was to change a .strip(“\n”) call to .rstrip(“\n”) within the map_obj_to_commands function in the ios_banner.py file. Calling strip would remove any leading and trailing empty lines in the banner text, but changing it to rstrip would only remove trailing empty lines and keep the leading lines, allowing for clean space and formatting in the ASCII art banner.

For example, take the following playbook:

   - name: Set banner fact with leading newline
      set_fact:
        banner: |+

          ############################
          #                          #
          #     ASCII Art Banner     #
          #                          #
          ############################

    - name: Generate the banner configuration
      ios_banner:
        banner: login
        text: "{{ banner }}"
        state: present

Before the change, this would result in the following command being inputted to the device:

banner login @
############################
#                          #
#     ASCII Art Banner     #
#                          #
############################
@

The empty lines in the beginning of the banner that were specified in the playbook were removed.
After the change, this is the command that is inputted to the device:

banner login @

############################
#                          #
#     ASCII Art Banner     #
#                          #
############################
@

This output now has the leading empty lines included in the banner.

@Ruchip16

Ruchip16 commented Oct 1, 2025

Copy link
Copy Markdown
Contributor

@derrickma06 thanks for working on this issue, currently this is not in our priority and we are not planning to work on this for some time atleast!

@Ruchip16 Ruchip16 requested a review from AAYUSH2091 October 1, 2025 09:40
@Ruchip16 Ruchip16 marked this pull request as draft October 1, 2025 09:42
@Ruchip16 Ruchip16 changed the title Fixed issue where new/empty lines are stripped at the top of a banner [DNM] Fixed issue where new/empty lines are stripped at the top of a banner Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow empty lines in ios_banner module

2 participants