From d40214dc7731318deb37821ba7b64d72bf95b9fd Mon Sep 17 00:00:00 2001 From: Damien A Date: Sun, 17 Dec 2023 20:06:32 +0100 Subject: [PATCH] Add copy from Local Folder feature --- ansible/install_containerlab.yml | 9 +++++++++ terraform/ec2.tf | 9 +++++++-- terraform/variables.tf | 7 ++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ansible/install_containerlab.yml b/ansible/install_containerlab.yml index 2f24554..3a7f4e5 100644 --- a/ansible/install_containerlab.yml +++ b/ansible/install_containerlab.yml @@ -18,6 +18,7 @@ - git - tree - htop + - rsync state: latest update_cache: true @@ -75,6 +76,14 @@ become: yes when: repo_git_url | length > 0 + - name: Synchronize local directory to VM + synchronize: + src: "{{ local_dir_path }}" + dest: "/opt/containerlab/projet/" + recursive: yes + become: yes + when: local_dir_path | length > 0 + - name: Copy network images to remote /tmp directory copy: src: "{{ item }}" diff --git a/terraform/ec2.tf b/terraform/ec2.tf index 876fdd4..faf74ce 100644 --- a/terraform/ec2.tf +++ b/terraform/ec2.tf @@ -29,7 +29,7 @@ resource "aws_security_group" "netlab_sg" { } resource "aws_instance" "containerlab_host" { - ami = var.AWS_AMIS[var.AWS_REGION] + ami = var.AWS_AMI[var.AWS_REGION] instance_type = "t2.xlarge" key_name = var.AWS_KEY_NAME vpc_security_group_ids = [aws_security_group.netlab_sg.id] @@ -46,6 +46,11 @@ resource "aws_instance" "containerlab_host" { } provisioner "local-exec" { - command = "sleep 20; ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -u admin -i ../ansible/inventory --private-key ${var.AWS_KEY_LOCATION} ../ansible/install_containerlab.yml --extra-vars repo_git_url=${var.GITHUB_REPO_URL}" + command = <