From 10fd7b45c879a3b5efdeefc63dc280bc6a48f12c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20M=C3=A4rkle?= Date: Wed, 16 Dec 2020 11:42:13 +0100 Subject: [PATCH] Neu mit optionalem route53 nameservereintrag --- create_aws_wireguard_server.yml | 6 ++++++ roles/aws_graviton_nano_spot/tasks/main.yml | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/create_aws_wireguard_server.yml b/create_aws_wireguard_server.yml index 13c4c1d..1cc3a0f 100644 --- a/create_aws_wireguard_server.yml +++ b/create_aws_wireguard_server.yml @@ -20,6 +20,12 @@ prompt: Instance type to request default: "t4g.nano" private: no + - name: dns_name + prompt: Which hostname shall be registered for the host (Empty = no dns, Zone needs to be route53 managed)? + default: "" + private: no + vars: + - dns_zone_name: "{{ dns_name | regex_replace('^[\\w-]+\\.', '') }}" roles: - aws_graviton_nano_spot diff --git a/roles/aws_graviton_nano_spot/tasks/main.yml b/roles/aws_graviton_nano_spot/tasks/main.yml index 005555f..3719707 100644 --- a/roles/aws_graviton_nano_spot/tasks/main.yml +++ b/roles/aws_graviton_nano_spot/tasks/main.yml @@ -29,8 +29,22 @@ image: "{{ aws_ami }}" wait: yes instance_initiated_shutdown_behavior: terminate + vpc_subnet_id: "subnet-3df70f5a" + assign_public_ip: yes register: graviton +- name: generate route53 dns entry for the instance + route53: + command: create + overwrite: yes + zone: "{{ dns_zone_name }}" + record: "{{ dns_name }}" + type: CNAME + ttl: 60 + value: "{{ item.public_dns_name }}" + loop: "{{ graviton.instances }}" + when: dns_name != "" + - name: Wait for SSH to come up delegate_to: "{{ item.public_dns_name }}" wait_for_connection: