0

I have a problem with Cisco Routers. I can't open a config terminal because it's saying always invalid input. I done everything what are docs saying. Inventory file:

all:
  vars:
      ansible_connection: network_cli
      ansible_network_os: ios          
      ansible_user: user
      ansible_ssh_pass: pass
      ansible_become: yes      
      ansible_become_method: enable
      ansible_become_password: pass
      ansible_python_interpreter: python
      accept_hostkey: yes 
      ansible_host_key_checking: false
  hosts: 
    testcisco:
      ansible_host: ip

Playbook:

---
- hosts: all
  ignore_errors: yes
  gather_facts: no
  tasks:
    - name: Config
      cisco.ios.ios_command:
        commands: "configure terminal"
      register: output
    - debug:
        msg: "{{ output }}"

Output:

fatal: [testcisco]: FAILED! => {"changed": false, "msg": "configure terminal\r\nconfigure terminal\r\n   ^\r\n% Invalid input detected at '^' marker.\r\n\r\n------#"}

No matter what i type config terminal, conf t etc. It's always saying invalid input

SPR
  • 15
  • 4

2 Answers2

0

For some reason, Ansible is deciding to run two instances of conf t, which is strange. However, you don't nececarily need to be going into global config mode inside of Ansible, see this documentation: https://docs.ansible.com/ansible/latest/collections/cisco/ios/ios_config_module.html

and specifically this part

- name: configure top level configuration
  cisco.ios.ios_config:
    lines: hostname {{ inventory_hostname }}

- name: configure interface settings
  cisco.ios.ios_config:
    lines:
    - description test interface
    - ip address 172.31.1.1 255.255.255.0
    parents: interface Ethernet1

You can see you can do most/all configuration changes you need inside of the playbook itself.

0

you can also just type ios_config and leave out the word cisco

sleek1
  • 1
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 15 '22 at 08:00