mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 10:59:59 +00:00
feat(mesh-cli): move the transport to SSH without moving the address
keep_address switches the connection, the user, the key and the ssh args exactly as the mesh switch does, and leaves ansible_host where it was. Against the other two transports that isolates the cost of leaving the local connection from the cost of the tunnel.
This commit is contained in:
1 file changed
+10
-1
@@ -91,9 +91,15 @@ def switch_to_mesh(
|
||||
user: str,
|
||||
private_key_file: str,
|
||||
application_id: str = DEFAULT_APPLICATION_ID,
|
||||
keep_address: bool = False,
|
||||
) -> dict[str, str]:
|
||||
"""Point every member of *mesh_name* at its mesh address over SSH.
|
||||
|
||||
Args:
|
||||
keep_address: move the connection to SSH but leave ``ansible_host`` on
|
||||
the address it already held, so a run can separate the cost of
|
||||
leaving the local connection from the cost of the tunnel.
|
||||
|
||||
Returns:
|
||||
Host to the address it was switched to. A host with no address on this
|
||||
mesh is left alone -- it is not a member, and rewriting it would
|
||||
@@ -106,7 +112,10 @@ def switch_to_mesh(
|
||||
continue
|
||||
path = host_vars_path(host_vars_dir, host)
|
||||
document = load_document(path)
|
||||
document["ansible_host"] = address
|
||||
if keep_address:
|
||||
address = str(document.get("ansible_host") or address)
|
||||
else:
|
||||
document["ansible_host"] = address
|
||||
document["ansible_connection"] = SSH_CONNECTION
|
||||
document["ansible_user"] = user
|
||||
document["ansible_ssh_private_key_file"] = private_key_file
|
||||
|
||||
Reference in new issue
Block a user