Update Doc and Variables

This commit is contained in:
Damien A
2024-01-02 13:15:29 +01:00
parent 00ee8e73d1
commit fb2e5422c2
10 changed files with 8 additions and 59 deletions

0
.gitignore vendored Normal file → Executable file
View File

0
LICENSE Normal file → Executable file
View File

25
README.md Normal file → Executable file
View File

@@ -76,33 +76,10 @@ Before you begin, ensure you have the following prerequisites installed and conf
The Terraform configuration will automatically trigger the Ansible playbook install_containerlab.yml after the EC2 instance is up. This playbook configures the instance with the necessary packages and settings, installs ContainerLab, and optionally clones the specified GitHub repository. The Terraform configuration will automatically trigger the Ansible playbook install_containerlab.yml after the EC2 instance is up. This playbook configures the instance with the necessary packages and settings, installs ContainerLab, and optionally clones the specified GitHub repository.
## Network Images Folder and Naming Convention ## Network Images Folder
### Network Images Folder
The `network_images` folder is intended for Docker images that will be used by ContainerLab. These images should be pre-downloaded and placed in this folder before running the Ansible playbook. During the setup process, the images will be copied to the remote `/tmp` directory of the ContainerLab host and then imported into Docker. The `network_images` folder is intended for Docker images that will be used by ContainerLab. These images should be pre-downloaded and placed in this folder before running the Ansible playbook. During the setup process, the images will be copied to the remote `/tmp` directory of the ContainerLab host and then imported into Docker.
### Naming Convention for Images
It's important to follow a specific naming convention for the images to ensure they are correctly imported into Docker. The naming convention is as follows:
`system_name_without_digit-*-tag.tar.xz`
- `system_name_without_digit`: This part of the filename should include the system name without any digits and need to be written in lower case. The system name will be converted to lowercase during the import process.
- `*`: This is a wildcard segment that can include any characters but should not contain the version or tag information.
- `tag`: This part should specify the version or tag of the image. The tag can include both lowercase and uppercase characters and digits.
#### Example
Given an image file named `cEOS64-lab-4.30.3M.tar.xz`:
- `cEOS64` will be the system name. Digits will be removed `ceos`.
- `4.30.3M` will be the tag, kept as-is.
The image will be imported into Docker with the tag `ceos:4.30.3M`.
Please ensure that all image files in the `network_images` folder conform to this naming convention for the automated process to function correctly.
## Accessing ContainerLab ## Accessing ContainerLab
- You can access the ContainerLab instance via SSH using the public IP or the DNS name provided by Route53. - You can access the ContainerLab instance via SSH using the public IP or the DNS name provided by Route53.

6
ansible/install_containerlab.yml Normal file → Executable file
View File

@@ -92,10 +92,4 @@
dest: "/tmp/{{ item | basename }}" dest: "/tmp/{{ item | basename }}"
with_fileglob: with_fileglob:
- "../network_images/*" - "../network_images/*"
when: inventory_hostname in groups['all']
- name: Import network image to Docker with specific tag
command:
cmd: "docker import /tmp/{{ item | basename }} {{ (item | basename | regex_replace('^(\\D+)-.*-(.*)\\.tar\\.xz', '\\1')) | lower }}:{{ item | basename | regex_replace('^(\\D+)-.*-(.*)\\.tar\\.xz', '\\2') }}"
loop: "{{ query('fileglob', '../network_images/*.tar.xz') }}"
when: inventory_hostname in groups['all'] when: inventory_hostname in groups['all']

25
network_images/network-images.md Normal file → Executable file
View File

@@ -1,29 +1,4 @@
# Network images # Network images
## Network Images Folder
The `network_images` folder is intended for Docker images that will be used by ContainerLab. These images should be pre-downloaded and placed in this folder before running the Ansible playbook. During the setup process, the images will be copied to the remote `/tmp` directory of the ContainerLab host and then imported into Docker.
## Naming Convention for Images
It's important to follow a specific naming convention for the images to ensure they are correctly imported into Docker. The naming convention is as follows:
`system_name_without_digit-*-tag.tar.xz`
- `system_name_without_digit`: This part of the filename should include the system name without any digits and need to be written in lower case. The system name will be converted to lowercase during the import process.
- `*`: This is a wildcard segment that can include any characters but should not contain the version or tag information.
- `tag`: This part should specify the version or tag of the image. The tag can include both lowercase and uppercase characters and digits.
### Example
Given an image file named `cEOS64-lab-4.30.3M.tar.xz`:
- `cEOS64` will be the system name. Digits will be removed `ceos`.
- `4.30.3M` will be the tag, kept as-is.
The image will be imported into Docker with the tag `ceos:4.30.3M`.
Please ensure that all image files in the `network_images` folder conform to this naming convention for the automated process to function correctly.
Arista cEOS image can be downlaoded at : arista.com Arista cEOS image can be downlaoded at : arista.com
`ceos-lab-4.30.3M.tar.xz` `ceos-lab-4.30.3M.tar.xz`

2
terraform/ec2.tf Normal file → Executable file
View File

@@ -30,7 +30,7 @@ resource "aws_security_group" "netlab_sg" {
resource "aws_instance" "containerlab_host" { resource "aws_instance" "containerlab_host" {
ami = var.AWS_AMI[var.AWS_REGION] ami = var.AWS_AMI[var.AWS_REGION]
instance_type = "t2.xlarge" instance_type = var.INSTANCE_TYPE
key_name = var.AWS_KEY_NAME key_name = var.AWS_KEY_NAME
vpc_security_group_ids = [aws_security_group.netlab_sg.id] vpc_security_group_ids = [aws_security_group.netlab_sg.id]

0
terraform/outputs.tf Normal file → Executable file
View File

0
terraform/route53-record.tf Normal file → Executable file
View File

7
terraform/terraform.tfvars.sample Normal file → Executable file
View File

@@ -1,2 +1,5 @@
AWS_ACCESS_KEY="YOURACCESSKEY" AWS_ACCESS_KEY = "YOURACCESSKEY"
AWS_SECRET_KEY="YOURACCESSTOKEN" AWS_SECRET_KEY = "YOURACCESSTOKEN"
AWS_KEY_NAME = "AWS_key_name"
AWS_KEY_LOCATION = "~/.ssh/aws_key.pem"
AWS_R53_ZONE_ID = "R53_ZONE_ID"

2
terraform/variables.tf Normal file → Executable file
View File

@@ -26,7 +26,7 @@ variable "AWS_AMI" {
} }
} }
variable "instance_type" { variable "INSTANCE_TYPE" {
type = string type = string
default = "t2.xlarge" default = "t2.xlarge"
} }