(self, host, role)
Get a SSH connection (possibly with sudo or intermediate hosts) depending on parameters.
Get a SSH connection (possibly with sudo or intermediate hosts) depending on parameters.
Get a SSH connection ( possibly with sudo or intermediate hosts ) depending on parameters .
def get_connection_for_host(self, host, role):
        """
        Get a SSH connection (possibly with sudo or intermediate hosts) depending on parameters.
        """

        if host.name in self.connections:
            return self.connections[host.name]
        else:
            variables = host.all_variables()
            via = variables.get('opsmop_via', None)
            if via:
                via = self.hosts.get('via', None)
                if via is None:
                    raise InventoryError("host specified by 'opsmop_via' not defined in inventory")
                parent = self.get_connection_for_host(via, host, role)
                return self._form_connection(parent, role)

            return self._form_connection(host, role)
def get_connection_for_host ( self , host , role ) : if host . name in self . connections : return self . connections [ host . name ] else : variables = host . all_variables ( ) via = variables . get ( 'opsmop_via' , None ) if via : via = self . hosts . get ( 'via' , None ) if via is None : raise InventoryError ( "host specified by 'opsmop_via' not defined in inventory" ) parent = self . get_connection_for_host ( via , host , role ) return self . _form_connection ( parent , role ) return self . _form_connection ( host , role )