Open Booooooosh opened 3 years ago
I know that there is a ios_banner
module that specifically solve for multi-line banner. However, it will require us to parse the input config file, isolate the banner part and feed it into two separate module. It will be really convenient for us to be able to push the entire config using just ios_config
module.
Thank you for your help!
Hey, @Booooooosh that is the intended behavior of the config module when you are pushing an input from an src.
the multiline_delimiter
is there to specify the start and end of a multiline value not to be used as a separator for multiline, Even then you should be able to use the ios_banner module. Let us know if that helps.
I previously also tried the following
---
- name: apply_config
hosts: all
connection: network_cli
gather_facts: no
vars:
ansible_become: false
ansible_network_os: ios
ansible_user: my-user
tasks:
- name: ios_config
cisco.ios.ios_config:
match: none
src: banner_config.txt
multiline_delimiter: "@"
with banner_config set to
banner motd @
This is obviously
a multi-line
banner
@
with no luck either. I'm suspecting whether multiline banner command is supported within ios_config
module or not.
That being said, yes, we are able to do the same thing using ios_banner
module. However, that will require us to modify the config file (removing the banner portion from the original config) and that's something we want to avoid. So it will be great if ios_config
module supports multi-line banner by default.
It seems that when we extract banner form the candidate / src config we don't take into account the user defined delimiter
and defaults to a \^C
. Code. This can be the root cause where the module isn't parsing mult-line banner correctly?
Also the regex is banner <type> \^C(.+?)(?=\^C)
While it matches banner motd ^C message ^C
It doesn't match multi-line version since .
doesn't include \n
by default.
Hi @Booooooosh That is right, we can consider the fix and check if it passes all the test cases in CI, you can raise a PR for the same, or I can push the required changes. Thanks for looking into it.
hi, i have the same issue. using ios_banner
as workaround would be fine, but we also want to deploy other things like macros and aaa authentication fail-message
using ansible. there are no modules for that, so we would need the multiline functionality of ios_config
.
Is someone allready working on this issue?
Hey, @Thorbijoern I am looking at the issue, can you share some more detail or open an issue explaining the same. Thanks
disclaimer: i'm only a dev bulding some scripts and playbooks to automate config deployment to switches and other network hardware in my company, i don't fully know how cisco devices or cisco ios works.
while testing i stumbled uppon the problem that different config commands don't work with the ios_config
module by default because they require multiline input at the shell and use a different prompt for that, i then found out about the multiline_delimiter
param and tried it but had no luck in getting it to work, like @Booooooosh.
for the cisco ios config options banner exec
and banner login
i could just use the ios_banner
module, it would work and only make the maintenance of the playbooks/roles slightly more work.
But we also want to set aaa authentication fail-message
and macros on the switches using ansible, for example:
aaa authentication fail-message ^
UNAUTHORIZED ACCESS!
^
and simply some macros we want to configure making it a bit simpler for our networking department to manually check things on the switches.
I don't know if there are more ios commands which could require multiline inputs, but we would like macros and aaa authentication fail-message
to also work with multiline inputs from a playbook or a (partial) config file handed to ios_config
(using the src
param).
Thanks for looking into the problem
i'm not a regex wizzard, but the regex which was allready quoted by @Booooooosh supports multiline like this:
banner motd @([\s\S]+?)(?=@)
the set [\s\S]
matches every character and +?
matches between one to unlimeted chars of that set but does lazy matching to match as little as possible. it would only be needed to drop in the vars for the banner type and the chosen delimiter
.
i don't quite know which other parts of the module would need changes to fully support multiline arguments and configs, because the module seems to be a wrapper onto the cli of the switch and these multiline config parameters come with a different prompt at the terminal. as example:
foobar(config)#banner login @
Enter TEXT message. End with the character '@'.
test banner, only for test
@
foobar(config)#
but i wasn't able to test the regex yet inside the module.
SUMMARY
We are performing a full config push using
ios_config
module. It seems like the module still doesn't like multi-line banner command. Thebanner motd
command can be executed only when it's in one line. There are quite a few similar issues from years ago but it seems that this bug still exists.ISSUE TYPE
COMPONENT NAME
ios_config
ANSIBLE VERSION
OS / ENVIRONMENT
Cisco IOS XE Software, Version 16.05.01a
STEPS TO REPRODUCE
banner_config.txt
EXPECTED RESULTS
Successful deployment and device banner updated.
ACTUAL RESULTS
Basically, the device is expecting the multi-line banner however the module seems not to be able to handle the prompt and hence resulting a timeout.
That being said, if I change the banner_config.txt to
It completed without issue and device banner is updated.