Ansible: Playbook basico para Cisco IOS
1. Configurar hosts file -> /etc/ansible/hosts
[ciscoios]
192.168.1.10
192.168.1.20
[ciscoios:vars]
ansible_python=interpreter=/usr/bin/python3
2. Configurar playbook -> nano /etc/ansible/show_version.yml
---
- name: show version
hosts: all
gather_facts: false
tasks:
- name: show version
raw: "show version"
register: print_output
- debug: var=print_output.stdout_lines
3. Ejecutar playbook con nuestro usuario de sssh-> ansible-playbook show_version.yml -u angel -k
Obtendremos un output de este estilo:
root@angel-pc:/etc/ansible# ansible-playbook show_version.yml -u angel -k
SSH password:
PLAY [show version] **********************************************************************************************************************************
TASK [show version] **********************************************************************************************************************************
changed: [192.168.1.10]
changed: [192.168.1.11]
ok: [192.168.1.10] => {
"print_output.stdout_lines": [
"",
"",
"Cisco IOS XE Software, Version 16.09.04",
"Cisco IOS Software [Fuji], Catalyst L3 Switch Software (CAT9K_IOSXE), Version 16.9.4, RELEASE SOFTWARE (fc2)",
"Technical Support: http://www.cisco.com/techsupport",
"Copyright (c) 1986-2019 by Cisco Systems, Inc.",
"Compiled Thu 22-Aug-19 18:14 by mcpre",
"",
"",
"Cisco IOS-XE software, Copyright (c) 2005-2019 by cisco Systems, Inc.",
"All rights reserved. Certain components of Cisco IOS-XE software are",
"licensed under the GNU General Public License (\"GPL\") Version 2.0. The",
"software code licensed under GPL Version 2.0 is free software that comes",
"with ABSOLUTELY NO WARRANTY. You can redistribute and/or modify such",
"GPL code under the terms of GPL Version 2.0. For more details, see the",
"documentation or \"License Notice\" file accompanying the IOS-XE software,",
"or the applicable URL provided on the flyer accompanying the IOS-XE",
"software.",
"",
"",
"ROM: IOS-XE ROMMON",
"BOOTLDR: System Bootstrap, Version 16.9.1r [FC2], RELEASE SOFTWARE (P)",
"",
"SW1 uptime is 45 weeks, 5 days, 21 hours, 34 minutes",
"Uptime for this control processor is 45 weeks, 5 days, 21 hours, 36 minutes",
"System returned to ROM by Reload Command at 18:22:03 UTC Wed Mar 25 2020",
"System restarted at 18:24:26 UTC Wed Mar 25 2020",
"System image file is \"flash:packages.conf\"",
"Last reload reason: Reload Command",
ok: [192.168.1.11] => {
"print_output.stdout_lines": [
"",
"",
"Cisco IOS XE Software, Version 16.09.04",
"Cisco IOS Software [Fuji], Catalyst L3 Switch Software (CAT9K_IOSXE), Version 16.9.4, RELEASE SOFTWARE (fc2)",
"Technical Support: http://www.cisco.com/techsupport",
"Copyright (c) 1986-2019 by Cisco Systems, Inc.",
"Compiled Thu 22-Aug-19 18:14 by mcpre",
"",
"",
"Cisco IOS-XE software, Copyright (c) 2005-2019 by cisco Systems, Inc.",
"All rights reserved. Certain components of Cisco IOS-XE software are",
"licensed under the GNU General Public License (\"GPL\") Version 2.0. The",
"software code licensed under GPL Version 2.0 is free software that comes",
"with ABSOLUTELY NO WARRANTY. You can redistribute and/or modify such",
"GPL code under the terms of GPL Version 2.0. For more details, see the",
"documentation or \"License Notice\" file accompanying the IOS-XE software,",
"or the applicable URL provided on the flyer accompanying the IOS-XE",
"software.",
"",
"",
"ROM: IOS-XE ROMMON",
"BOOTLDR: System Bootstrap, Version 16.9.1r [FC2], RELEASE SOFTWARE (P)",
"",
"SW2 uptime is 45 weeks, 5 days, 21 hours, 34 minutes",
"Uptime for this control processor is 45 weeks, 5 days, 21 hours, 36 minutes",
"System returned to ROM by Reload Command at 18:22:03 UTC Wed Mar 25 2020",
"System restarted at 18:24:26 UTC Wed Mar 25 2020",
"System image file is \"flash:packages.conf\"",
"Last reload reason: Reload Command",
PLAY RECAP *******************************************************************************************************************************************
192.168.1.10 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
192.168.1.11 : ok=2 changed=1 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Comentarios
Publicar un comentario