dell / terraform-provider-redfish Goto Github PK
View Code? Open in Web Editor NEWTerraform provider for Redfish REST APIs
Home Page: https://registry.terraform.io/providers/dell/redfish/latest
License: Mozilla Public License 2.0
Terraform provider for Redfish REST APIs
Home Page: https://registry.terraform.io/providers/dell/redfish/latest
License: Mozilla Public License 2.0
FIX- Linting issue of power resource with golangci-lint configuration change
Originally posted by @Krishnan-Priyanshu in #105 (comment)
Hello,
I was wondering if you would consider bridging the terraform provider to Pulumi?
You only have one repository to maintain (this one) and the bridge will be easily updated (there are probably a way to automate that)
Take a look at the official documentation from pulumi for that : https://github.com/pulumi/pulumi-tf-provider-boilerplate ๐
terraform -v
Terraform v0.14.7
PowerEdge R640
iDRAC 9 version 4.20.20.20
redfish_bios
# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file.
resource "redfish_bios" "bios" {
redfish_server {
endpoint = "https://192.168.8.103:6443"
ssl_insecure = true
}
attributes = {
"SysProfile" = "PerfOptimized"
}
settings_apply_time = "OnReset"
action_after_apply = "ForceRestart"
}
https://gist.github.com/brutus333/950a67e89c0a099356060af3a4ea4f2e
Once the configuration is updated TF should not try to change the resource again
Terraform tried to update the resource again (even if it was compliant with the definition), so the change is not idempotent as it should be.
terraform apply
For some reason two of the files in the redfish folder are not compliant with the convention resource_redfish_XXXXXX. These are:
Need to change for:
Just leaving here this issue to keep track of enhancements that need to be done in the resource_redfish_storage_volume resource.
Comments
Things to do
The validate function for settingsApplyTime needs to be implemented.
Better handling on OnReset operations. If a job is created using terraform, and then the server is restarted manually, the new volume will be there (if the job was successful). At this point, if a terraform destroy command is issued, it will look for the new volume and destroy it rightaway, without creating a job (this scenario might be buggy for controllers that does not support Immediate opperations).
Since the iDRAC still doesn't support DELETE operation on standard tasks collection, tasks cannot be deleted in a standard way for all vendors. Here I had to implement the propietary way iDRAC manages jobs (/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/) through the redfish API. This will change in the future as soon as iDRAC redfish implementation supports that, Function to do this is common.DeleteDellJob
Please add support for macOS (darwin) builds and releases. It is super inconvenient to use a local build.
# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file.
As soon as new versions of this provider are tagged, we need to kick off a pipeline that eventually compile the provider (for windows, linux and darwing) and publish it within the packages section.
Also this is a requirement for publishing provider binaries to the terraform registry:
https://www.terraform.io/docs/registry/providers/publishing.html#github-actions-preferred-
These actions above are only the ones regarding this repo. To fully integrate with the terraform registry, all of them must be followed:
https://www.terraform.io/docs/registry/providers/publishing.html#github-actions-preferred-
Create a new datasource for getting the different storage from the Redfish API as well as all its different volumes attached to it.
New datasource
provider "redfish" {}
data "redfish_storage_volume" "storage" {
for_each = var.rack1
redfish_server {
user = each.value.user
password = each.value.password
endpoint = each.value.endpoint
ssl_insecure = each.value.ssl_insecure
}
}
Unit test cases for Bios resource
# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file.
Current master code does not compile because gofish library dependency is set to use v0.10.0 instead of v0.11.0.
This prevents the plugins system to work.
While updating BIOS setup using this provider I noticed that it created a job on the iDRAC but it did not wait for the job to finish.
IMHO the correct behavior (from TF perspective) it is to wait (sync or async) for the resource configuration to be applied.
The code can be changed to use existing method WaitForJobToFinish
# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file.
resource "redfish_bios" "bios" {
redfish_server {
endpoint = "https://192.168.8.103:6443"
ssl_insecure = true
}
attributes = {
"SysProfile" = "PerfOptimized"
}
settings_apply_time = "OnReset"
action_after_apply = "ForceRestart"
wait_to_finish = true
}
Add provider documentation inline with Terraform guidelines using tfplugindocs
tool to automatically generate documentation for redfish provider in the format required by the Terraform Registry. The plugin will read the descriptions and schema of each resource and data source in redfish provider and generate the relevant Markdown files. For more details see https://learn.hashicorp.com/tutorials/terraform/provider-release-publish.
Add a new Redfish provider resource for computer system reset. It should be able to support all the reset type operations supported by a server for e.g. On, Off, GracefulRestart, GracefulShutdown, ForceOff, ForceRestart etc.
new resource
# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file.
New acceptance tests for resource_user_account
# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file.
How should we go about booting form virtual dvd once?
resource "redfish_boot_source_override" "boot" {
for_each = var.rack1
redfish_server {
user = each.value.user
password = each.value.password
endpoint = each.value.endpoint
ssl_insecure = each.value.ssl_insecure
}
// boot source override parameters
boot_source_override_enabled = "Once"
boot_source_override_target = "UefiTarget"
boot_source_override_mode = "UEFI"
// Reset parameters to be applied after bios settings are applied
reset_type = "ForceRestart"
reset_timeout = "120"
# // The maximum amount of time to wait for the bios job to be completed
boot_source_job_timeout = "1200"
depends_on = [ redfish_virtual_media.vm ]
}
Add a new Redfish provider resource for manager reset. It should support all the reset type operations that is supported by a BMC for e.g. GracefulRestart, ForceRestart etc.
New resource
# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file.
I'm working on #15. In resource_redfish_bios.go I see that there is a function getSystemResource which resolves an instance of GoFish's service to a concrete system which I figure will be reused across multiple modules. I tried asking on StackOverflow to see if there is a good way to handle functionality shared across different resources. It would seem Go doesn't have stylistic guidance on the subject.
Right now my code is referencing getSystemResource in resource_redfish_bios.go
which I figure is undesirable. Is there a preferred way to handle this scenario?
Is there any intention of splitting out the Gofish Dell 'plugin' into its own repository?
https://github.com/dell/terraform-provider-redfish/tree/master/gofish/dell
I'm mainly asking since I'd like to import the Gofish Dell 'plugin' in another non-terraform project and possibly implement 'plugins' for other vendors.
Hello,
I currently have a dell xr4000. I would like to be able to configure my RAID disks with redfish using the provider. However, I have two systems in the /redfish/v1/Systems directory. These are my main node (XR4510c) and the witness server (XR4000w). However, the terraform provider doesn't allow me to choose which system I want to interact with. It will therefore default to the XR4000w, which has no RAID card...
Thanks in advance for your help.
When dealing with this provider, resources need to be aware of other resources, because when performing configurations, server reboots might be needed.
This causes race conditions if several resources creation are run concurrently.
To avoid this, and also to avoid the depends_on tag (Terraform recommends to use this as last resort), Hashicorp suggested to implement a global Lock used by resources when it comes to configuring a server. This will make aware one resource of the creation of other one.
Unit test case for power control
You can assign @grantcurell
Add support for expanding the Boot Options for Boot data source. The data source should also provide a list of the boot options and their details, similar to the following:
$ curl -k -s https://192.168.10.10/redfish/v1/Systems/System.Embedded.1/BootOptions/Boot0001 | python -m json.tool
{
"@odata.context": "/redfish/v1/$metadata#BootOption.BootOption",
"@odata.id": "/redfish/v1/Systems/System.Embedded.1/BootOptions/Boot0001",
"@odata.type": "#BootOption.v1_0_3.BootOption",
"BootOptionEnabled": true,
"BootOptionReference": "Boot0001",
"Description": "Current settings of the UEFI Boot option",
"DisplayName": "PXE Device 2: Integrated NIC 1 Port 1 Partition 1",
"Id": "Boot0001",
"Name": "Uefi Boot Option",
"UefiDevicePath": "VenHw(D227C733-F75F-4341-B749-4D1759EC8538)"
}
# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file.
This issue is to keep track of the implementation of VirtualMedia resource and datasource.
Resource: The user must be able to mount and unmount ISOs place on HTTP, CIFS or NFS shares.
Datasource: The user must be able to check the different virtual medias that can be used in the resource.
VirtualMedia resource implementation.
VirtualMedia datasource implementation.
In order to publish this provider to Terraform registry, some requisites need to be met according this: Publishing Providers.
Task list:
Currently, the redfish_storage_volume
allows the creation of a virtual disk on a redfish endpoint. However, there is no way to assign a physical drive to become either a global hotspare or a virtual drive hotspare.
Thanks in advance for your time to evaluate this feature request.
Add a makefile for building the provider binary and copying it to the default user plugin location.
None
Should be able to build the binary for all OS_ARCH and copy them to the default plugin path.
# build
$ make build
# install
$ make install
As of now the provider is using provider configuration as part of datasource and resource attributes to circumvent one endpoint per provider limitation.
However, a more Terraform like solution would rely on multiple providers and provider aliases: Terraform supports what is called multiple provider configuration via aliases: https://www.terraform.io/docs/language/providers/configuration.html#alias-multiple-provider-configurations
Terraform code will not look very nice since will be some repetition in the provider definition code but it will be more likely that the provider itself will continue to work. However, there are open issues on terraform project dealing with usage of for_each and count for providers code so probably there will be a fix in the near future.
For provider code duplication issue there are some other solutions like terragrunt.
All datasources and resources are affected by this change
provider "redfish" {
user = "john"
password = "password"
endpoint = "http://172.17.0.2"
ssl_insecure = true
alias = "bios1"
}
provider "redfish" {
user = "john"
password = "password"
endpoint = "http://172.17.0.3"
ssl_insecure = true
alias = "bios2"
}
data "redfish_bios" "bios_1" {
provider = redfish.bios1
}
data "redfish_bios" "bios_2" {
provider = redfish.bios2
}
I already fixed the code to allow this, if you find it valuable I can make a PR.
I have to say that the provider code is simplified by using this pattern.
Terraform Cloud Workspace Version 1.7.0
Redfish Provider Version 1.1.0
Dell R930 (D8KQRD2)
iDRAC 8
BIOS Version 2.13.0
Firmware Version 2.85.85.85
data "redfish_dell_idrac_attributes"
terraform {
required_providers {
redfish = {
source = "dell/redfish"
version = "1.1.0"
}
}
}
provider "redfish" {
user = var.idrac_username
password = var.idrac_password
}
data "redfish_dell_idrac_attributes" "idrac" {
redfish_server {
endpoint = var.r930_idrac_endpoint
ssl_insecure = true
}
}
data "redfish_bios" "bios" {
redfish_server {
endpoint = var.r930_idrac_endpoint
ssl_insecure = true
}
}
variable "idrac_username" {
type = string
sensitive = true
}
variable "idrac_password" {
type = string
sensitive = true
}
variable "r930_idrac_endpoint" {
type = string
sensitive = true
}
https://gist.github.com/robbycuenot/b1db72eb7a2e2d167498abe2ab140fe7
None
The data block should have been read and added to the state, as the BIOS attributes did.
After ~10 seconds, an unexpected EOF is received and the iDRAC attributes are not imported to the state
terraform apply
Running on terraform cloud, using a local linux agent with the official TFC container from here: https://hub.docker.com/r/hashicorp/tfc-agent/tags
Other resources work correctly, such as creating user accounts or retrieving BIOS attributes.
It is possible that this is a timeout issue, as the iDRACs tend to have slow response times.
Hi! What's the recommended way to install OS and make the initial configuration with this provider?
Looks like there is no way to pass kickstart or cloud-init files directly from the terraform.
Is the integration with user_data possible?
Or should I host a PXE server for this?
Create a new Redfish resource for provisioning manager attributes.
new resource
An example terraform plan for manager attribute configuration could be:
# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file.
resource "redfish_manager" "manager" {
for_each = var.rack1
redfish_server {
user = each.value.user
password = each.value.password
endpoint = each.value.endpoint
ssl_insecure = each.value.ssl_insecure
}
attributes = {
"SNMPAlert.1.Destination" = "192.168.10.11"
"SNMPAlert.2.Destination" = "192.168.10.12"
"SNMPAlert.3.Destination" = "192.168.10.13"
}
}
When do you plan to release v1,1?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.