Read now works, and terraform directory contains example code
This commit is contained in:
1 parent
ef498e4a72
commit
a6f1019175
43 files changed
+4341
-38
No files matched your search
@@ -0,0 +1,4 @@
|
||||
.terraform/
|
||||
.terraform.lock.hcl
|
||||
*.tfstate
|
||||
*.tfstate.*
|
||||
@@ -0,0 +1,42 @@
|
||||
# Example OpenTofu config for the hpe1810 provider
|
||||
|
||||
Run this once the switch is reachable again.
|
||||
|
||||
## 1. Build the provider
|
||||
|
||||
```bash
|
||||
cd ../terraform-provider-hpe1810
|
||||
go build -o terraform-provider-hpe1810 .
|
||||
```
|
||||
|
||||
`~/.tofurc` already has a `dev_overrides` entry pointing at that directory, so `tofu`
|
||||
picks up this locally-built binary instead of trying to fetch anything from a registry.
|
||||
|
||||
## 2. Plan
|
||||
|
||||
```bash
|
||||
cd ../terraform # this directory
|
||||
tofu plan
|
||||
```
|
||||
|
||||
No `tofu init` needed (and it would fail anyway — `local/joachimfriberg/hpe1810` isn't a
|
||||
real registry source) since `dev_overrides` bypasses that step entirely.
|
||||
|
||||
You'll see a warning about dev overrides being in effect — that's expected during local
|
||||
development, not an error.
|
||||
|
||||
## Files here
|
||||
|
||||
- `versions.tf` — `required_providers` block, points at the provider source name.
|
||||
- `provider.tf` — `provider "hpe1810"` block; all fields optional (see comments for the
|
||||
env-var fallback chain).
|
||||
- `main.tf` — the actual data source usage.
|
||||
- `outputs.tf` — prints what came back.
|
||||
|
||||
## Remember
|
||||
|
||||
- Only one login session to the switch at a time (see AGENT.md) — close the switch's web
|
||||
UI in your browser before running `tofu plan`.
|
||||
- Same proxy issue as the Python project: Go's `net/http` also respects `HTTP_PROXY`/
|
||||
`NO_PROXY`. If you get `login request returned status 502`, run
|
||||
`export NO_PROXY=192.168.2.10` (or `no_proxy=192.168.2.10`) before `tofu plan`.
|
||||
@@ -0,0 +1,17 @@
|
||||
# All 13 read-only extractors are now ported as data sources -- see
|
||||
# ~/code/experiments/hpe/terraform-provider-hpe1810/internal/provider/data_source_*.go
|
||||
# Eventually resource "hpe1810_locator" once actions/locator.py is ported.
|
||||
|
||||
data "hpe1810_system_description" "this" {}
|
||||
data "hpe1810_network_setup" "this" {}
|
||||
data "hpe1810_port_summary" "this" {}
|
||||
data "hpe1810_lldp_statistics" "this" {}
|
||||
data "hpe1810_buffered_log" "this" {}
|
||||
data "hpe1810_mac_table" "this" {}
|
||||
data "hpe1810_trunk_status" "this" {}
|
||||
data "hpe1810_loop_protection_status" "this" {}
|
||||
data "hpe1810_dual_image_status" "this" {}
|
||||
data "hpe1810_clock" "this" {}
|
||||
data "hpe1810_sntp" "this" {}
|
||||
data "hpe1810_log_configuration" "this" {}
|
||||
data "hpe1810_backup_manager" "this" {}
|
||||
@@ -0,0 +1,21 @@
|
||||
output "system_description" {
|
||||
description = "Everything read back from the switch's System Description page."
|
||||
value = data.hpe1810_system_description.this
|
||||
}
|
||||
|
||||
output "system_name" {
|
||||
value = data.hpe1810_system_description.this.name
|
||||
}
|
||||
|
||||
output "port_summary" {
|
||||
value = data.hpe1810_port_summary.this.ports
|
||||
}
|
||||
|
||||
output "port_24" {
|
||||
description = "The uplink port -- verifying it's readable without touching it."
|
||||
value = [for p in data.hpe1810_port_summary.this.ports : p if p.Interface == "24"]
|
||||
}
|
||||
|
||||
output "mac_table" {
|
||||
value = data.hpe1810_mac_table.this
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
# All three fields are optional. If omitted, each falls back to an env var,
|
||||
# then to a default -- same pattern as config.py in the Python reference
|
||||
# project (SWITCH_HOST / SWITCH_HTTPS / SWITCH_PASSWORD):
|
||||
#
|
||||
# host <- HPE1810_HOST <- "192.168.2.10"
|
||||
# https <- HPE1810_HTTPS <- false
|
||||
# password <- HPE1810_PASSWORD <- ""
|
||||
#
|
||||
# So for the switch as currently configured (no password, plain HTTP, at its
|
||||
# default IP), an empty provider block is enough:
|
||||
#
|
||||
# provider "hpe1810" {}
|
||||
#
|
||||
# The explicit values below are just to show what's available.
|
||||
|
||||
provider "hpe1810" {
|
||||
host = "192.168.2.10"
|
||||
https = false
|
||||
password = "" # switch currently has no password set
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
# Points at the locally-built provider binary, not a real registry --
|
||||
# this only resolves because of the dev_overrides block in ~/.tofurc:
|
||||
#
|
||||
# provider_installation {
|
||||
# dev_overrides {
|
||||
# "local/joachimfriberg/hpe1810" = "/home/joachimfriberg/code/experiments/hpe/terraform-provider-hpe1810"
|
||||
# }
|
||||
# direct {}
|
||||
# }
|
||||
#
|
||||
# With dev_overrides in effect, "tofu init" is not needed (and would fail,
|
||||
# since this source doesn't exist in any real registry) -- go straight to
|
||||
# "tofu plan". Before that, build the provider binary:
|
||||
#
|
||||
# cd ../terraform-provider-hpe1810 && go build -o terraform-provider-hpe1810 .
|
||||
|
||||
terraform {
|
||||
required_providers {
|
||||
hpe1810 = {
|
||||
source = "local/joachimfriberg/hpe1810"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user