redfish_user_account (Resource)

This Terraform resource is used to manage user entity of the iDRAC Server. We can create, read, modify and delete an existing user using this resource.

Note: In the absence of user_id, first available user_id is assigned to the given user.

Example Usage

variables.tf

/*
Copyright (c) 2023 Dell Inc., or its subsidiaries. All Rights Reserved.

Licensed under the Mozilla Public License Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://mozilla.org/MPL/2.0/


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

variable "rack1" {
  type = map(object({
    user         = string
    password     = string
    endpoint     = string
    ssl_insecure = bool
  }))
}

terraform.tfvars

/*
Copyright (c) 2023 Dell Inc., or its subsidiaries. All Rights Reserved.

Licensed under the Mozilla Public License Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://mozilla.org/MPL/2.0/


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

rack1 = {
  "my-server-1" = {
    user         = "admin"
    password     = "passw0rd"
    endpoint     = "https://my-server-1.myawesomecompany.org"
    ssl_insecure = true
  },
  "my-server-2" = {
    user         = "admin"
    password     = "passw0rd"
    endpoint     = "https://my-server-2.myawesomecompany.org"
    ssl_insecure = true
  },
}

provider.tf

/*
Copyright (c) 2023 Dell Inc., or its subsidiaries. All Rights Reserved.

Licensed under the Mozilla Public License Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://mozilla.org/MPL/2.0/


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

terraform {
  required_providers {
    redfish = {
      version = "1.0.0"
      source  = "registry.terraform.io/dell/redfish"
    }
  }
}

main.tf

/*
Copyright (c) 2023 Dell Inc., or its subsidiaries. All Rights Reserved.

Licensed under the Mozilla Public License Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://mozilla.org/MPL/2.0/


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

resource "redfish_user_account" "rr" {
  for_each = var.rack1

  redfish_server {
    user         = each.value.user
    password     = each.value.password
    endpoint     = each.value.endpoint
    ssl_insecure = each.value.ssl_insecure
  }

  // user details for creating/modifying a user
  user_id  = "4"
  username = "test"
  password = "Test@123"
  role_id  = "Operator"
  // to set user as active or inactive
  enabled = true
}

After the successful execution of the above resource block, a new user would have got created, if not already present. It can be verified through state file.

Schema

Required

  • password (String, Sensitive) Password of the user.
  • redfish_server (Block List, Min: 1) This list contains the different redfish endpoints to manage (different servers) (see below for nested schema)
  • username (String) The name of the user.

Optional

  • enabled (Boolean) If the user is currently active or not.
  • role_id (String) Applicable values are ‘Operator’, ‘Administrator’, ‘None’, and ‘ReadOnly’. Default is “None”.
  • user_id (String) The ID of the user. Cannot be updated.

Read-Only

  • id (String) The ID of this resource.

Nested Schema for redfish_server

Required:

  • endpoint (String) This field is the endpoint where the redfish API is placed

Optional:

  • password (String) This field is the password related to the user given
  • ssl_insecure (Boolean) This field indicates if the SSL/TLS certificate must be verified
  • user (String) This field is the user to login against the redfish API