fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gateway in group


From: Vu Ngoc VU
Subject: gateway in group
Date: Thu, 31 Aug 2023 12:22:53 +0200 (CEST)

Hello,

I have no idea if my previous message hit the list since I've sent it before 
confirming my registration and didn't see it in the web interface of this list 
archive.

Using Fabric latest release, I need to know how to declare an ssh gateway to a 
group (SerialGroup or ThreadingGroup) inside fabfile.py.

I've tried without success:

group = SerialGroup('host1.example.org', 'host2.example.org, 
gateway=Connection('bastion.example.org'))

Could you tell me how to do that please?

Currently, the only way I have is to do loops:

from fabric import *

bastion = 'bastion.example.org'
target_hosts = (
        'host1.example.org',
        'host2.example.org',
        'host3.example.org',
)


def get_lists_old(c):
    list_home = '/var/lib/sympa/expl'
    cmd = f'ls -1 "{list_home}"'
    connections = []
    #c.run(cmd, hide=True)
    for hostname in target_hosts:
        conn = Connection(host=hostname,gateway=Connection(bastion))
        connections.append(conn)

    with SerialGroup.from_connections(connections) as group:
        result = group.sudo(cmd)

    for conn, conn_result in result.items():
        print(conn, conn_result)


Isn't it possible to declare the common gateway directly in the group?

Thank you for you help.

Regards,


--
Vu~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]