VyOS common task using Ansible
This module will guide you through creating playbooks and running them against the inventory. Review all available modules for VyOS here and decide the best module for the use case.
Write a basic Ansible playbook to configure things like hostname, timezone, loopback IP, syslog server etc. Best would be to add these one by one. Add one job, run the playbook, if it goes well, add the next one and so on.
playbook.yml
Step 1 - Configure hostname
- hosts: routers
gather_facts: no
tasks:
- name: Setup system hostname
vyos.vyos.vyos_system:
host_name: "{{ inventory_hostname }}"
Step 2 - Configure timezone
- name: Setup system timezone
vyos.vyos.vyos_config:
lines:
- set system time-zone Asia/Tokyo
Step 3 - Add loopback IPs
- name: Add IPs to loopback
vyos.vyos.vyos_l3_interfaces:
config:
- name: lo
ipv4:
- address: 10.10.10.11/32
- address: 10.10.10.12/32
state: merged
Run the playbook using command:
ansible-playbook -i inventory playbook.yml
Ensure that:
- Run is successful
- Changes in the playbook are applied on the router by looking at
show configuration
orshow configuration commands
output