aws commands aktualisiert

This commit is contained in:
Stefan Märkle 2023-05-17 20:17:32 +02:00
parent 66cdd276c2
commit 3232483945
4 changed files with 54 additions and 26 deletions

View File

@ -12,26 +12,20 @@
prompt: AWS Region to use for instance
default: "eu-central-1"
private: no
- name: aws_ami
prompt: Disk image to use for instance (default is debian buster arm64)
default: "ami-0e70ab85b58b23a77"
private: no
- name: aws_type
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-]+\\.', '') }}"
ansible_python_interpreter: /usr/bin/python3
roles:
- aws_graviton_nano_spot
- aws_graviton_nano
- name: include playbook for pihole
import_playbook: pihole.yml
- name: include playbook for pihole#
import_playbook: headscale-server.yml
- name: include playbook for wireguard server
import_playbook: wireguard_pihole_only.yml
#- name: include playbook for pihole#
# import_playbook: pihole.yml
#- name: include playbook for wireguard server
# import_playbook: wireguard_pihole_only.yml

15
headscale-server.yml Normal file
View File

@ -0,0 +1,15 @@
---
# Install headscale
- name: Install headscale
hosts: launched
remote_user: admin
become: true
vars_prompt:
- name: install_headscale
prompt: Shall the headscale server software be installed (Defaults to false)?
default: false
private: no
roles:
- role: headscale-server
when: install_headscale

View File

@ -20,21 +20,40 @@
cidr_ip: 0.0.0.0/0
register: security_group
- name: create graviton spot instance
amazon.aws.ec2:
- name: find arm64 ami for debian
amazon.aws.ec2_ami_info:
region: "{{ aws_region }}"
owners: amazon
filters:
name: "debian-11-arm64-20*"
architecture: "arm64"
register: amis
- name: Extract the most recently created AMI from the list
ansible.builtin.set_fact:
aws_ami: "{{ amis.images[-1].image_id }}"
- name: debug
debug:
var: aws_ami
- name: create graviton instance
amazon.aws.ec2_instance:
region: "{{ aws_region }}"
spot_type: persistent
spot_wait_timeout: 120
key_name: vpn_key
group_id: "{{ security_group.group_id }}"
instance_type: "{{ aws_type }}"
image: "{{ aws_ami }}"
wait: yes
name: "{{ dns_name }}"
security_group: "{{ security_group.group_id }}"
instance_type: "t4g.nano"
image_id: "{{ aws_ami }}"
instance_initiated_shutdown_behavior: terminate
network:
assign_public_ip: true
wait: true
state: running
register: graviton
- name: generate route53 dns entry for the instance
route53:
amazon.aws.route53:
command: create
overwrite: yes
zone: "{{ dns_zone_name }}"
@ -54,7 +73,7 @@
- name: Add new instance to host group
add_host:
hostname: "{{ item.public_ip }}"
hostname: "{{ item.public_ip_address }}"
groupname: launched
loop: "{{ graviton.instances }}"

View File