APNIC 56 Network Automation tutorial
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

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.


Step 1 - Configure hostname

  - hosts: routers  
    gather_facts: no
      - name: Setup system hostname   
          host_name: "{{ inventory_hostname }}"

Step 2 - Configure timezone

      - name: Setup system timezone    
            - set system time-zone Asia/Tokyo

Step 3 - Add loopback IPs

      - name: Add IPs to loopback
          - name: lo
            - address:
            - address:
          state: merged

Run the playbook using command:

ansible-playbook -i inventory playbook.yml 

Ensure that:

  1. Run is successful
  2. Changes in the playbook are applied on the router by looking at show configuration or show configuration commands output