This terraform script will create the following resources:
- Openstack network
- Openstack security group rules
- For each student two (or five) Openstack instances with a public IP (the public ips are stored under
ips
) - For each student an individual ssh key pair will be generated (and be stored under
keys
) - For each student an zip file will be created (and stored under
packages
)
If you look for the GCP terraform configuration, take a look at the folder gcp_setup
.
- terraform (
v1.1.7+
) - puttygen (tested with Release 0.71)
- Openstack Account
We need to create the terraform.tfvars
file that contains all variables to use this terraform script:
cp terraform.tfvars.example terraform.tfvars
Now fill in all the required variables (e.g. your student names).
If you want to also send mails with the provided Python script add all information to mail_info.yaml
in the mail
folder.
The student list can be read from the yaml file with the following command: yq -r '.attendees | map("\"" + .Short + "\"") | join(", ")' mail/mail_info.yaml
.
In the first step we need to initialize all the modules and providers:
# Otherwise the project from OS_CLOUD will be used
unset OS_CLOUD
terraform init
See here how to setup a clouds.yaml
for Openstack and terraform.
Ensure that the OS_CLOUD
environment variable is unset otherwise the value of this environment variable will be used to located the cloud config.
Now we can verify everything with the plan
step: terraform plan
if everything looks fine just apply the changes: terraform apply
After the creation of the instances run ./scripts/check_connection.sh
to check that all instances are reachable with the ssh key.
Ensure that the Gmail API is activated.
virtualenv --python=python3.10 .venv
. .venv/bin/activate
cd mail
pip install -r requirements.txt
Adjust the files under mail
:
- Add all your attendees to the
mail_info.yaml
file - Adjust the mail text in
mail_template.txt
Finally send the mails and thee attachments with: python3 send_mails.py
In order to clean up everything just run: terraform destroy && rm ./keys/*.ppk