Closed pporada-gl closed 8 years ago
Switch# config t Switch(config)# interface gi1/0/5 Switch(config-if)# switchport access vlan 42
Could the cli prompt "Switch(config)#" be confusing ios_commands.py? Looks like there is a regex to match cli prompts at: https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/ios.py#L40 If that regex fails to match, potentially means this is a bug in ansible/ansible module_utils.
But that's just a guess, I haven't tested that regex and know nothing about ios. Reassigning to @privateip for more knowledgable take.
Please do not use ios_command to send configuration commands to the device, thats the purpose of ios_config or ios_template :) In a future release (2.2), ios_command will not accept a list of commands that include configuration.
If there is some functionality that is missing in either ios_config or ios_template that prevents its use, please open a feature request issue.
Would it be possible to get an example of what I was trying to do, but with ios_config? I don't quite understand the syntax from the documentation.
- name: Cisco 2960 XR Switch vlan swap
hosts: cisco_switch_2960xr_nonpoe
connection: local
gather_facts: false
vars:
provider:
host: "{{ inventory_hostnae }}"
username: "{{ device_username }}"
password: "{{ device_password }}"
auth_pass: "{{ device_secret_password }}"
authorize: yes
timeout: 10
tasks:
- name: Change interface VLAN
ios_config:
lines:
- switchport access vlan 42
parents: interface GigabitEthernet1/0/5
provider: "{{ provider }}"
register: output
- debug:
msg: "{{output.stdout_lines}}"
Thank you. I appreciate that very much.
ISSUE TYPE
COMPONENT NAME
ios_command
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
Ubuntu 16.04
SUMMARY
I have a list of commands to send to a switch. It appears as if commands that require
config t
are skipped or fail to execute.STEPS TO REPRODUCE
EXPECTED RESULTS
The switchport changes to the correct vlan as specified by the command list.
ACTUAL RESULTS
The interface does not switch to the appropriate vlan.