Hi everyone,

Question: I am trying to parse ntp server ip from running-config of Cisco 
IOS device. What are the best methods to do that? The output should just be 
the IPs.

My code:

---
# Purpose: Provide credentials and find hard coded ntp server IP

- hosts: ios_devices
  gather_facts: no
  connection: local

  vars_prompt:
  -  name: "Username"
     prompt: "TACACS Username"
  -  name: "Password"
     prompt: "TACACS Password"

  tasks:

  - name: SYS | Define provider
    set_fact:
      provider:
        host: "{{ inventory_hostname }}"
        username: "{{ Username }}"
        password: "{{ Password }}"

  - name: Current ntp servers
    ios_command:
      provider: "{{ provider }}"
      commands: 
        - sh run
    register: runconf

  - set_fact: 
      oldntpser: "{{ runconf.stdout | regex_search('(ntp)') }}"

  - debug: 
      var: oldntpser

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5b4d1ff2-1784-46ff-b11d-6872af77741e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to