1
0
Fork
You've already forked vps
0
terraform and ansible setup for untilde.co
  • Shell 52.5%
  • HCL 47.5%
2025年08月16日 20:46:35 +02:00
.gitignore feat: Add initial Terraform configuration 2025年08月16日 20:29:26 +02:00
.terraform.lock.hcl feat: Add initial Terraform configuration 2025年08月16日 20:29:26 +02:00
ansible.cfg Refactor README to use environment variables 2025年08月16日 20:46:10 +02:00
deploy.sh Add initial deployment script 2025年08月16日 20:46:35 +02:00
main.tf feat: Add initial Terraform configuration 2025年08月16日 20:29:26 +02:00
playbook.yml Enhance Netcup VPS Management setup 2025年08月16日 20:39:13 +02:00
README.md Refactor README to use environment variables 2025年08月16日 20:46:10 +02:00
variables.tf feat: Add initial Terraform configuration 2025年08月16日 20:29:26 +02:00

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.co domain.
  • Ansible: Configures the server, installs Docker and Docker Compose, and deploys the untilde.co application 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

  1. Initialize Terraform:

    terraform init
    
  2. Create an execution plan:

    terraform plan
    
  3. 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.