Using DC/OS Terraform Infrastructure module to spin up a "cluster"-like infrastrcuture with the following components on Azure:
-
Resource Group
-
Network
-
Network SG
-
Bootstrap Node
-
Master Node(s)
-
Private Nodes(s)
You can view all your components under the Resource Group Created (dcos-$VAR.CLUSTER_NAME
). You can use this to delete all resources if needed or your TF state gets lost.
All VMs will use the username dcos_admin
user name with the specified ssh key.
Terraform less than version 0.12, cloud credentials, and SSH keys:
If you're on a Mac environment with homebrew installed, simply run the following command:
brew install terraform
For help installing Terraform on a different OS, please see here:
You have to install the Azure CLI in order to provide credentials for the terraform provider.
Please checkout the Install the Azure CLI guide to get az
installed and running
To retrieve credentials please issue
$ az login
the output will show the subscriptions your user has permissions in.
You can insure being logged in by listing your accounts subscriptions
$ az account
[
{
"cloudName": "AzureCloud",
"id": "12345678-abcd-efgh-9876-abc123456789",
"isDefault": true,
"name": "Blah Blah Subscription",
"state": "Enabled",
"tenantId": "987654321-abcd-efgh-9876-abc123456789",
"user": {
"name": "myaccount@azuremesosphere.onmicrosoft.com",
"type": "user"
}
}
]
We have to provide the Azure subscription ID. This could be done by exporting ARM_SUBSCRIPTION_ID
.
If you do not know your subscription id use az account
to see a list of your subscriptions and copy the desired subscription id.
export ARM_SUBSCRIPTION_ID="desired-subscriptionid"
Example:
export ARM_SUBSCRIPTION_ID="12345678-abcd-efgh-9876-abc123456789"
Ensure it is set:
> echo $ARM_SUBSCRIPTION_ID
12345678-abcd-efgh-9876-abc123456789
-
Create a
main.tf
from this repo in your current working directory. Modify any Variable you see fit. See this README for defaults and/or additional variables you can use within yourmain.tf
. -
Execute the following after you have auth'd to Azure (see above):
ssh-add ~/.ssh/YOUR_PRIVATE_KEY # adds to key to auth agent
terraform init -upgrade=true
terraform plan -out plan.out
terraform apply plan.out
Check out the Azure Console under your Resource Group.
Note: The main.tf
also creates a local inventory file you can use with Ansible. You will just need to provide an ansbile.cfg
in the same directory or it will use your default one.
ansible -m ping all -i inventory
-
Be sure that you are auth'd to Azure (see above)
-
Execute following:
terraform destroy