Last active
May 12, 2020 14:56
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir -p ansible-vyos/{backup,host_vars} | |
cd ansible-vyos | |
vim ansible.cfg | |
###copy-paste below --- Define list of inventory of destination node(s) | |
[defaults] | |
inventory = ./hosts | |
###end of copy-paste | |
vim hosts | |
###copy-paste below --- Define group name of destination node(s) | |
[vyos-devices] | |
vyos-1 | |
###end of copy-paste | |
vim host_vars/vyos-1 | |
###copy-paste below --- IP destination, and SSH credential | |
ansible_host: 192.168.1.15 | |
ansible_user: vyos | |
ansible_ssh_pass: vyos | |
ansible_connection: network_cli | |
ansible_network_os: vyos | |
###end of copy-paste | |
vim vyos_facts.yml | |
###copy-paste below --- Playbook for showing all subsets of vyos | |
--- | |
- name: vyos facts | |
connection: network_cli | |
gather_facts: False | |
hosts: vyos-1 | |
tasks: | |
- name: vyos facts | |
vyos_facts: | |
gather_subset: all | |
register: output | |
###end of copy-paste | |
vim vyos_command.yml | |
###copy-paste below --- Playbook for showing interface with loop | |
--- | |
- name: vyos command with loop | |
connection: network_cli | |
gather_facts: False | |
hosts: vyos-1 | |
tasks: | |
- name: show interface | |
vyos_command: | |
commands: show interface ethernet {{ item }} | |
loop: | |
- eth0 | |
- eth1 | |
register: output | |
- name: show output | |
debug: | |
var: output | |
###end of copy-paste | |
vim vyos_backup.yml | |
###copy-paste below --- Playbook for backup config locally | |
- name: configure the remote device | |
vyos_config: | |
lines: | |
- set system host-name {{ inventory_hostname }} | |
- set service lldp | |
- delete service dhcp-server | |
- name: backup and load from file | |
vyos_config: | |
src: vyos.cfg | |
backup: yes | |
- name: render a Jinja2 template onto the VyOS router | |
vyos_config: | |
src: vyos_template.j2 | |
- name: for idempotency, use full-form commands | |
vyos_config: | |
lines: | |
- set interface ethernet eth1 description 'OUTSIDE' | |
- name: configurable backup path | |
vyos_config: | |
backup: yes | |
backup_options: | |
filename: backup.cfg | |
dir_path: /home/ubuntu | |
###end of copy-paste |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment