cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
988
Views
0
Helpful
2
Replies

DNAC Template delete users

wsolano
Level 1
Level 1

Hello!

I am creating a few velocity/Jinja2 templates on DNAC to push some configurations to multiple devices. The question that I have is if there is a way to tell the template to delete all existing local users in the device. When I look at the options for variable binding at the device level I don't see users as options.

https://www.cisco.com/c/en/us/td/docs/cloud-systems-management/network-automation-and-management/dna-center/2-3-6/user_guide/b_cisco_dna_center_ug_2_3_6/b_cisco_dna_center_ug_2_3_6_chapter_01000.html

Has anyone tried something similar?

2 Replies 2

nirraman
Cisco Employee
Cisco Employee

Hi Wsolano,

Yes, it is possible to use a Jinja2 template on DNAC to delete local users on multiple devices. You can achieve this by using the "cli" command in the Jinja2 template and executing the command "no username <username>" for each user that needs to be deleted.
 

Here is an example Jinja2 template that deletes all local users on a Cisco IOS device:

 

{% for user in users %}

cli  

command "no username {{ user }}"

{% endfor %}

 

In the above example, "users" is a variable that contains a list of usernames that need to be deleted.

You can then bind this template to a device in DNAC and provide the "users" variable as input.

 

"Note that deleting local users can be a risky operation, and you should ensure that you have a backup of the device configuration before running this template."

-----------------------------------------

If you find my reply solved your question or issue, kindly click the 'Accept as Solution' button and vote it as helpful.

 

You can also learn more about Cisco DNA Center through our live Ask the Experts (ATXs) session. Check out Cisco DNA Center ATXs Resources [https://community.cisco.com/t5/networking-knowledge-base/cisco-dna-center-ask-the-experts-resources/ta-p/4394489] to view the latest schedule for upcoming sessions, as well as the useful references, e.g. online guides, FAQs.

-----------------------------------------

Thank You
Niranjana Ramanan

 


 

Sure about that? Deleting user accounts is an interactive CLI command requiring confirmation. I tried this earlier but got the following error:

Message: Unable to push the invalid CLI to the device switch01.domain.com using protocol ssh2. Invalid CLI -  Current output : no username Anakin
This operation will remove all username related configurations with same name.Do you want to continue? [confirm]
Current expects : switch01.{0,30}([^)]+)#s*z (Config Prompt)
switch01#s*z (Prompt)
[y/n] (Interactive)
ACCEPT? (yes/[no]): (Interactive)

I did not investigate this in depth, I tried a few ways to get it to hit ENTER on the question but no success.