Example #1
0
def contextualize(hosts: List[Host]):
    '''Fig1. Install MariaDB and Galera on a list of `hosts`.

    A `Host` is an abstract notion of unit of computation that can be
    bound to bare-metal machines, virtual machines or containers.

    '''
    run_command("apt install -y mariadb-server galera", hosts)
Example #2
0
def contextualize(rs: Roles):
    'Fig3. Install Galera on `database`, and Sysbench on `client` hosts.'
    run_command("apt install -y mariadb-server galera",
                pattern_hosts="database",
                roles=rs)
    run_command(
        "curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/script.deb.sh | bash; apt install -y sysbench",
        pattern_hosts="client",
        roles=rs)
Example #3
0
    "box": "debian/jessie64",
    "resources": {
        "machines": [{
            "role": "control1",
            "flavor": "tiny",
            "number": 1,
            "networks": ["n1", "n2"]
        }, {
            "role": "control2",
            "flavor": "tiny",
            "number": 1,
            "networks": ["n1", "n3"]
        }]
    }
}

tc = {
    "enable": True,
    "default_delay": "20ms",
    "default_rate": "1gbit",
}
inventory = os.path.join(os.getcwd(), "hosts")
provider = Enos_vagrant(provider_conf)
roles, networks = provider.init()
generate_inventory(roles, networks, inventory, check_networks=True)
#result = run_command("control*", "ping -c 1 {{hostvars['enos-1']['ansible_' + n1].ipv4.address}}", inventory)
result = run_command("control*", "date", inventory)
print(result["ok"])
emulate_network(roles, inventory, tc)
validate_network(roles, inventory)
    "resources": {
        "machines": [{
            "roles": ["control"],
            "alias": "test_machine",
            "address": "localhost",
            "extra": {
                "ansible_connection": "local"
            },
        }],
        "networks": [{
            "roles": ["local"],
            "start": "172.17.0.0",
            "end": "172.17.255.255",
            "cidr": "172.17.0.0/16",
            "gateway": "172.17.0.1",
            "dns": "172.17.0.1",
        }],
    }
}

inventory = os.path.join(os.getcwd(), "hosts")
provider = Static(Configuration.from_dictionnary(provider_conf))
roles, networks = provider.init()
generate_inventory(roles, networks, inventory, check_networks=True)
# using an inventory
result = run_command("date", pattern_hosts="control", inventory_path=inventory)
print(json.dumps(result))
# using the roles
result = run_command("date", pattern_hosts="control", roles=roles)
print(json.dumps(result))
Example #5
0
    #     nodes=2,
    #     primary_network=network_lyon
    # )
    # .add_machine(
    #     roles=["control"],
    #     cluster="chiclet",
    #     nodes=2,
    #     primary_network=network_lille
    # )
    .finalize())

provider = G5k(conf)
roles, networks = provider.init()

# install docker
run_command("apt update", roles=roles)
run_command(
    "apt install -y apt-transport-https ca-certificates curl gnupg2 software-properties-common",
    roles=roles)
run_command(
    "curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -",
    roles=roles)
run_command(
    'add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"',
    roles=roles)
run_command("apt update && apt-cache policy docker-ce", roles=roles)
run_command("apt install -y docker-ce", roles=roles)

#install docker-compose
run_command(
    "sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose",
Example #6
0
logging.basicConfig(level=logging.DEBUG)

provider_conf = {
    "backend": "libvirt",
    "box": "generic/debian9",
    "resources": {
        "machines": [{
            "roles":  ["control1"],
            "flavor": "tiny",
            "number": 1,
        },{
            "roles": ["control2"],
            "flavor": "tiny",
            "number": 1,
        }],
        "networks": [{"roles": ["rn1"], "cidr": "172.16.0.1/16"}]
    }
}

conf = Configuration.from_dictionnary(provider_conf)
provider = Enos_vagrant(conf)
roles, networks = provider.init()
discover_networks(roles, networks)
result = run_command("date",
                     pattern_hosts="control*",
                     roles=roles)
with open("result_ok", "w") as f:
    json.dump(result["ok"], f, indent=2)
with open("result_failed", "w") as f:
    json.dump(result["failed"], f, indent=2)
Example #7
0
provider_conf = {
    "backend": "libvirt",
    "box": "generic/debian9",
    "resources": {
        "machines": [{
            "roles": ["control1"],
            "flavor": "tiny",
            "number": 1,
        }, {
            "roles": ["control2"],
            "flavor": "tiny",
            "number": 1,
        }],
        "networks": [{
            "roles": ["rn1"],
            "cidr": "172.16.0.1/16"
        }]
    }
}

conf = Configuration.from_dictionnary(provider_conf)
provider = Enos_vagrant(conf)
roles, networks = provider.init()
discover_networks(roles, networks)
result = run_command("control*", "date", roles=roles)
with open("result_ok", "w") as f:
    json.dump(result["ok"], f, indent=2)
with open("result_failed", "w") as f:
    json.dump(result["failed"], f, indent=2)