In the root of the project, there are two scripts, called run.sh and run.py.
Both support the same functions, and are meant to simplify the usage of Terraform and Ansible with this project.
The run.sh script may be faster, but it requires Bash
The run.py script requires Python3, but is more portable and has more features.
Running ansible and the run.py script require installing some dependencies via pip.
All requirements are listed in the requirements.txt file.
Even when using the run.sh script, it is recommended to install the dependencies, as they include ansible.
The installation can be either system-wide or in a virtual environment.
pip3 install -r requirements.txt
For a more in depth explanation of the commands, run the script with the -h flag.
# Show the help
./run.py -h
```shell
# Run all the commands in sequence to create the infrastructure
./run.py all -p <provider>
# Create the infrastructure
./run.py terraform init -p <provider>
# Create the infrastructure
./run.py terraform apply -p <provider>
# Destroy the infrastructure
./run.py terraform destroy -p <provider>
# Using the outputs from Terraform to configure
# hosts and private keys
./run.py terraform out -p <provider>
# Adds all the remote hosts to the known hosts
./run.py connect fingerprint
# Starts the setup process on all the hosts
./run.py ansible playbook
# Bootstraps wireguard on all the hosts
./run.py ansible up
# Shuts down wireguard on all the hosts
./run.py ansible down
# Create the infrastructure on AWS
./run.py terraform apply -p aws
# Add the terraform outputs,
# including ips and private keys,
# to the ansible inventory
./run.py terraform out -p aws
# Add the hosts to the known hosts
./run.py connect fingerprint
# Run the ansible playbook
./run.py ansible playbook
./run.py all -p aws
Although the run.sh script is the recommended way to use this project, it is possible to use Terraform and Ansible manually. Make sure the working directory is the correct one before running the commands.