From 5374baa99b82e66ad7c7b95bd8bd19a617352bdb Mon Sep 17 00:00:00 2001 From: Jack Lloyd-Walters Date: Thu, 27 Jun 2024 10:44:06 +0100 Subject: [PATCH] integration to use the endpoints --- anvil-python/anvil/commands/haproxy.py | 2 ++ anvil-python/anvil/provider/local/commands.py | 11 ---------- cloud/etc/deploy-haproxy/main.tf | 22 ++++++++++++++----- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/anvil-python/anvil/commands/haproxy.py b/anvil-python/anvil/commands/haproxy.py index 6d529d8..bb03cb2 100644 --- a/anvil-python/anvil/commands/haproxy.py +++ b/anvil-python/anvil/commands/haproxy.py @@ -87,6 +87,8 @@ def prompt(self, console: Console | None = None) -> None: LOG.debug(self.variables) write_answers(self.client, CONFIG_KEY, self.variables) + + def extra_tfvars(self) -> dict[str, Any]: return self.variables diff --git a/anvil-python/anvil/provider/local/commands.py b/anvil-python/anvil/provider/local/commands.py index bbc19c8..4ce6731 100644 --- a/anvil-python/anvil/provider/local/commands.py +++ b/anvil-python/anvil/provider/local/commands.py @@ -167,19 +167,12 @@ def deployment_type(self) -> tuple[str, type[Deployment]]: help="Specify additional roles, region or agent, for the " "bootstrap node. Defaults to the database role.", ) -@click.option( - "--vip", - type=click.STRING, - callback=validate_ip_address, - help="Specify the Virtual IP address.", -) @click.pass_context def bootstrap( ctx: click.Context, roles: List[Role], manifest: Path | None = None, accept_defaults: bool = False, - vip: str | None = None, ) -> None: """Bootstrap the local node. @@ -210,10 +203,6 @@ def bootstrap( if Role.DATABASE not in roles: LOG.debug("Enabling database role for bootstrap") roles.append(Role.DATABASE) - # VIP functionality requires haproxy - if Role.HAPROXY not in roles and vip: - LOG.debug("Enabling haproxy for VIP") - roles.append(Role.HAPROXY) is_region_node = any(role.is_region_node() for role in roles) is_agent_node = any(role.is_agent_node() for role in roles) is_haproxy_node = any(role.is_haproxy_node() for role in roles) diff --git a/cloud/etc/deploy-haproxy/main.tf b/cloud/etc/deploy-haproxy/main.tf index 05e766a..b7031d7 100644 --- a/cloud/etc/deploy-haproxy/main.tf +++ b/cloud/etc/deploy-haproxy/main.tf @@ -46,7 +46,7 @@ resource "juju_application" "haproxy" { } resource "juju_application" "keepalived" { - count = var.virtual_ip != "" ? 1 : 0 + count = length(var.virtual_ip) > 0 ? 1 : 0 name = "keepalived" model = data.juju_model.machine_model.name @@ -57,12 +57,22 @@ resource "juju_application" "keepalived" { base = "ubuntu@22.04" } - config = var.charm_haproxy_config + config = { + "virtual_ip": var.virtual_ip, + } } -resource "juju_integration" "haproxy_keepalived" { - count = var.virtual_ip != "" ? 1 : 0 +resource "juju_integration" "maas-region-haproxy" { + count = length(var.virtual_ip) > 0 ? 1 : 0 model = data.juju_model.machine_model.name - application_one = juju_application.haproxy.name - application_two = juju_application.keepalived[0].name + + application { + name = juju_application.haproxy.name + endpoint = "juju-info" + } + + application { + name = juju_application.keepalived.name + endpoint = "juju-info" + } } \ No newline at end of file