Skip to content
Snippets Groups Projects
Commit f7803fd4 authored by Simone Spinelli's avatar Simone Spinelli
Browse files

Initial commit

parents
No related branches found
No related tags found
No related merge requests found
README.md 0 → 100644
# Network Automation Minilab
Vagrantfile and additional configuration to deploy a development environment like the one shown in the picture:
![Dev_Environment_Topology](./images/DevEnvironment.png)
The environment consists of:
- 1 VM for Ansible
- 3 vSRXs fully connected
VM specifications:
* vSRXs have 2 vCPUs and 4GB RAM
* ansible has 2vCPUs and 1GB RAM
## Whats in this repo
These are the contents of this repository:
```
├── docs // Other documentation in addition to this readme file.
│ └── virtualbox_create_vsrx3.0.md
├── images // Images (for the documentation)
│ ├── DevEnvironment.drawio
│ ├── DevEnvironment.png
│ └── warning_icon.png
├── README.md // This readme files
└── Vagrantfile // The Vagrantfile that describes the resources you are going to instantiate
```
## Requirements:
### Git:
Git is recommended to clone this repository.
* Windows:
Download git from:
https://git-scm.com/download/win
* Linux:
Install git using:
```
sudo apt-get install git
```
```
sudo yum install git
```
* OsX:
Download git from:
https://git-scm.com/download/mac
If want to know more about git, you can refer to this book:
https://git-scm.com/book/en/v2
### VirtualBOX:
Download and install virtualbox from:
https://www.virtualbox.org/wiki/Downloads
### Vagrant:
Vagrant will spin up the infrastructure described in the Vagrantfile: Virtual machines and network segments are defined in this file.
Download vagrant from:
https://www.vagrantup.com/downloads.html
Some documentation about Vagrant is available here:
https://www.vagrantup.com/intro/getting-started/index.html
You need at least Vagrant version 2.2.7 if you are using Virtualbox 6.1+
#### Vagrant plugins:
```
➜ vagrant plugin list
vagrant-host-shell (0.0.4, global)
- Version Constraint: > 0
vagrant-junos (0.2.1, global)
- Version Constraint: > 0
vagrant-junos_cli (1.1.0, global)
- Version Constraint: > 0
```
Plugins can be installed using :
```
vagrant plugin install vagrant-host-shell vagrant-junos vagrant-junos_cli
```
|||
|--|--|
|![Warning](./images/warning_icon.png)| **WARNING <p> If you are uprading Virtualbox or Vagrant, run:**```vagrant plugin update```|
### vSRX Images
We use a public vSRX image: https://app.vagrantup.com/juniper/boxes/ffp-12.1X47-D15.4-packetmode
## How to use
Clone this repository using the following command:
```
git clone git@gitlab.geant.org:geant-oav/geant-na-minilab.git
```
Once you have cloned this repository, installed all the requirements and jumped into the directory, you should see this:
```
➜ vagrant status
vsrx1 not created (virtualbox)
ansible-node not created (virtualbox)
This environment represents multiple VMs. The VMs are all listed
above with their current state. For more information about a specific
VM, run `vagrant status NAME`.
```
Launching ```vagrant up``` without any argument turn on all the vms.
You have to do a little manual configuration on vrsx:
```
set system login user vagrant class super-user
set system login user vagrant authentication ssh-rsa "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key"
set interfaces ge-0/0/1 description "HostOnly network"
set interfaces ge-0/0/1 unit 0 family inet address 192.168.56.11/24
set system services netconf ssh
```
Once this is done, you can login in ansible and launch your first playbook:
```
vagrant@ansible-node:~$ cd ansible-minilab/
vagrant@ansible-node:~/ansible-minilab$ ansible-playbook -i minilab-inventory/ playbooks/get_facts.yaml
PLAY [all] *******************************************************************************************************************************************************************************************************
TASK [Gathering Facts] *******************************************************************************************************************************************************************************************
[WARNING]: Ignoring timeout(10) for junos_facts
[WARNING]: default value for `gather_subset` will be changed to `min` from `!config` v2.11 onwards
[WARNING]: Platform linux on host 192.168.56.11 is using the discovered Python interpreter at /usr/bin/python3, but future installation of another Python interpreter could change this. See
https://docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html for more information.
ok: [192.168.56.11]
TASK [collect default set of facts] ******************************************************************************************************************************************************************************
ok: [192.168.56.11]
TASK [show facts] ************************************************************************************************************************************************************************************************
ok: [192.168.56.11] => {
"msg": {
"ansible_facts": {
"ansible_net_api": "netconf",
"ansible_net_filesystems": [
"/dev/ad0s1a",
"devfs",
"/dev/md0",
"/cf",
"devfs",
"procfs",
"/dev/bo0s1e",
"/dev/md1",
"/cf/var/jail",
"/cf/var/log",
"devfs",
"/dev/md2"
],
"ansible_net_gather_network_resources": [],
"ansible_net_gather_subset": [
"default",
"hardware",
"interfaces"
],
"ansible_net_has_2RE": false,
"ansible_net_hostname": "vsrx1",
"ansible_net_interfaces": {
".local.": {
"admin-status": "up",
"macaddress": "Unspecified",
"mtu": "Unlimited",
"oper-status": "up",
"speed": "Unlimited",
"type": "Loopback"
},
"dsc": {
"admin-status": "up",
"macaddress": "Unspecified",
"mtu": "Unlimited",
"oper-status": "up",
"speed": "Unspecified",
"type": "Software-Pseudo"
},
"ge-0/0/0": {
"admin-status": "up",
"macaddress": "08:00:27:ae:f4:51",
"mtu": "1514",
"oper-status": "up",
"speed": "1000mbps",
"type": null
},
"ge-0/0/1": {
"admin-status": "up",
"macaddress": "08:00:27:99:c1:78",
"mtu": "1514",
"oper-status": "up",
"speed": "1000mbps",
"type": null
},
"ge-0/0/2": {
"admin-status": "up",
"macaddress": "08:00:27:54:17:91",
"mtu": "1514",
"oper-status": "up",
"speed": "1000mbps",
"type": null
},
"ge-0/0/3": {
"admin-status": "up",
"macaddress": "08:00:27:61:90:9f",
"mtu": "1514",
"oper-status": "up",
"speed": "1000mbps",
"type": null
},
"gr-0/0/0": {
"admin-status": "up",
"macaddress": null,
"mtu": "Unlimited",
"oper-status": "up",
"speed": "800mbps",
"type": "GRE"
},
"gre": {
"admin-status": "up",
"macaddress": null,
"mtu": "Unlimited",
"oper-status": "up",
"speed": "Unlimited",
"type": "GRE"
},
"ip-0/0/0": {
"admin-status": "up",
"macaddress": null,
"mtu": "Unlimited",
"oper-status": "up",
"speed": "800mbps",
"type": "IPIP"
},
"ipip": {
"admin-status": "up",
"macaddress": null,
"mtu": "Unlimited",
"oper-status": "up",
"speed": "Unlimited",
"type": "IPIP"
},
"irb": {
"admin-status": "up",
"macaddress": "4c:96:14:10:01:30",
"mtu": "1514",
"oper-status": "up",
"speed": "Unspecified",
"type": "Ethernet"
},
"lo0": {
"admin-status": "up",
"macaddress": "Unspecified",
"mtu": "Unlimited",
"oper-status": "up",
"speed": "Unspecified",
"type": "Loopback"
},
"lsi": {
"admin-status": "up",
"macaddress": "Unspecified",
"mtu": "1496",
"oper-status": "up",
"speed": "Unlimited",
"type": "Software-Pseudo"
},
"lsq-0/0/0": {
"admin-status": "up",
"macaddress": null,
"mtu": "1504",
"oper-status": "up",
"speed": null,
"type": null
},
"lt-0/0/0": {
"admin-status": "up",
"macaddress": "02:96:14:10:01:33",
"mtu": "Unlimited",
"oper-status": "up",
"speed": "800mbps",
"type": "Logical-tunnel"
},
"mt-0/0/0": {
"admin-status": "up",
"macaddress": null,
"mtu": "Unlimited",
"oper-status": "up",
"speed": "800mbps",
"type": "Multicast-GRE"
},
"mtun": {
"admin-status": "up",
"macaddress": null,
"mtu": "Unlimited",
"oper-status": "up",
"speed": "Unlimited",
"type": "Multicast-GRE"
},
"pimd": {
"admin-status": "up",
"macaddress": null,
"mtu": "Unlimited",
"oper-status": "up",
"speed": "Unlimited",
"type": "PIMD"
},
"pime": {
"admin-status": "up",
"macaddress": null,
"mtu": "Unlimited",
"oper-status": "up",
"speed": "Unlimited",
"type": "PIME"
},
"pp0": {
"admin-status": "up",
"macaddress": "Unspecified",
"mtu": "1532",
"oper-status": "up",
"speed": "Unspecified",
"type": "PPPoE"
},
"ppd0": {
"admin-status": "up",
"macaddress": null,
"mtu": "Unlimited",
"oper-status": "up",
"speed": "800mbps",
"type": "PIMD"
},
"ppe0": {
"admin-status": "up",
"macaddress": null,
"mtu": "Unlimited",
"oper-status": "up",
"speed": "800mbps",
"type": "PIME"
},
"sp-0/0/0": {
"admin-status": "up",
"macaddress": "Unspecified",
"mtu": "9192",
"oper-status": "up",
"speed": "800mbps",
"type": "Adaptive-Services"
},
"st0": {
"admin-status": "up",
"macaddress": null,
"mtu": "9192",
"oper-status": "up",
"speed": "Unspecified",
"type": "Secure-Tunnel"
},
"tap": {
"admin-status": "up",
"macaddress": "Unspecified",
"mtu": "Unlimited",
"oper-status": "up",
"speed": "Unlimited",
"type": "Software-Pseudo"
},
"vlan": {
"admin-status": "up",
"macaddress": "00:00:00:00:00:00",
"mtu": "1518",
"oper-status": "down",
"speed": "1000mbps",
"type": "VLAN"
}
},
"ansible_net_memfree_mb": 604700,
"ansible_net_memtotal_mb": 2080148,
"ansible_net_model": "firefly-perimeter",
"ansible_net_modules": [
{
"name": "Midplane"
},
{
"name": "System IO"
},
{
"description": "FIREFLY-PERIMETER RE",
"name": "Routing Engine"
},
{
"chassis_sub_module": null,
"description": "Virtual FPC",
"name": "FPC 0"
},
{
"name": "Power Supply 0"
}
],
"ansible_net_python_version": "3.8.10",
"ansible_net_routing_engines": {
"null": {
"cpu_background": "0",
"cpu_idle": "99",
"cpu_interrupt": "0",
"cpu_system": "1",
"cpu_user": "0",
"last_reboot_reason": "Router rebooted after a normal shutdown.",
"load_average_fifteen": "0.10",
"load_average_five": "0.14",
"load_average_one": "0.40",
"memory_control_plane": "1150",
"memory_control_plane_used": "357",
"memory_control_plane_util": "31",
"memory_data_plane": "898",
"memory_data_plane_used": "323",
"memory_data_plane_util": "36",
"memory_system_total": "2048",
"memory_system_total_used": "676",
"memory_system_total_util": "33",
"model": "FIREFLY-PERIMETER RE",
"slot": null,
"start_time": "2021-12-07 10:23:23 UTC",
"status": "Testing",
"up_time": "12 minutes, 47 seconds"
}
},
"ansible_net_serialnum": "46bc1397f531",
"ansible_net_system": "junos",
"ansible_network_resources": {}
},
"changed": false,
"failed": false
}
}
PLAY RECAP *******************************************************************************************************************************************************************************************************
192.168.56.11 : ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
vagrant@ansible-node:~/ansible-minilab$
```
# -*- mode: ruby -*-
# vi: set ft=ruby :
###
###
### --------------------------------------------------------------------------------------------
### If needed, update the SSH keys paths: consider that #{Dir.home} is a variable! not a comment
### Also, if you have to change it, consider creating a branch for your work
### We use special SSH keys, so that your work can be pushed on your name and not using
### some generic non-human account
###
my_group_name = "geant-oav-minilab"
###
### --------------------------------------------------------------------------------------------
###
###
Vagrant.configure("2") do |config|
config.vm.provider "virtualbox" do |v|
v.customize ["modifyvm", :id, "--groups", "/#{my_group_name}"]
v.customize ["modifyvm", :id, "--nicpromisc2", "deny"]
end
## Vsrx1
config.vm.define "vsrx1" do |vsrx1|
vsrx1.vm.hostname = "vsrx1"
vsrx1.vm.box = "juniper/ffp-12.1X47-D15.4-packetmode"
## ge-0/0/0 is connected to NAT network.
vsrx1.vm.network "private_network", ip: "192.168.56.11", auto_config: false ## ge-0/0/1
vsrx1.vm.network "private_network", virtualbox__intnet: "node1_TO_node2_A" ## ge-0/0/2
vsrx1.vm.network "private_network", virtualbox__intnet: "node1_TO_node3_A" ## ge-0/0/3
end
###
### Uncomment this part to have full topology
###
## ## Vsrx2
## config.vm.define "vsrx2" do |vsrx2|
## vsrx2.vm.hostname = "vsrx2"
## vsrx2.vm.box = "juniper/ffp-12.1X47-D15.4-packetmode"
## vsrx2.vm.network "private_network", ip: "192.168.56.12", auto_config: false ## ge-0/0/1
## vsrx2.vm.network "private_network", virtualbox__intnet: "node1_TO_node2_A" ## ge-0/0/2
## vsrx2.vm.network "private_network", virtualbox__intnet: "node2_TO_node3_A" ## ge-0/0/3
##
## end
## ## Vsrx3
## config.vm.define "vsrx3" do |vsrx3|
## vsrx3.vm.hostname = "vsrx3"
## vsrx3.vm.box = "juniper/ffp-12.1X47-D15.4-packetmode"
## vsrx3.vm.network "private_network", ip: "192.168.56.13", auto_config: false ## ge-0/0/1
## vsrx3.vm.network "private_network", virtualbox__intnet: "node1_TO_node3_A" ## ge-0/0/2
## vsrx3.vm.network "private_network", virtualbox__intnet: "node2_TO_node3_A" ## ge-0/0/3
## end
###
###
###
## Ansible node
config.vm.define "ansible-node" do |ansible_master|
ansible_master.vm.hostname = "ansible-node"
ansible_master.vm.box = "ubuntu/focal64"
ansible_master.vm.network "private_network", ip: "192.168.56.199"
ansible_master.vm.provision 'shell', path: "./scripts/finalize_vm.sh"
ansible_master.vm.provision "file", source: "./ansible-minilab", destination: "/home/vagrant/ansible-minilab"
end
end
ansible_connection: netconf
ansible_network_os: junos
all:
children:
junos:
children:
vsrxes:
hosts:
192.168.56.11:
---
- hosts: all
tasks:
- name: collect default set of facts
junipernetworks.junos.junos_facts:
gather_network_resources:
register: router_facts
- name: show facts
debug:
msg: "{{ router_facts }}"
<mxfile modified="2021-12-07T12:30:23.815Z" host="Electron" agent="5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/15.8.7 Chrome/91.0.4472.164 Electron/13.6.2 Safari/537.36" etag="fjfObxs8f9yXOimqQwJf" version="15.8.7" type="device" pages="2"><diagram id="mY9peApjVmFiLAsdPe8O" name="Page-1">7Vxbc6JIFP41Vu0+aNHd0MBjrjNbuzuT2kyyO/OG0CoVpB3EqPPrt9Hm0hfRRFCTmEvFPjQtnO87V9p00NV48SnxJqO/aUCiDjSCRQdddyAEwIDsTyZZcokBrbVkmIQBl5WC+/AXySdy6SwMyFSYmFIapeFEFPo0jomfCjIvSehcnDagkfiuE29IFMG970Wq9N8wSEf5jWG3PPCZhMMRf2sH2usDYy+fzO9kOvICOq+I0E0HXSWUputX48UViTLt5XpZn3e74WhxYQmJ011O+Lp4uPS+jBLj0f/88wJ/f/yGf3VtfrXPXjTjd8yvNl3mKkjoLA5ItorRQZfzUZiS+4nnZ0fnDHUmG6XjiI0Aexl409FqbjaYpgl9Ilc0oslqKWQY5pXrsiODMIpyeUxjkolonHL8AeRj4dTsi8m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4pVIwYPtaUZoyfM6MFyTpNx8rqSSV+s+OaTJPyjrVTvSmCdwqKJWzJ0whlq/fD1vIzvwdxc3UG4QVE1uEnEBBfszPtceZ44LGfoEE0V8kiA0eu90DNj/VIn48gidWh/5Xu8KEhNVtPzPP4yrv3m98JfywodiALzVWrZtrOZeugqrTf6+NeQYJo/NO8AyFUohvOy00/n5XRJRayn+aZxSdUVs7+qjQx8OFkrDXNMUmfvvMFhu2sMWaLV0Rs4tNgeF4ZfTc5OaNbv4A</diagram></mxfile>
\ No newline at end of file
images/DevEnvironment.png

40.5 KiB

images/warning_icon.png

5.43 KiB

apt-get update
apt-get -y upgrade
sudo apt-get install -y python3-pip ansible
sudo -u vagrant ansible-galaxy collection install junipernetworks.junos
sudo -u vagrant ansible-galaxy collection install juniper.device
sudo -u vagrant pip3 install junos-eznc
sudo -u vagrant pip3 install jxmlease
sudo -u vagrant pip3 install ncclient
cat > /home/vagrant/.ansible.cfg << \EOF
[defaults]
host_key_checking = False
EOF
#### Install vagrant SSH keys (Insecure)
mkdir -p /home/vagrant/.ssh
wget https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant -O /home/vagrant/.ssh/id_rsa
chmod 600 /home/vagrant/.ssh/id_rsa
chown vagrant:vagrant /home/vagrant/.ssh/id_rsa
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment