| .gitignore | feat: Add initial Terraform configuration | |
| .terraform.lock.hcl | feat: Add initial Terraform configuration | |
| ansible.cfg | Refactor README to use environment variables | |
| deploy.sh | Add initial deployment script | |
| main.tf | feat: Add initial Terraform configuration | |
| playbook.yml | Enhance Netcup VPS Management setup | |
| README.md | Refactor README to use environment variables | |
| variables.tf | feat: Add initial Terraform configuration | |
Netcup VPS Management for untilde.co
This repository contains an Infrastructure as Code (IaaC) setup to provision and manage a Virtual Private Server (VPS) on Netcup for the purpose of hosting the untilde.co application.
The setup uses a combination of Terraform and Ansible to achieve the following:
- Terraform: Manages the DNS records for the
untilde.codomain. - Ansible: Configures the server, installs Docker and Docker Compose, and deploys the
untilde.coapplication from its Git repository.
Prerequisites
- Terraform installed on your local machine.
- Ansible installed on your local machine.
- A Netcup account.
- A virtual server that you have created manually in the Netcup SCP, with your SSH key added for access.
- API credentials for the Netcup CCP.
Usage
There are two parts to this setup: managing the DNS with Terraform and configuring the server with Ansible.
1. Manage DNS with Terraform
This part of the setup will configure the DNS records for your server in the Netcup CCP.
a. Configure your variables
Create a file named terraform.tfvars and add the following content, replacing the placeholder values with your actual information:
netcup_customer_number = "YOUR_CUSTOMER_NUMBER"
server_name = "NAME_OF_YOUR_SERVER"
domain_name = "your-domain.com"
b. Set your credentials
For your sensitive credentials, open your terminal and run the following commands, replacing the placeholders with your actual API keys and passwords.
export TF_VAR_netcup_ccp_api_key="YOUR_CCP_API_KEY"
export TF_VAR_netcup_ccp_api_password="YOUR_CCP_API_PASSWORD"
c. Run Terraform
-
Initialize Terraform:
terraform init -
Create an execution plan:
terraform plan -
Apply the changes:
terraform apply
2. Configure the Server with Ansible
This part of the setup will configure your server, install Docker, and deploy your application from the https://github.com/usysrc/untilde.co repository.
a. Set your server connection details
Open your terminal and run the following commands, replacing the placeholders with your server's IP address and your SSH username:
export ANSIBLE_HOST="YOUR_SERVER_IP"
export ANSIBLE_USER="YOUR_SSH_USER"
b. Run the playbook
Open your terminal and run the following command. This command creates a temporary, in-memory inventory with your server and passes it to the playbook.
ansible-playbook playbook.yml -i "$ANSIBLE_HOST," --user "$ANSIBLE_USER"
This command will connect to your server via SSH and execute the tasks defined in the playbook.
Files
main.tf: The main Terraform configuration for managing DNS.variables.tf: Contains the variable definitions for Terraform.ansible.cfg: The configuration file for Ansible.playbook.yml: The Ansible playbook that defines the server configuration tasks..gitignore: A file that tells Git which files to ignore.