04-18-2023 12:53 PM
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.
Has anyone tried something similar?
04-28-2023 12:13 AM
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
01-16-2024 12:17 AM
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.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide