ansible.cfg
[defaults]
timeout= 60
host_key_checking=False
deprecation_warnings=False
interpreter_python=/usr/local/bin/python3
[paramiko_connection]
look_for_keys = False
==========================================================
hosts
[iosxe:vars]
ansible_connection=ansible.netcommon.network_cli
ansible_user=<username>
ansible_password=<password>
ansible_become=yes
ansible_become_method=enable
ansible_network_os=cisco.ios.ios
subnet_id=1
[iosxe]
<device-ip>
==========================================================
show-commands.yaml
---
- name: Sample IOS playbook to run show commands
hosts: iosxe
gather_facts: no
tasks:
- name: run show ip int brief
cisco.ios.ios_command:
commands: show ip interface brief
register: myinterfaces
- name: display value of "myinterfaces" variable
debug:
var: myinterfaces["stdout_lines"][0]
- name: run show users
cisco.ios.ios_command:
commands: show users
register: myusers
- name: display value of "myusers" variable
debug:
var: myusers["stdout_lines"][0]
==========================================================
No comments:
Post a Comment