Skip to content

Latest commit

 

History

History

minecraft-testenv

Ansible Project - minecraft-testenv

This project is a collection of Ansible playbooks and roles to deploy a simple Minecraft test environment.

  • Terraform
  • Ansible
  • Python3
# Install required python packages
pip install -r requirements.txt

# Install required ansible packages
ansible-galaxy install -r requirements.yml

Read the Infrastructure section for more information on variables and providers.

ansible-playbook -i inventories/terraform playbooks/terraform.yml
ansible-playbook -i inventories/terraform playbooks/mc.yml
ansible-playbook -i inventories/terraform playbooks/terraform.yml -e state=destroy

The default domain for all the providers is terraform.test. You can change this by setting the Terraform default_domain variable, e.g. export TF_VAR_default_domain=example.com.

The domain deployed within the VMs has no effect on the DNS records made (except for the /etc/hosts provider), it is just to set a hostname. Only subdomains are passed through to the DNS provider, e.g. upstream.terraform.test would be passed through as upstream. This way, the DNS provider vars can be set to any domain.

Status: Done

Deploy No steps, use -i inventories/local for the inventory.

Status: Done

export TF_VAR_hcloud_api_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

# OPTIONAL
export TF_VAR_default_domain=terraform.test
export TF_VAR_default_datacenter=ash-dc1
export TF_VAR_network_zone=us-east

Deploy Add -e provider=hetzner to the command, e.g.

ansible-playbook -i inventories/terraform playbooks/terraform.yml -e provider=hetzner

Status: Done

Setup Variables

export TF_VAR_digitalocean_api_token=dop_v1_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

# OPTIONAL
export TF_VAR_default_domain=terraform.test
export TF_VAR_default_region=ams3
export TF_VAR_default_project="test"

Deploy Add -e provider=digitalocean to the command, e.g.

ansible-playbook -i inventories/terraform playbooks/terraform.yml -e provider=digitalocean

Status: WIP

# OPTIONAL, not needed for local libvirt, this is the default
export TF_VAR_libvirt_uri=qemu:///system
export TF_VAR_default_domain=terraform.test

Libvirt automatically creates DNS entries for the VMs, so you do not need to set up a DNS provider. To use this DNS server, you will need to set the server on your machine for the domain you used. For systems using systemd-resolved, you can use the following command:

**Deploy**
Add `-e provider=libvirt` to the command, e.g.
```bash
ansible-playbook -i inventories/terraform playbooks/terraform.yml -e provider=libvirt

Status: Done

export TF_VAR_digitalocean_api_token=dop_v1_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

export TF_VAR_digitalocean_default_domain=example.com
# OR (If you would like to use the domain ID instead of the domain name)
export TF_VAR_digitalocean_default_domain_id=123456789

Deploy Add -e dns_provider=digitalocean to the command, e.g.

ansible-playbook -i inventories/terraform playbooks/terraform.yml -e dns_provider=digitalocean

Status: Done

export TF_VAR_cloudflare_api_token=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

export TF_VAR_cloudflare_default_domain=example.com
# OR (If you would like to use the domain ID instead of the domain name)
export TF_VAR_cloudflare_default_domain_id=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Deploy Add -e dns_provider=cloudflare to the command, e.g.

ansible-playbook -i inventories/terraform playbooks/terraform.yml -e dns_provider=cloudflare

Status: Done

# OPTIONAL, these are the defaults. since this is fully local, the tfvars already have these values
export TF_VAR_vyos_ssh_user=vyos
export TF_VAR_vyos_ssh_password=vyos
export TF_VAR_vyos_ssh_port=22
export TF_VAR_vyos_ssh_ip=192.168.21.2

export TF_VAR_vyos_default_domain=example.com

Deploy Add -e dns_provider=vyos to the command, e.g.

ansible-playbook -i inventories/terraform playbooks/terraform.yml -e dns_provider=vyos

You can use this DNS for local testing by running the following command:

resolvectl dns virbr1 192.168.21.2  # Or the IP you set for the vyos_ssh_ip

Status: Done Notes: Not achieved through Terraform, this is coded into the Ansible playbook.

# No variables

Deploy Add -e dns_provider=etchosts to the command, e.g.

ansible-playbook -i inventories/terraform playbooks/terraform.yml -e dns_provider=etchosts

The playbook will prompt for your sudo password to edit the /etc/hosts file.