The goal is to create configurations for VyOS devices and applying them using Ansible. I have used Vyos as my home router, VPN endpoint device (with 1300+ ipsec tunnels) as well as a datacenter router connected to the AMS-IX using 10Gbps uplinks.
Prerequisites
Make sure you have a Vyos installation (can be virtual, can be a box, can even be a Unify Edgerouter) with ssh enabled.
Inventory file
[vyos]
10.0.1.1 ansible_user=ansible-adm ansible_network_os=vyos
Sample Playbook
---
- name: VYOS | Config eth1
hosts: vyos
connection: network_cli
tasks:
- name: VYOS | BACKUP
vyos_config:
backup: yes
- name: VYOS | Apply eth1 config
vyos_l3_interface:
name: eth1
ipv4: 10.0.2.1/24
state: present
Run ansible playbook:
$ ansible-playbook -i hosts vyos.yml --ask-pass
SSH password:
PLAY [VYOS | Config eth1] *************************************************************************************************************************************************************
TASK [Gathering Facts] **************************************************************************************************************************************************
ok: [10.0.1.1]
TASK [VYOS | BACKUP ] *************************************************************************************************************************************************************
changed: [10.0.1.1]
TASK [VYOS | Apply eth1 config] *************************************************************************************************************************************************************
changed: [10.0.1.1]
PLAY RECAP **************************************************************************************************************************************************************
10.0.1.1 : ok=2 changed=2 unreachable=0 failed=0
Configure DNS server on VyOS
---
- hosts: vyos
connection: network_cli
tasks:
- name: VYOS | DNS servers and hostname
vyos_system:
host_name: "{{inventory_hostname}}"
domain_name: my.vyos.test
name_server:
- 1.1.1.1
- 8.8.4.4