https://github.com/computestacks/terraform-cs-digitalocean
Deploy ComputeStacks on DigitalOcean
https://github.com/computestacks/terraform-cs-digitalocean
digitalocean terraform
Last synced: 8 months ago
JSON representation
Deploy ComputeStacks on DigitalOcean
- Host: GitHub
- URL: https://github.com/computestacks/terraform-cs-digitalocean
- Owner: ComputeStacks
- Created: 2021-02-17T06:40:29.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-07-08T20:38:14.000Z (almost 3 years ago)
- Last Synced: 2025-02-27T22:04:23.741Z (over 1 year ago)
- Topics: digitalocean, terraform
- Language: HCL
- Homepage:
- Size: 37.1 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Deploying ComputeStacks on Digital Ocean
Create a `terraform.tfvars` file and adjust the settings appropriately. Specifically, you will:
* Choose the appropriate package for your servers
* _NOTE:_ The packages set as the default in the `terraform.tfvars.sample` meet our minimum requirements. We do not recommend going below those, as that may prevent ComputeStacks from booting.
* Specify how many nodes you want (we recommend 1, 3, or 5). If you need more resources, consider increasing the plan size, or creating multiple availability zones.
* Choose your region
Additionally, please ensure the DigitalOcean project is created prior to running this package.
Copy `providers.tf.sample` to `providers.tf` and adjust.
## (Optional) Auto-configure DNS
You may wish to automatically configure your DNS records by using a terraform dns provider. Included here is an example file using CloudFlare, `dns_cloudflare.tf.sample`. You may copy that to `dns_cloudflare.tf` and adjust accordingly. You will also need to adjust your `providers.tf` file to include the CloudFlare modules.
By default, you will see the required DNS settings under `result/`.
## Setup Terraform
Before proceeding, ensure you have [terraform installed](https://learn.hashicorp.com/tutorials/terraform/install-cli), and then run:
```bash
terraform init
```
## Running Terraform
```bash
terraform apply
```
After terraform runs, you will see 2 newly created files under the `result/` directory.
1. `dns_settings.txt` | Your DNS settings, which must be applied prior to running the ansible package.
2. `inventory.yml` | You will need this later when configuring Ansible.
## Before Running Ansible
During the initial boot process of your new droplets, ansible will be installed. This can take a few minutes to complete.
Please ensure that this process has completed _before_ running the ansible package. You can verify that this is completed by: `tail -f /var/log/syslog`
For either distribution, you're waiting to see Ansible finish installing. This will be the last step.
You can also confirm the process has completed by ensuring `which ansible` is successful.
## Find Digital Ocean Resources
You can use [direnv](https://direnv.net/) to safely store environmental variables locally in this directory.
Once [direnv](https://direnv.net/) is installed:
1) `mv .envrc.sample .envrc`
2) add your digital ocean token, and;
3) `direnv allow .`.
We also recommend installing [jq](https://stedolan.github.io/jq/) to aid in the presentation of the json data.
### List available plans
```
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $DO_TOKEN" "https://api.digitalocean.com/v2/sizes" | jq
```
### List all regions
```
curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer $DO_TOKEN" "https://api.digitalocean.com/v2/regions" | jq
```