09-29-2023 03:07 PM
Hello, I'm trying to convert our current switch configuration to IBNS configuration for 802.1x with ansible but ran into an issue that i'm trying to figure out. I can get ansible to write "authentication display new-style" and remove some of the default lines that it generates like the class-map type control ... but when I get ansible to remove the policy-map type control.... lines it prompts with a message basically asking if i'm sure and expects a yes. From what i've been reading, the ios_config modules waits for hostname(config)# to show back up before sending the next command and because of this ansible times out waiting for that prompt. I've tied to use the cli_config module as well but it says that it doesn't support a connection type of local. I'm not 100% sure what that means but is there a way to get the ios_config module to look for a different prompt so that i can continue? Or ignore prompts so that i can send a "yes"? Thanks.
10-01-2023 12:14 AM
Hi, try the cli_command module which is part of the ansible.netcommon collection. This module has prompt and answer parameters, which should do the trick. In order to use it in config mode there is an example provided (you need to adjust this to your case):
- name: run config mode command and handle prompt/answer
ansible.netcommon.cli_command:
command: '{{ item }}'
prompt:
- Exit with uncommitted changes
answer: y
loop:
- configure
- set system syslog file test any any
- exit
10-01-2023 03:01 PM
Thanks for the response. I've actually tried cli_command and cli_config already and thought it would work but I get a "connection type local is not valid for this module". I tried to add ansible_connection: network_cli but it didn't make a difference. not sure what to try next to get cli_command or cli_config to work.
10-02-2023 07:08 AM
Can you try
ansible_connection: ansible.netcommon.network_cli
10-02-2023 07:50 AM
I've tried that also and I get the following, "conflicting action statements: ansible_connection, ansible.netcommon.cli_command"
Would setting ansible_connection elseware override whatever is defined in this block or would this take precedence?
10-02-2023 08:58 AM
I would just configure it in the inventory.
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