routers.yml 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. ---
  2. - name: Configurar routers Cisco
  3. hosts: routers
  4. gather_facts: no
  5. become: yes
  6. vars: # for execution environment
  7. ansible_connection: ansible.netcommon.network_cli
  8. ansible_network_os: cisco.ios.ios
  9. ansible_user: vagrant
  10. ansible_password: vagrant
  11. tasks:
  12. - name: Configurar interfaces GigabitEthernet
  13. ansible.netcommon.cli_command:
  14. command: "{{ item }}"
  15. loop:
  16. - "enable"
  17. - "configure terminal"
  18. - "interface GigabitEthernet1"
  19. - "ip address {{ wan_ip }} 255.255.255.0"
  20. - "no shutdown"
  21. - "exit"
  22. - "interface GigabitEthernet2"
  23. - "ip address {{ lan_ip }} 255.255.255.0"
  24. - "no shutdown"
  25. - "exit"
  26. vars:
  27. wan_ip: "{{ wan_interface_ip }}"
  28. lan_ip: "{{ lan_interface_ip }}"
  29. - name: Configurar RIPv2 en el router
  30. ansible.netcommon.cli_command:
  31. command: "{{ item }}"
  32. loop:
  33. - "enable"
  34. - "configure terminal"
  35. - "router rip"
  36. - "version 2"
  37. - "network {{ wan }}"
  38. - "network {{ lan }}"
  39. - "no auto-summary"
  40. vars:
  41. wan: "{{ wan_network }}"
  42. lan: "{{ lan_network }}"
  43. - name: Guardar la configuración en la NVRAM
  44. ansible.netcommon.cli_command:
  45. command: "{{ item }}"
  46. loop:
  47. - "enable"
  48. # - "configure terminal"
  49. - "write memory"
  50. # - name: Reiniciar los routers
  51. # reboot:
  52. # reboot_timeout: 300