canonical / canonical/postgresql-operator
terraform: module has no machines set for placement
- Dominant language
- Python
- Stars
- 20
- Forks
- 36
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 30
Description
## Summary
The Terraform module supports placing PostgreSQL on a single pre-created machine via the
`machine` variable, but there is no way to place an HA (multi-unit) deployment across a set
of machines. `machine` is a single string, so explicit placement and HA are mutually
exclusive today.
## Details
At `v16/1.305.0`, `terraform/main.tf`:
```hcl
machines = var.machine != null ? [var.machine] : null
units = var.machine == null ? var.units : null
```
`variable "machine"` is described as *"Target Juju machine to deploy on"*. So a 3-unit
cluster placed on three `juju_machine` resources is not expressible — you get either
placement with one unit, or three units with provisioner-allocated machines.
This came out of #911, which asked for simplified single-VM placement; that was implemented
as the singular `machine`. This issue is the HA follow-up.
The `juju_application` resource itself already takes a set:
> `machines` (Set of String) Specify the target machines for the application's units. The
> number of machines in the set indicates the unit count for the application.
## Impact
`canonical/landscape-server-operator`'s `landscape-scalable` product module colocates its
stack on a fixed set of machines, and postgresql is one of the applications it cannot
place, alongside haproxy. Its source carries the comment:
```hcl
# machines is not supported by the external postgresql module (v16/1.165.0)
```
## Request
Add a `machines` (set of string) variable alongside the existing `machine`, e.g.:
```hcl
machines = var.machines != null ? var.machines : (var.machine != null ? [var.machine] : null)
units = (var.machines == null && var.machine == null) ? var.units : null
```
keeping `machine` working for the single-VM case from #911.
Contributor guide
Assessment
This issue has not been assessed yet.