Skip to content

Commit

Permalink
Add #8 to dev branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ipspace committed May 2, 2021
2 parents e79b026 + 83800dd commit 63f14cd
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ Installing the tools:
* Within the **netsim-tools** directory, install PyYAML, Jinja2, netaddr and python-box Python libraries with **pip3 install -r requirements.txt**.
* Optional: install Ansible or use [ipSpace network automation container image](https://hub.docker.com/r/ipspace/automation). The tools were tested with Ansible 2.9 and 2.10.

Alternatively, you could use **install.libvirt** Ansible playbook to install Vagrant, *libvirt* Vagrant plugin, **netsim-tools**, and all their dependencies on Ubuntu (tested on a Ubuntu 20.04 virtual machine):

```bash
$ wget https://github.com/ipspace/netsim-tools/blob/master/install.libvirt
$ ansible-playbook install.libvirt --ask-become
```

The playbook:

- Installs all software packages required to use the *libvirt* Vagrant backend (including the *vagrant-libvirt* plugin)
- Configures the *vagrant-libvirt* network
- Clones the `netsim-tools` repository into `/opt/netsim-tools` and makes that directory writeable by the current user
- Instantiates a new Python virtual environment in `/opt/netsim-tools` and install the Python dependencies into it.

## Building Your Lab

The current version of the **config-generate** tool contains templates needed to create a Vagrant topology containing Cisco IOSv, Cisco CSR 1000v, Cisco Nexus 9300v, and Arista vEOS devices with *vagrant-libvirt* or *virtualbox* provider. The tool also supports container-based network operating systems powered by *containerlab*.
Expand Down
61 changes: 61 additions & 0 deletions install.libvirt
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
- name: Install netsim-tools and dependencies for libvirt provider
hosts: localhost
connection: local
vars:
plugin_file: "{{ lookup('file','~/.vagrant.d/plugins.json', errors='ignore') | from_json }}"
clone_to: /opt/netsim-tools
vagrant_libvirt_version: 0.4.1
netsim_tools_version: release_0.6.1
vagrant_libvirt_installed: "{{ plugin_file.installed.vagrant_libvirt is not defined or plugin_file.installed.vagrant_libvirt.gem_version != vagrant_libvirt_version }}"
tasks:
- name: Install apt dependencies
apt:
pkg:
- libvirt-dev
- qemu-kvm
- vagrant
- virtinst
- ruby-libvirt
- qemu
- libvirt-daemon-system
- libvirt-clients
- ebtables
- dnsmasq-base
- libxslt-dev
- libxml2-dev
- zlib1g-dev
- ruby-dev
- python3-venv
- sshpass
- jq
become: yes
- name: Install vagrant-libvirt Vagrant plugin
shell: "vagrant plugin install vagrant-libvirt --plugin-version={{ vagrant_libvirt_version }}"
when: not vagrant_libvirt_installed
- name: Clone netsim-tools
git:
repo: https://github.com/ipspace/netsim-tools.git
version: "{{ netsim_tools_version }}"
dest: "{{ clone_to }}"
become: yes
- name: Change owner of netsim-tools folder to current user
file:
path: "{{ clone_to }}"
owner: "{{ ansible_effective_user_id }}"
group: "{{ ansible_effective_group_id }}"
recurse: yes
become: yes
- name: Create a python virtual environment and install requirements
shell:
cmd: python3 -m venv venv
chdir: "{{ clone_to }}"
creates: "{{ clone_to }}/venv"
- name: Install requirements.txt
shell:
cmd: "{{ clone_to }}/venv/bin/pip install -r requirements.txt"
chdir: "{{ clone_to }}"
- name: Delete existing vagrant-libvirt network
shell: virsh net-undefine vagrant-libvirt && virsh net-destroy vagrant-libvirt
failed_when: False
- name: Add vagrant-libvirt virtual network from netsim-tools template
shell: "virsh net-define {{ clone_to + '/netsim/templates/provider/libvirt/vagrant-libvirt.xml' }}"

0 comments on commit 63f14cd

Please sign in to comment.