terraform-provider-hpeuxi

command module
v0.1.0-alpha.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 5 Imported by: 0

README

Terraform Provider HPEUXI - Terraform Provider HPEUXI

Introduction

A repository to hold the HPEUXI terraform provider.

Installation

See the INSTALL.md file for instructions on how to install the binaries manually.

Prerequisites

  1. Terraform version >= v1.7.0 and 64-bit install terraform
  2. A Greenlake API client to authenticate against UXI configuration API.
  3. Terraform basics. Terraform Introduction

Usage

Ensure correct terraform version

Make sure you have the correct Terraform version installed; It must be v1.7.0 or later:

terraform version
Create manifest

Create a Terraform file in your working directory, and reference the desired provider version from the terraform registry. For more information please consult the documentation:

terraform {
    required_providers {
        hpeuxi = {
            source  = "aruba-uxi/hpeuxi"
            version = ">= 0.0.0-pre.alpha.3"
        }
    }
    required_version = ">= 1.7.0"
}

# create a group
resource "hpeuxi_group" "my_group" {
    name = "level_1"
}

# import a sensor
resource "hpeuxi_sensor" "my_sensor" {
    name = "my_sensor_name"

    lifecycle {
        prevent_destroy = true
    }
}

import {
    to = hpeuxi_sensor.my_sensor
    id = "my_sensor_id"
}

# assign the sensor to a group
resource "hpeuxi_sensor_group_assignment" "my_uxi_sensor_group_assignment" {
    sensor_id = hpeuxi_sensor.my_sensor.id
    group_id = hpeuxi_group.my_group.id
}
Export API client credentials as environment variables
export HPEUXI_CLIENT_ID=<hpeuxi_client_id>
export HPEUXI_CLIENT_SECRET=<hpeuxi_client_secret>

To override the host against which the API requests are made, use the env var as shown below, else UXI production is used as the default.

export HPEUXI_HOST_OVERRIDE=api.staging.capedev.io
Initialize Terraform working directory:
> terraform init
Plan resources
> terraform plan
Deploy resources
> terraform apply

Development

.terraformrc for local development

Add the appropriate terraform provider dev override to your ~/.terraformrc file to ensure that that terraform operations is performed against the local provider.

Example ~/.terraformrc file

provider_installation {
  dev_overrides {
      "registry.terraform.io/aruba-uxi/hpeuxi" = "/Users/<user>/go/bin"
  }
  direct {}
}
Justfile

Install just. This is used to run the recipes defined in the Justfile. Run the following to see a helpful list of commands:

just help
Installing the provider locally
just setup-run

Running Local Test Suite

just test

Updating the client

The client used for interfacing with the UXI backend is autogenerated using an API Spec and openapitools. In order to download the latest spec and generate the corresponding client, run:

just generate-config-api-client

Running Acceptance Tests

Create a file called acceptance.env containing the following environment variables. See the table below for a description of the fields.

ACCEPTANCE_AGENT_ID=<acceptance_agent_id>
ACCEPTANCE_AGENT_PROVISION_HOST=<acceptance_agent_provision_host>
ACCEPTANCE_AGENT_PROVISION_SERIAL=<acceptance_agent_provision_serial>
ACCEPTANCE_CUSTOMER_ID=<acceptance_customer_id>
ACCEPTANCE_GROUP_ID_ROOT=<acceptance_group_id_root>
ACCEPTANCE_SENSOR_ID=<acceptance_sensor_id>
ACCEPTANCE_SERVICE_TEST_ID=<acceptance_service_test_id>
ACCEPTANCE_WIRED_NETWORK_ID=<acceptance_wired_network_id>
ACCEPTANCE_WIRELESS_NETWORK_ID=<acceptance_wireless_network_id>
HPEUXI_CLIENT_ID=<hpeuxi_client_id>
HPEUXI_CLIENT_SECRET=<hpeuxi_client_secret>
HPEUXI_HOST_OVERRIDE=<hpeuxi_host_override>
HPEUXI_PROVISION_TOKEN=<hpeuxi_provision_token>
Environment Variable Description
ACCEPTANCE_AGENT_ID ID of an agent on customer.
ACCEPTANCE_AGENT_PROVISION_SERIAL Serial number of an agent to be provisioned. Keep this constant between test runs to avoid excessive provisioning of agents.
ACCEPTANCE_CUSTOMER_ID ID of the customer against which the acceptance tests will be run.
ACCEPTANCE_GROUP_ID_ROOT ID of the root group.
ACCEPTANCE_SENSOR_ID ID of a hardware sensor on the customer.
ACCEPTANCE_SERVICE_TEST_ID ID of a service test on the customer.
ACCEPTANCE_WIRED_NETWORK_ID ID of a wired network on the customer.
ACCEPTANCE_WIRELESS_NETWORK_ID ID of a wireless network on the customer.
DEVICE_GATEWAY_HOST Host address of the device gateway (against which the agent provisioning will be run)
HPEUXI_CLIENT_ID CLIENT_ID component of the UXI API credentials as obtained from Greenlake.
HPEUXI_CLIENT_SECRET CLIENT_SECRET component of the UXI API credentials as obtained from Greenlake.
HPEUXI_HOST_OVERRIDE Host address of the configuration API (against which the configuration API requests will be run).
HPEUXI_PROVISION_TOKEN Token used to provision agents for the given customer.

Then run the following command to execute the acceptance tests against the given customer.

just acceptance-tests acceptance.env

Building and Distribution

All builds must be signed by HPE before distribution. Read the Notices Report and ensure a report is added to every build which is published All open source sourcecode must be submitted to the HPE DSM to make this available for customers to download on request.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL