Runnable Rehost automation example for STACKIT using Terraform and Ansible.
- Provisions network/security and a VM in STACKIT via Terraform.
- Assigns a public IP and SSH key.
- Bridges to Ansible to install Java, copy a Spring Boot JAR, and run it as a
systemdservice.
The repository includes a ready-to-deploy sample Spring Boot artifact at ansible/files/springboot-app.jar.
By default, Terraform/Ansible deploy this artifact via jar_local_path = "ansible/files/springboot-app.jar".
- Terraform
>= 1.5 - Ansible
- SSH key pair available on your machine (default:
~/.ssh/id_rsaand~/.ssh/id_rsa.pub) - A STACKIT service account email (used as project owner in
target_project_owner_email) - Downloaded JSON key file for this service account (referenced via
service_account_key_path) - Permissions for the service account on folder or organization scope so project/network/compute resources can be created
- Parent container ID where the project should be created (
parent_container_id)
Authentication for this example is based on the service account JSON key file.
STACKIT_SERVICE_ACCOUNT_TOKEN is not required.
- Copy the example variables file:
cp env.tfvars.example env.tfvars- Edit
env.tfvarsand set at least:
service_account_key_pathtarget_project_owner_emailparent_container_id
bootstrap_project_id can stay as placeholder when parent_container_id is set.
- Initialize and run Terraform:
terraform init
terraform plan -var-file=env.tfvars
terraform apply -var-file=env.tfvars- After apply:
terraform output vm_public_ip
terraform output application_url- Default artifact path:
ansible/files/springboot-app.jar - To deploy a different app, replace this file or set
jar_local_pathinenv.tfvars.
terraform destroy -var-file=env.tfvarsenv.tfvars.examplecontains placeholders by design. Fill them inenv.tfvarsbefore running.- If your region uses a different image/flavor, adjust
image_idandmachine_type. ansibleis triggered automatically by Terraform viaterraform_data.