This is the Terraform Provider for the Severalnines ClusterControl - Database Automation Tool.
- ClusterControl Website
- Documentation
- Support - (sign up before you create the request).
Name | Version |
---|---|
Terraform | >= 0.13.x |
ClusterControl | >= 1.9.8 |
Name | Version |
---|---|
Terraform ClusterControl Provider | >= 0.2.0 |
Name |
---|
clustercontrol_db_cluster |
clustercontrol_db_cluster_backup |
clustercontrol_db_cluster_backup_schedule |
clustercontrol_db_cluster_maintenance |
[NOTE:] If you already have ClusterControl running in your env, skip to #4
- Getting started with ClusterControl
- ClusterControl installation requirements
- Install ClusterControl
- Configure ClusterControl - Enable ClusterControl for API access by (on the ClusterControl host)
sudo vi /etc/default/cmon
and set the RPC_BIND_ADDRESSES
as shown below
RPC_BIND_ADDRESSES="10.0.0.15,127.0.0.1"
Where 10.0.0.5
is the private IP of the ClusterControl host. Restart ClusterControl service.
sudo systemctl restart cmon
- Run a quick test to make sure you can access ClusterControl via its REST API (curl or postman)
curl -c cookie.jar.txt -k 'https://10.0.0.5:9501/v2/auth' -XPOST -d '{"operation":"authenticateWithPassword","user_name":"CHANGE_ME","password":"CHANGE_ME"}'
Where username
and password
are valid login credentials for ClusterControl.
Make sure you get a response like the following. If you don't get a similar JSON
response, it means something has gone wrong.
{
"controller_id": "76936896-794a-4f5f-95ac-5c44cefb6830",
"is_superuser": true,
"request_processed": "2024-05-24T15:00:35.400Z",
"request_status": "Ok",
"debug_messages":
[
"RPC V2 authenticated user is 'username'."
],
"user":
{
"class_name": "CmonUser",
"owner_user_name": "username",
"groups":
[
{
"class_name": "CmonGroup",
"cdt_path": "/groups",
"group_name": "admins"
}
],
"timezone":
{
"class_name": "CmonTimeZone",
"name": "UTC",
"abbreviation": "UTC",
"offset": 0,
"use_dst": false
}
}
}
A cookie will be returned by ClusterControl back-end and saved in the cookie.jar.txt
per the curl command.
Execute the following additional curl command and check the response to make sure you are properly authenticated with ClusterControl.
curl -k -b cookie.jar.txt 'https://10.0.0.5:9501/v2/clusters' -XPOST -d '{"operation": "getAllClusterInfo"}'
Response should look like the following JSON
:
{
"controller_id": "76936896-794a-4f5f-95ac-5c44cefb6830",
"request_processed": "2024-05-24T15:07:25.837Z",
"request_status": "Ok",
"request_user_id": 5,
"total": 0,
"debug_messages": [
"RPC V2 authenticated user is 'username'."
]
}
Navigate to the examples folder for concrete examples on deploying database clusters of various types (MySQL/MariaDB replication or galera with ProxySQL, PostgreSql replication, MongoDB replicaset and/or sharded, Redis sentinel, Microsoft SQL server, and Elasticsearch)
Navigate to the docs folder for generated documentation on the terraform provider plugin for ClusterControl
cc_api_url="https://<cc-host-or-ip>:9501/v2"
cc_api_user="CHANGE-ME"
cc_api_user_password="CHANGE-ME"
terraform init
terraform validate
terraform plan -var-file="terraform.tfvars"
terraform apply -var-file="terraform.tfvars"
After navigating to the appropriate directory which was used to deploy a cluster:
terraform destroy -var-file="terraform.tfvars"