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: