A Terraform provider for managing Turing Pi's Baseboard Management Controller (BMC). This plugin enables you to interact with Turing Pi's BMC API, allowing you to:
- Authenticate with the BMC.
- Control power for specific nodes.
- Flash firmware to nodes.
- Retrieve system and node statuses.
- Power Management: Turn nodes on/off and check power status.
- Firmware Management: Flash firmware to individual nodes.
- Node Interaction: Communicate with nodes via the Turing Pi BMC API.
- Go Installation: Install Go from the official Go website.
- Terraform: Install Terraform from the official Terraform website.
-
Clone the repository:
git clone https://github.com/jfreed-dev/terraform-provider-turingpi.git cd terraform-provider-turingpi
-
Initialize the Go module:
go mod tidy
-
Build the binary:
go build -o terraform-provider-turingpi
-
Create the plugin directory:
mkdir -p ~/.terraform.d/plugins/local/turingpi/turingpi/1.0.0/linux_amd64/
-
Move the binary to the plugin directory:
mv terraform-provider-turingpi ~/.terraform.d/plugins/local/turingpi/turingpi/1.0.0/linux_amd64/
-
Create the plugin directory:
mkdir -p %APPDATA%\terraform.d\plugins\local\turingpi\turingpi\1.0.0\windows_amd64\
-
Move the binary to the plugin directory:
move terraform-provider-turingpi terraform-provider-turingpi.exe move terraform-provider-turingpi.exe %APPDATA%\terraform.d\plugins\local\turingpi\turingpi\1.0.0\windows_amd64\
-
Define the Provider in Terraform Configuration Create a
main.tf
file with the following content:terraform { required_providers { turingpi = { source = "local/turingpi/turingpi" version = "1.0.0" } } } provider "turingpi" { username = "your-username" password = "your-password" }
-
Initialize Terraform:
terraform init
-
Apply Your Configuration:
terraform apply
-
Use
go run
to quickly test changes:go run main.go
-
Enable verbose logs during Terraform runs:
export TF_LOG=DEBUG terraform apply
To avoid exposing sensitive credentials directly in your Terraform configuration files:
-
Use Environment Variables: Terraform supports environment variables for sensitive provider configurations. You can set
TURINGPI_USERNAME
andTURINGPI_PASSWORD
in your shell environment:export TURINGPI_USERNAME=root export TURINGPI_PASSWORD=turing
Update the provider block to use environment variables:
provider "turingpi" {}
-
Use a
.tfvars
File: Store credentials in a separate.tfvars
file:username = "root" password = "turing"
Reference the
.tfvars
file in your Terraform commands:terraform apply -var-file="credentials.tfvars"
Here’s a complete example of a Terraform configuration using the Turing Pi provider:
terraform {
required_providers {
turingpi = {
source = "local/turingpi/turingpi"
version = "1.0.0"
}
}
}
provider "turingpi" {
username = "root" # Replace with your BMC username
password = "turing" # Replace with your BMC password
}
resource "turingpi_power" "node1" {
node = 1
state = true # Turn on power for node 1
}
resource "turingpi_flash" "node1" {
node = 1
firmware_file = "/path/to/firmware.img"
}