Skip to content
Snippets Groups Projects
Verified Commit 8094d3de authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

Update ContainerLab install and test

Add test topology
Add plays that run test topology, inspect, and destroy when finished
Delete unused groups gap_repos and kvm
Update README.md
parent 180bc353
No related branches found
No related tags found
No related merge requests found
Ansible playbook for deploying a containerlab node # Ansible playbook for deploying a ContainerLab node
This playbook is used to install containerlab on a VM, and test network configurations. This playbook is used to install ContainerLab on a VM, and test network configurations.
To run this playbook: To run this playbook:
...@@ -8,20 +8,16 @@ To run this playbook: ...@@ -8,20 +8,16 @@ To run this playbook:
2. Get the ip address of the new VM, and configure your ssh environment 2. Get the ip address of the new VM, and configure your ssh environment
3. Create & activate a python virtual environment and install ansible 3. Create & activate a python virtual environment and install ansible
4. Update inventory.yml so that your VM is defined in the "dev_environments" goup 4. Update inventory.yml so that your VM is defined in the "dev_environments" goup
5. Run ansible like this: ansible-playbook -i inventory.yml playbook.yml 5. update group_vars/dev_environments.yml with your gitlab.geant.net username and personal access token
6. Run ansible like this: ansible-playbook -i inventory.yml playbook.yml
note: to run ansible, you'll also need to update group_vars/dev_environments.yml with the S3 access key & secret
Containerlab project template(s) are installed from here, in the ~nat users's home directory:
https://gitlab.geant.org/nat/ansible-containerlab/-/tree/main/roles/dev_networks/files
To ssh into the nat user's shell, you'll need the containerlab-rsa private key ("b3BlbnNzaC1rZXktdjEAAAAABG5...") To ssh into the nat user's shell, you'll need the containerlab-rsa private key ("b3BlbnNzaC1rZXktdjEAAAAABG5...")
To start containerlab (e.g. project lab01): To start ContainerLab (e.g. project lab01):
1. shell into the nat user 1. shell into the nat user
2. cd lab01 2. cd lab01
3. sudo containerlab deploy 3. sudo containerlab deploy
To view the currently running containerlab status: To view the currently running ContainerLab status:
1. navigate to the same directory as above (e.g. lab01) 1. navigate to the same directory as above (e.g. lab01)
2. sudo containerlab inspect 2. sudo containerlab inspect
- name: System Setup
hosts: dev_environments
become: true
roles:
- gap_repos
s3: docker:
access_key: XXXXXXXXXXXXXXXXX registry_url: gitlab.geant.net:5005/docker/ci_registry
secret_key: XXXXXXXXXXXXXXXXX username: # first.lastname
region: eu-central-1 private_token: # some-secret-token
bucket: geant-nat-emulation-images
normal_images:
- filename: cEOS-lab-4.28.2.1F.tar
image_name: ceos
image_tag: 4.28.1.1F
vrnetlab_images:
- vm_image: vmx-bundle-18.2R1.9.tgz
integration: vmx
image_name: vrnetlab/vr-vmx
image_tag: 18.2R1.9
nat_user: nat nat_user: nat
...@@ -10,3 +10,44 @@ ...@@ -10,3 +10,44 @@
ansible.builtin.apt: ansible.builtin.apt:
pkg: pkg:
- containerlab - containerlab
- name: Log in on Docker repository
community.docker.docker_login:
registry_url: '{{ docker.registry_url }}'
username: '{{ docker.username }}'
password: '{{ docker.private_token }}'
- name: Pull vMX image from Docker repository
community.docker.docker_image:
name: '{{ docker.registry_url }}/vrnetlab/vr-vmx:18.2R1.9'
source: pull
- name: Move test topology onto remote machine
ansible.builtin.template:
src: test_topology.clab.yml
dest: /root/test_topology.clab.yml
become: true
- name: Run test topology
ansible.builtin.command:
chdir: /root
cmd: containerlab deploy
become: true
- name: Inspect current ContainerLab topology
ansible.builtin.command:
chdir: /root
cmd: containerlab inspect --format json
become: true
register: deploy_output
- name: Return ContainerLab deploy result
ansible.builtin.debug:
msg: '{{ deploy_output.stdout }}'
when: deploy_output is defined
- name: Destroy ContainerLab test environment
ansible.builtin.command:
chdir: /root
cmd: containerlab destroy
become: true
name: test_topology
topology:
kinds:
vr-vmx:
image: '{{ docker.registry_url }}/vrnetlab/vr-vmx:18.2R1.9'
nodes:
vmx1:
kind: vr-vmx
---
# tasks file for gap_repos
#
#- name: Git clone GAP test inventory
# shell: "git clone git@gitlab.geant.org:nat/gap_test_inventory.git /var/tmp/inventory"
# delegate_to: localhost
- name: Get the username running the deploy
become: false
local_action: command whoami
register: local_username
- name: Git checkout GAP Ansible repo
ansible.builtin.git:
repo: git@gitlab.geant.org:nat/uat_environment/lab_network_ansible.git
dest: /var/tmp/gap_ansible
#version: release-0.22
delegate_to: localhost
become_user: "{{ local_username.stdout }}"
- name: Git checkout GAP reference topology
ansible.builtin.git:
repo: git@gitlab.geant.org:nat/cl-topologies/reference_topology.git
dest: /var/tmp/gap_reference_topology
clone: yes
#version: release-0.22
delegate_to: localhost
become_user: "{{ local_username.stdout }}"
- name: Copy GAP Ansible on the target
ansible.builtin.copy:
src: /var/tmp/gap_ansible
dest: ~/gap_reference_topolog/gap_ansible
- name: Copy GAP Refernece topoloy on the target
ansible.builtin.copy:
src: /var/tmp/gap_reference_topology
dest: ~/
- name: Install Packages
ansible.builtin.apt:
pkg:
- qemu-kvm
- virt-manager
- libvirt-daemon-system
- virtinst
- libvirt-clients
- bridge-utils
update_cache: true
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment