cisco.ios
cisco.ios copied to clipboard
cisco.ios.ios_route_maps does not allow to set a list of community values
SUMMARY
I am trying to set a list of community values. In a Cisco router, the "set community" command allows to enter more than one community value, the cisco.ios.ios_route_maps module does not.
ISSUE TYPE
- Bug Report
COMPONENT NAME
cisco.ios.ios_route_maps
ANSIBLE VERSION
ansible --version
ansible [core 2.13.2]
config file = /etc/ansible/ansible.cfg
configured module search path = ['/home/gbloise/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /home/gbloise/.local/lib/python3.8/site-packages/ansible
ansible collection location = /home/gbloise/.ansible/collections
executable location = /home/gbloise/.local/bin/ansible
python version = 3.8.10 (default, Mar 15 2022, 12:22:08) [GCC 9.4.0]
jinja version = 3.1.2
libyaml = True
COLLECTION VERSION
ansible-galaxy collection list cisco.ios
# /home/gbloise/.local/lib/python3.8/site-packages/ansible_collections
Collection Version
---------- -------
cisco.ios 3.3.0
# /home/gbloise/.ansible/collections/ansible_collections
Collection Version
---------- -------
cisco.ios 3.3.0
# /usr/local/lib/python3.8/dist-packages/ansible_collections
Collection Version
---------- -------
cisco.ios 3.3.0
CONFIGURATION
In the documentation for cisco.ios.ios_route_maps (https://github.com/ansible-collections/cisco.ios/blob/main/docs/cisco.ios.ios_route_maps_module.rst) the "set" for "community" is the following:
<html>
<body>
<!--StartFragment-->
<html>
<body>
<!--StartFragment-->
setdictionary | | Match source-protocol of route
-- | -- | --
| | | aigp_metricdictionary | | accumulated metric value
| | | | igp_metricboolean | Choices:noyes | metric value from rib
| | | | valueinteger | | manual value
| | | as_pathdictionary | | Prepend string for a BGP AS-path attribute
| | | | prependdictionary | | Prepend to the as-path
| | | | | as_numberlist / elements=string | | AS numberPlease refer vendor documentation for valid values
| | | | | last_asinteger | | Prepend last AS to the as-pathNumber of last-AS prependsPlease refer vendor documentation for valid values
| | | | tagboolean | Choices:noyes | Set the tag as an AS-path attribute
| | | automatic_tagboolean | Choices:noyes | Automatically compute TAG value
| | | clnsstring | | OSI summary addressNext hop addressCLNS summary prefix
| | | comm_liststring | | set BGP community list (for deletion)Community-list name/numberDelete matching communities
| | | communitydictionary | | BGP community attribute
| | | | additiveboolean | Choices:noyes | Add to the existing community
| | | | gshutboolean | Choices:noyes | Graceful Shutdown (well-known community)
| | | | internetboolean | Choices:noyes | Internet (well-known community)
| | | | local_asboolean | Choices:noyes | Do not send outside local AS (well-known community)
| | | | no_advertiseboolean | Choices:noyes | Do not advertise to any peer (well-known community)
| | | | no_exportboolean | Choices:noyes | Do not export to next AS (well-known community)
| | | | noneboolean | Choices:noyes | No community attribute
| | | | numberstring | | community numbercommunity number in aa:nn formatPlease refer vendor documentation for valid values
<!--EndFragment-->
</body>
</html>
<!--EndFragment-->
</body>
</html>
Notice, set | community | number is a string variable, not a list variable. As such I cannot enter more than one.
OS / ENVIRONMENT
us1455-houston1-dc-cs#show ver
Cisco IOS XE Software, Version 16.09.05
Cisco IOS Software [Fuji], ASR1000 Software (X86_64_LINUX_IOSD-UNIVERSALK9-M), Version 16.9.5, RELEASE SOFTWARE (fc1)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2020 by Cisco Systems, Inc.
Compiled Thu 30-Jan-20 18:53 by mcpre
Cisco IOS-XE software, Copyright (c) 2005-2020 by cisco Systems, Inc.
All rights reserved. Certain components of Cisco IOS-XE software are
licensed under the GNU General Public License ("GPL") Version 2.0. The
software code licensed under GPL Version 2.0 is free software that comes
with ABSOLUTELY NO WARRANTY. You can redistribute and/or modify such
GPL code under the terms of GPL Version 2.0. For more details, see the
documentation or "License Notice" file accompanying the IOS-XE software,
or the applicable URL provided on the flyer accompanying the IOS-XE
software.
ROM: IOS-XE ROMMON
us1455-houston1-dc-cs uptime is 1 year, 6 weeks, 5 days, 4 hours, 14 minutes
Uptime for this control processor is 1 year, 6 weeks, 5 days, 4 hours, 17 minutes
System returned to ROM by PowerOn at 01:23:52 GMT Fri May 21 2021
System restarted at 10:29:14 GMT Wed Jun 23 2021
System image file is "bootflash:asr1000rpx86-universalk9.16.09.05.SPA.bin"
Last reload reason: PowerOn
This product contains cryptographic features and is subject to United
States and local country laws governing import, export, transfer and
use. Delivery of Cisco cryptographic products does not imply
third-party authority to import, export, distribute or use encryption.
Importers, exporters, distributors and users are responsible for
compliance with U.S. and local country laws. By using this product you
agree to comply with applicable laws and regulations. If you are unable
to comply with U.S. and local laws, return this product immediately.
A summary of U.S. laws governing Cisco cryptographic products may be found at:
http://www.cisco.com/wwl/export/crypto/tool/stqrg.html
If you require further assistance please contact us by sending email to
[email protected].
License Type: EvalRightToUse
License Level: adventerprise
Next reload license Level: adventerprise
Smart Licensing Status: Smart Licensing is DISABLED
cisco ASR1006 (RP2) processor (revision RP2) with 9997044K/6147K bytes of memory.
Processor board ID FXS1715Q7MQ
16 Gigabit Ethernet interfaces
6 Ten Gigabit Ethernet interfaces
32768K bytes of non-volatile configuration memory.
16777216K bytes of physical memory.
1925119K bytes of eUSB flash at bootflash:.
78085207K bytes of SATA hard disk at harddisk:.
0K bytes of WebUI ODM Files at webui:.
Configuration register is 0x2102
us1455-houston1-dc-cs#
STEPS TO REPRODUCE
When trying to configure the set community number, it only allows for one community value:
set:
community:
number: 1:1
EXPECTED RESULTS
It would be expected to convert this variable to a list so I could configure (as an example) like:
set:
community:
number:
- 1:1
- 1:2
ACTUAL RESULTS
I couldn't pass the verification part from VS Code
Just a comment on this. The behavior of the set community command in a route map entry is the following:
- set community options:
1.a. Many options can be added:
router(config-route-map)#set community ?
<1-4294967295> community number
aa:nn community number in aa:nn format
gshut Graceful Shutdown (well-known community)
internet Internet (well-known community)
local-AS Do not send outside local AS (well-known community)
no-advertise Do not advertise to any peer (well-known community)
no-export Do not export to next AS (well-known community)
none No community attribute
1.b. once a community number has been entered, the list of options remain the same (including the end of the list, highlighted by carriage return (
): router(config-route-map)#set community 13979:110 ? <1-4294967295> community number aa:nn community number in aa:nn format additive Add to the existing community gshut Graceful Shutdown (well-known community) internet Internet (well-known community) local-AS Do not send outside local AS (well-known community) no-advertise Do not advertise to any peer (well-known community) no-export Do not export to next AS (well-known community) 1.c. Options <1-4294967295>, aa:nn, gshut, internet, local-AS, no-advertise and no-export allows for more options to be added:
router(config-route-map)#set community 13979:110 no-export ?
<1-4294967295> community number
aa:nn community number in aa:nn format
additive Add to the existing community
gshut Graceful Shutdown (well-known community)
internet Internet (well-known community)
local-AS Do not send outside local AS (well-known community)
no-advertise Do not advertise to any peer (well-known community)
no-export Do not export to next AS (well-known community)
router(config-route-map)#set community 13979:110 gsh
router(config-route-map)#set community 13979:110 gshut ?
<1-4294967295> community number
aa:nn community number in aa:nn format
additive Add to the existing community
gshut Graceful Shutdown (well-known community)
internet Internet (well-known community)
local-AS Do not send outside local AS (well-known community)
no-advertise Do not advertise to any peer (well-known community)
no-export Do not export to next AS (well-known community)
router(config-route-map)#set community 13979:110 in
router(config-route-map)#set community 13979:110 internet ?
<1-4294967295> community number
aa:nn community number in aa:nn format
additive Add to the existing community
gshut Graceful Shutdown (well-known community)
internet Internet (well-known community)
local-AS Do not send outside local AS (well-known community)
no-advertise Do not advertise to any peer (well-known community)
no-export Do not export to next AS (well-known community)
router(config-route-map)#set community 13979:110 local
router(config-route-map)#set community 13979:110 local-AS ?
<1-4294967295> community number
aa:nn community number in aa:nn format
additive Add to the existing community
gshut Graceful Shutdown (well-known community)
internet Internet (well-known community)
local-AS Do not send outside local AS (well-known community)
no-advertise Do not advertise to any peer (well-known community)
no-export Do not export to next AS (well-known community)
router(config-route-map)#set community 13979:110 no
router(config-route-map)#set community 13979:110 no-ad
router(config-route-map)#set community 13979:110 no-advertise ?
<1-4294967295> community number
aa:nn community number in aa:nn format
additive Add to the existing community
gshut Graceful Shutdown (well-known community)
internet Internet (well-known community)
local-AS Do not send outside local AS (well-known community)
no-advertise Do not advertise to any peer (well-known community)
no-export Do not export to next AS (well-known community)
router(config-route-map)#set community 13979:110 no-ex
router(config-route-map)#set community 13979:110 no-export ?
<1-4294967295> community number
aa:nn community number in aa:nn format
additive Add to the existing community
gshut Graceful Shutdown (well-known community)
internet Internet (well-known community)
local-AS Do not send outside local AS (well-known community)
no-advertise Do not advertise to any peer (well-known community)
no-export Do not export to next AS (well-known community)
1.d. the additive option does not allow for any more options, which means it has to be the last option in the list:
router(config-route-map)#set community 13979:110 additive ?
1.e. the none option would be an either or option with the rest ... meaning you can only add set community none or set community
I would propose to do something like:
set: community: communities: - <1-4294967295> - aa:nn - gshut - internet - local-AS - no-advertise - no-export additive: True | False none: True | False
where: if none=True then don't evaluate any other value
I hope this helps.
Hi Gian! I came across your bug report while looking at some idempotency issues I've been experiencing with route maps.
I guess, since number is a string, that you could put an arbitrary value here as long as it's accepted by ios?
set:
community:
number: 65100:100 65100:123 no-export
Another alternative, and probably more according to convention, is to split it it up into separate tasks.
- name: set numbered or new-format community
cisco.ios.ios_route_maps:
config:
- route_map: TEST
entries:
- sequence: 10
action: permit
set:
community:
number: 6500:100 6500:200
- name: set no_export community
cisco.ios.ios_route_maps:
config:
- route_map: TEST
entries:
- sequence: 10
action: permit
set:
community:
no_export: true
- name: screw it I'm having regrets!
cisco.ios.ios_route_maps:
config:
- route_map: TEST
entries:
- sequence: 10
action: permit
set:
community:
none: true
state: replaced
but alas either option seems to break idempotency 🙉
Would you consider the above alternatives as a solution and would you agree that bringing idempotency to this would be a step further in the right direction? 😃
Thanks and take care!
HI @bentole, I have tested the suggested: adding a set of community values as a string works ... on top of that, setting additive to 'yes' when the number has a long "string" also works, however I would consider this a workaround, not a solution. As you mentioned above, indeed bringing idempotency would be the step in the right direction as long as it follows Cisco IOS logic :)
Sounds good! I forgot to say that you should be able to add different communites types in the same task as well. Sorry for not mentioning that in the previous post 😄
- name: set various communities
cisco.ios.ios_route_maps:
config:
- route_map: TEST
entries:
- sequence: 10
action: permit
set:
community:
number: 65000:100 65000:200
no_export: yes
internet: yes
but I agree, it makes more sense to have the community numbers as a list of strings, like this (?)
- name: making more sense
config:
- route_map: TEST
entries:
- sequence: 10
action: permit
set:
community:
number:
- 65000:100
- 65000:200
no_export: yes
internet: yes
I guess there's also an issue with additive. Like you said it has to be the last option on the list. Well-known communities can be additive too, right? Yet, it only seems to work on number...