Feature/tailscale access (#1)

* AWS_R53_ENABLED: Delete unused variable

* Add Tailscale Feature
- Removed R53 configuration
- Updated Ansible playbook to handle empty variables
- Updated Ansible playbook to use variables file
- Updated README to include updated requirements

---------

Co-authored-by: Damien A <sepales.pret0h@icloud.com>
This commit is contained in:
Damien A
2024-02-25 17:25:34 +01:00
committed by GitHub
parent a4170247b3
commit 315910772c
9 changed files with 54 additions and 85 deletions

View File

@@ -20,12 +20,6 @@ resource "aws_security_group" "netlab_sg" {
protocol = "tcp"
cidr_blocks = [var.AWS_LOCAL_IP]
}
ingress {
from_port = 50080
to_port = 50080
protocol = "tcp"
cidr_blocks = [var.AWS_LOCAL_IP]
}
}
resource "aws_instance" "containerlab_host" {
@@ -51,9 +45,11 @@ resource "aws_instance" "containerlab_host" {
provisioner "local-exec" {
command = <<EOT
sleep 20
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -u admin -i ../ansible/inventory --private-key ${var.AWS_KEY_LOCATION} ../ansible/install_containerlab.yml \
${var.GITHUB_REPO_URL != "" ? "--extra-vars repo_git_url=${var.GITHUB_REPO_URL}" : ""} \
${var.LOCAL_DIR_PATH != "" ? "--extra-vars local_dir_path=${var.LOCAL_DIR_PATH}" : ""}
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook \
-u admin \
-i ../ansible/inventory \
--private-key ${var.AWS_KEY_LOCATION} \
../ansible/install_containerlab.yml
EOT
}
}

View File

@@ -1,7 +1,3 @@
output "public_ip" {
value = aws_instance.containerlab_host.public_ip
}
output "containerlab_fqdn" {
value = var.AWS_R53_ENABLED && length(aws_route53_record.containerlab_fqdn) > 0 ? "${aws_route53_record.containerlab_fqdn[0].name}.${data.aws_route53_zone.selected.name}" : ""
}

View File

@@ -1,12 +0,0 @@
data "aws_route53_zone" "selected" {
zone_id = var.AWS_R53_ZONE_ID
}
resource "aws_route53_record" "containerlab_fqdn" {
count = var.AWS_R53_ENABLED ? 1 : 0
zone_id = var.AWS_R53_ZONE_ID
name = "containerlab"
type = "A"
ttl = "300"
records = [aws_instance.containerlab_host.public_ip]
}

View File

@@ -1,6 +1,4 @@
AWS_ACCESS_KEY = "YOURACCESSKEY"
AWS_SECRET_KEY = "YOURACCESSTOKEN"
AWS_KEY_NAME = "AWS_key_name"
AWS_KEY_LOCATION = "~/.ssh/aws_key.pem"
AWS_R53_ENABLED = "false"
AWS_R53_ZONE_ID = "R53_ZONE_ID"
AWS_KEY_LOCATION = "~/.ssh/aws_key.pem"

View File

@@ -2,27 +2,12 @@ variable "AWS_ACCESS_KEY" {}
variable "AWS_SECRET_KEY" {}
variable "AWS_KEY_NAME" {}
variable "AWS_KEY_LOCATION" {}
variable "AWS_R53_ZONE_ID" {}
variable "AWS_R53_ENABLED" {
type = bool
default = false
}
variable "AWS_LOCAL_IP" {
type = string
default = "0.0.0.0/0"
}
variable "GITHUB_REPO_URL" {
type = string
default = ""
}
variable "LOCAL_DIR_PATH" {
type = string
default = ""
}
variable "AWS_REGION" {
type = string
default = "eu-west-3"