Ejemplo n.º 1
0
Archivo: api.py Proyecto: dloup/enoslib
def _generate_inventory(roles):
    """Generates an inventory files from roles

    :param roles: dict of roles (roles -> list of Host)
    """
    inventory = EnosInventory(roles=roles)
    return inventory.to_ini_string()
Ejemplo n.º 2
0
 def test_address_gateway_same_user(self):
     h = Host("1.2.3.4", user="******", extra={'gateway': '4.3.2.1'})
     enos_inventory = EnosInventory(roles={"r1": [h]})
     ini = enos_inventory.to_ini_string()
     line = _find_host_line(ini, "r1")
     self.assertEqual(
         "1.2.3.4 ansible_host=1.2.3.4 ansible_ssh_common_args='-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ProxyCommand=\"ssh -W %h:%p -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -l foo 4.3.2.1\"' ansible_ssh_user='******'",
         line)
Ejemplo n.º 3
0
 def test_port(self):
     h = Host("1.2.3.4", port=2222)
     enos_inventory = EnosInventory(roles={"r1": [h]})
     ini = enos_inventory.to_ini_string()
     line = _find_host_line(ini, "r1")
     self.assertEqual(
         "1.2.3.4 ansible_host=1.2.3.4 ansible_port='2222' ansible_ssh_common_args='-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null'",
         line)
Ejemplo n.º 4
0
 def test_address_user(self):
     h = Host("1.2.3.4", user="******")
     enos_inventory = EnosInventory(roles={"r1": [h]})
     ini = enos_inventory.to_ini_string()
     line = _find_host_line(ini, "r1")
     self.assertEqual(
         "1.2.3.4 ansible_host=1.2.3.4 ansible_ssh_common_args='-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' ansible_ssh_user='******'",
         line,
     )