Server infrastructure automation powered by terraform and ansible
- Export Vultr's API key as environmental variable
$ export TF_VAR_api_key="[API key]"
- Init terraform
$ terraform init
- [If importing an existing infrastructure] Import terraform state
$ terraform import vultr_instance.tunnel [instanceID]
- Confirm infrastructure changes
$ terraform plan
- Apply infrastructure changes
$ terraform apply
- Add
password_file
and skip to step 3, else continue to next step
$ touch password_file
-
Copy
group_vars/servers.yml.example
togroup_vars/servers.yml
set the appropriate config -
Install roles from ansible galaxy
$ ansible-galaxy install -r requirements.yml
- Configure
servers
inventory file
[remote]
tunnel ansible_host=tunnel.example.org ansible_user=user ansible_become_pass=secret
[local]
nas ansible_host=nas.example.org ansible_user=user ansible_become_pass=secret
[servers:children]
remote
local
- Run deployment script
$ ansible-playbook --vault-password-file=password_file -i servers site.yml
$ ansible-vault edit --vault-password-file=password_file group_vars/servers.yml
- WireGuard Site-to-Site
- WireGuard: How to access a peer’s local network
- Some Unofficial WireGuard Documentation