Skip to content

Ansible - telnet#

hosts
[R1]
192.168.1.1
cisco.yml
---
- hosts: R1
  gather_facts: False
  roles:
    - cisco
roles/cisco/tasks/main.yml
---
- name: show run
  telnet:
    user: cisco
    password: cisco
    login_prompt: "Username: "
    prompts:
      - "[>|#]|Password: "
    command:
      - terminal length 0
      - terminal width 0
      - show run
  changed_when: False
  register: command_result

- name: debug
  debug:
    var: command_result.output

- name: log export
  local_action:
    module: copy
    owner: nohara
    group: nohara
    mode: 0644
    dest: "{{ log_dir }}/show_run.log"
    content: "{{ command_result.output[3] }}"
  changed_when: False