{ "cells": [ { "cell_type": "markdown", "id": "preceding-chorus", "metadata": {}, "source": [ "# Remote actions and variables\n", "\n", "Changing the state of remote resources\n", "\n", "\n", "---\n", "- Website: https://discovery.gitlabpages.inria.fr/enoslib/index.html\n", "- Instant chat: https://framateam.org/enoslib\n", "---\n", "\n", "\n", "\n", "\n", "**Prerequisites**:\n", "- A Grid'5000 account\n", "- A working EnOSlib environment and Jupyter (not included in EnOSlib dependencies, but `pip install jupyterlab` will install it)\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "handed-forestry", "metadata": {}, "outputs": [], "source": [ "import enoslib as en\n", "\n", "# get some logging info\n", "import logging\n", "logging.basicConfig(level=logging.INFO)" ] }, { "cell_type": "markdown", "id": "provincial-madonna", "metadata": {}, "source": [ "## Setup on Grid'5000\n", "\n", "### Describing the resources\n", "\n", "For the purpose of the tutorial we'll reserve 2 nodes in the production environment.\n", "\n", "First we build a configuration object describing the wanted resources: `machines` and `networks`." ] }, { "cell_type": "code", "execution_count": 2, "id": "southeast-feature", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " <style> .enoslib {\n", " width: auto;\n", "}\n", "\n", ".enoslib_object {\n", " width: auto;\n", " font-size: 1em;\n", " line-height: 1.5;\n", " background-color: rgb(250, 249, 249);\n", " font-family: 'Segoe UI';\n", " color: black;\n", "}\n", "\n", ".enoslib_object ul {\n", " padding: 0;\n", "}\n", "\n", ".enoslib_object input+label {\n", " margin-bottom: 0%;\n", "}\n", "\n", ".object_name {\n", " padding: 6px 0 6px 3px;\n", " border-bottom-width: 1px;\n", " border-bottom-style: solid;\n", " border-bottom-color: #777;\n", " color: #555;\n", "}\n", "\n", ".object_name>div,\n", ".object_name>ul {\n", " display: inline;\n", " margin-top: 0;\n", " margin-bottom: 0;\n", "}\n", "\n", "ul {\n", " list-style: none !important;\n", " padding: 3px !important;\n", " margin: 0 !important;\n", "}\n", "\n", "input.att+label {\n", " display: inline-block;\n", " /*width: 140px;*/\n", " color: rgb(36, 35, 35);\n", " font-weight: 500;\n", " padding: 4px 0 2px 0;\n", "}\n", "\n", "input.att:enabled+label {\n", " cursor: pointer;\n", " width: auto;\n", "}\n", "\n", "input.att {\n", " display: none;\n", "}\n", "\n", "input.att+label:before {\n", " display: inline-block;\n", " content: '►';\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", "}\n", "\n", "input.att:checked+label:before {\n", " content: '▼';\n", "}\n", "\n", "input.att:disabled+label:before {\n", " content: none;\n", "}\n", "\n", "input.att+label>span {\n", " display: inline-block;\n", " margin-left: 4px;\n", "}\n", "\n", "input.att+label>span.len {\n", " font-size: small;\n", "}\n", "\n", "input.att:checked+label>span.len {\n", " display: none;\n", "}\n", "\n", "label+span {\n", " color: rgb(70, 69, 69);\n", "}\n", "\n", "input.att~ul {\n", " display: none;\n", "}\n", "\n", "input.att:checked~ul {\n", " display: block;\n", "}\n", "\n", "table {\n", " width: auto;\n", " border-collapse: collapse;\n", " margin: 2%;\n", "}\n", "\n", "td,\n", "th {\n", " padding: 8px;\n", " height: 15px;\n", " font-size: small;\n", "}\n", "\n", "td {\n", " text-align: left !important;\n", " color: rgb(160, 160, 160)\n", "}\n", "\n", "th {\n", " text-align: center;\n", " color: black;\n", "}\n", "\n", "input~ul {\n", " position: relative;\n", " left: 25px;\n", "}\n", "\n", "input.att~table {\n", " display: none;\n", "}\n", "\n", "input.att:checked~table {\n", " display: block;\n", "} </style>\n", " <div class=\"enoslib\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.infra.enos_g5k.configuration.Configuration'>@0x7fce1b88add0\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"dhcp-f1f540f0-888a-49e2-a0fe-68c84c13685d\" class=\"att\" disabled=\"\">\n", " <label for=\"dhcp-f1f540f0-888a-49e2-a0fe-68c84c13685d\">\n", " <span>dhcp</span>\n", " </label>\n", " <span>True</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"force_deploy-719b447b-ea5b-4806-8f0c-93ab3f241dc0\" class=\"att\" disabled=\"\">\n", " <label for=\"force_deploy-719b447b-ea5b-4806-8f0c-93ab3f241dc0\">\n", " <span>force_deploy</span>\n", " </label>\n", " <span>False</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"env_name-37cb5a1f-c17e-4138-b9ff-a8f14fef8008\" class=\"att\" disabled=\"\">\n", " <label for=\"env_name-37cb5a1f-c17e-4138-b9ff-a8f14fef8008\">\n", " <span>env_name</span>\n", " </label>\n", " <span>debian10-x64-nfs</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"job_name-302f4e41-4492-4c02-805b-19496c39967f\" class=\"att\" disabled=\"\">\n", " <label for=\"job_name-302f4e41-4492-4c02-805b-19496c39967f\">\n", " <span>job_name</span>\n", " </label>\n", " <span>rsd-01</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"job_type-9fa88abf-b8d9-41cf-820e-04ee761fb68f\" class=\"att\" disabled=\"\">\n", " <label for=\"job_type-9fa88abf-b8d9-41cf-820e-04ee761fb68f\">\n", " <span>job_type</span>\n", " </label>\n", " <span>allow_classic_ssh</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"key-f5c5e87f-7de6-43f8-9f6e-93d01b18dd00\" class=\"att\" disabled=\"\">\n", " <label for=\"key-f5c5e87f-7de6-43f8-9f6e-93d01b18dd00\">\n", " <span>key</span>\n", " </label>\n", " <span>/home/msimonin/.ssh/id_rsa.pub</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"queue-bbdde893-49c2-412c-a90b-508455a568e6\" class=\"att\" disabled=\"\">\n", " <label for=\"queue-bbdde893-49c2-412c-a90b-508455a568e6\">\n", " <span>queue</span>\n", " </label>\n", " <span>default</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"walltime-7a80807d-8704-4b2d-8b00-65746ff66140\" class=\"att\" disabled=\"\">\n", " <label for=\"walltime-7a80807d-8704-4b2d-8b00-65746ff66140\">\n", " <span>walltime</span>\n", " </label>\n", " <span>02:00:00</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"resources-b76560ff-a5d5-4152-b556-562deb0dfcba\" class=\"att\">\n", " <label for=\"resources-b76560ff-a5d5-4152-b556-562deb0dfcba\">resources <span class=\"len\">(2)</span></label>\n", " <ul id=\"resources\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"machines-96e512e4-a0d8-451a-8a1d-7da5c4efa388\" class=\"att\">\n", " <label for=\"machines-96e512e4-a0d8-451a-8a1d-7da5c4efa388\">machines <span class=\"len\">(2)</span></label>\n", " <ul id=\"machines\">\n", " <table><thead><tr><th>roles</th><th>primary_network</th><th>secondary_networks</th><th>cluster</th><th>nodes</th></tr></thead><tbody><tr><td><ul><li>control</li></ul></td><td>n1</td><td></td><td>parasilo</td><td>1</td></tr><tr><td><ul><li>compute</li></ul></td><td>n1</td><td></td><td>parasilo</td><td>1</td></tr></tbody></table>\n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"networks-f2b5f78a-a4e3-4099-a58c-f1c3b91467cd\" class=\"att\">\n", " <label for=\"networks-f2b5f78a-a4e3-4099-a58c-f1c3b91467cd\">networks <span class=\"len\">(1)</span></label>\n", " <ul id=\"networks\">\n", " <table><thead><tr><th>id</th><th>type</th><th>roles</th><th>site</th></tr></thead><tbody><tr><td>n1</td><td>prod</td><td><ul><li>my_network</li></ul></td><td>rennes</td></tr></tbody></table>\n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </div>\n", " </div>\n", " " ], "text/plain": [ "Conf@0x7fce1b88add0\n", "{\n", " \"dhcp\": true,\n", " \"force_deploy\": false,\n", " \"env_name\": \"debian10-x64-nfs\",\n", " \"job_name\": \"rsd-01\",\n", " \"job_type\": \"allow_classic_ssh\",\n", " \"key\": \"/home/msimonin/.ssh/id_rsa.pub\",\n", " \"queue\": \"default\",\n", " \"walltime\": \"02:00:00\",\n", " \"resources\": {\n", " \"machines\": [\n", " {\n", " \"roles\": [\n", " \"control\"\n", " ],\n", " \"primary_network\": \"n1\",\n", " \"secondary_networks\": [],\n", " \"cluster\": \"parasilo\",\n", " \"nodes\": 1\n", " },\n", " {\n", " \"roles\": [\n", " \"compute\"\n", " ],\n", " \"primary_network\": \"n1\",\n", " \"secondary_networks\": [],\n", " \"cluster\": \"parasilo\",\n", " \"nodes\": 1\n", " }\n", " ],\n", " \"networks\": [\n", " {\n", " \"id\": \"n1\",\n", " \"type\": \"prod\",\n", " \"roles\": [\n", " \"my_network\"\n", " ],\n", " \"site\": \"rennes\"\n", " }\n", " ]\n", " }\n", "}" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "network = en.G5kNetworkConf(id=\"n1\", type=\"prod\", roles=[\"my_network\"], site=\"rennes\")\n", "\n", "conf = (\n", " en.G5kConf.from_settings(job_type=\"allow_classic_ssh\", job_name=\"rsd-01\")\n", " .add_network_conf(network)\n", " .add_machine(\n", " roles=[\"control\"], cluster=\"parasilo\", nodes=1, primary_network=network\n", " )\n", " .add_machine(\n", " roles=[\"compute\"],\n", " cluster=\"parasilo\",\n", " nodes=1,\n", " primary_network=network,\n", " )\n", " .finalize()\n", ")\n", "conf" ] }, { "cell_type": "markdown", "id": "proprietary-cricket", "metadata": {}, "source": [ "### Reserving the resources\n", "\n", "We can pass the `Configuration` object to the `G5k` provider. The provider is responsible to turn the abstract resource description into a et concrete resources." ] }, { "cell_type": "code", "execution_count": 3, "id": "approximate-sharp", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading rsd-01 from lille\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading rsd-01 from luxembourg\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading rsd-01 from lyon\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading rsd-01 from nancy\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading rsd-01 from nantes\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading rsd-01 from rennes\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading rsd-01 from sophia\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Submitting {'name': 'rsd-01', 'types': ['allow_classic_ssh'], 'resources': \"{cluster='parasilo'}/nodes=1+{cluster='parasilo'}/nodes=1,walltime=02:00:00\", 'command': 'sleep 31536000', 'queue': 'default'} on rennes\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Waiting for 1816344 on rennes [2021-08-27 10:00:58]\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Waiting for 1816344 on rennes [2021-08-27 10:00:58]\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:All jobs are Running !\n" ] } ], "source": [ "provider = en.G5k(conf)\n", "roles, networks = provider.init()" ] }, { "cell_type": "markdown", "id": "unnecessary-romantic", "metadata": {}, "source": [ "Inspecting the ressources we own for the experiment's lifetime:\n", "\n", "- roles: this is somehow a dictionnary whose keys are the role names and the associated values are the corresponding list of hosts\n", "- networks: similar to roles bu£t for networks" ] }, { "cell_type": "code", "execution_count": 4, "id": "formal-valley", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " <style> .enoslib {\n", " width: auto;\n", "}\n", "\n", ".enoslib_object {\n", " width: auto;\n", " font-size: 1em;\n", " line-height: 1.5;\n", " background-color: rgb(250, 249, 249);\n", " font-family: 'Segoe UI';\n", " color: black;\n", "}\n", "\n", ".enoslib_object ul {\n", " padding: 0;\n", "}\n", "\n", ".enoslib_object input+label {\n", " margin-bottom: 0%;\n", "}\n", "\n", ".object_name {\n", " padding: 6px 0 6px 3px;\n", " border-bottom-width: 1px;\n", " border-bottom-style: solid;\n", " border-bottom-color: #777;\n", " color: #555;\n", "}\n", "\n", ".object_name>div,\n", ".object_name>ul {\n", " display: inline;\n", " margin-top: 0;\n", " margin-bottom: 0;\n", "}\n", "\n", "ul {\n", " list-style: none !important;\n", " padding: 3px !important;\n", " margin: 0 !important;\n", "}\n", "\n", "input.att+label {\n", " display: inline-block;\n", " /*width: 140px;*/\n", " color: rgb(36, 35, 35);\n", " font-weight: 500;\n", " padding: 4px 0 2px 0;\n", "}\n", "\n", "input.att:enabled+label {\n", " cursor: pointer;\n", " width: auto;\n", "}\n", "\n", "input.att {\n", " display: none;\n", "}\n", "\n", "input.att+label:before {\n", " display: inline-block;\n", " content: '►';\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", "}\n", "\n", "input.att:checked+label:before {\n", " content: '▼';\n", "}\n", "\n", "input.att:disabled+label:before {\n", " content: none;\n", "}\n", "\n", "input.att+label>span {\n", " display: inline-block;\n", " margin-left: 4px;\n", "}\n", "\n", "input.att+label>span.len {\n", " font-size: small;\n", "}\n", "\n", "input.att:checked+label>span.len {\n", " display: none;\n", "}\n", "\n", "label+span {\n", " color: rgb(70, 69, 69);\n", "}\n", "\n", "input.att~ul {\n", " display: none;\n", "}\n", "\n", "input.att:checked~ul {\n", " display: block;\n", "}\n", "\n", "table {\n", " width: auto;\n", " border-collapse: collapse;\n", " margin: 2%;\n", "}\n", "\n", "td,\n", "th {\n", " padding: 8px;\n", " height: 15px;\n", " font-size: small;\n", "}\n", "\n", "td {\n", " text-align: left !important;\n", " color: rgb(160, 160, 160)\n", "}\n", "\n", "th {\n", " text-align: center;\n", " color: black;\n", "}\n", "\n", "input~ul {\n", " position: relative;\n", " left: 25px;\n", "}\n", "\n", "input.att~table {\n", " display: none;\n", "}\n", "\n", "input.att:checked~table {\n", " display: block;\n", "} </style>\n", " <div class=\"enoslib\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.Roles'>@0x7fce29eada90\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"control-027e1b91-a73c-43ca-826e-378033edb7b3\" class=\"att\">\n", " <label for=\"control-027e1b91-a73c-43ca-826e-378033edb7b3\">control <span class=\"len\">(1)</span></label>\n", " <ul id=\"control\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"parasilo-20.rennes.grid5000.fr-300070ff-11d0-4da4-800d-f2d1b92e889e\" class=\"att\">\n", " <label for=\"parasilo-20.rennes.grid5000.fr-300070ff-11d0-4da4-800d-f2d1b92e889e\">parasilo-20.rennes.grid5000.fr </label>\n", " <ul id=\"parasilo-20.rennes.grid5000.fr\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.Host'>@0x7fce1ae7e690\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"address-a82a614c-2bf8-492a-8da3-5fe4e9cb1674\" class=\"att\" disabled=\"\">\n", " <label for=\"address-a82a614c-2bf8-492a-8da3-5fe4e9cb1674\">\n", " <span>address</span>\n", " </label>\n", " <span>parasilo-20.rennes.grid5000.fr</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"alias-d8443bc8-57cf-42f7-b8ed-629184006414\" class=\"att\" disabled=\"\">\n", " <label for=\"alias-d8443bc8-57cf-42f7-b8ed-629184006414\">\n", " <span>alias</span>\n", " </label>\n", " <span>parasilo-20.rennes.grid5000.fr</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"user-fb997e74-9bea-4592-8e24-4a6494a24654\" class=\"att\" disabled=\"\">\n", " <label for=\"user-fb997e74-9bea-4592-8e24-4a6494a24654\">\n", " <span>user</span>\n", " </label>\n", " <span>root</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"keyfile-b04a509f-a4cf-413c-b606-a0fa52f13fe7\" class=\"att\" disabled=\"\">\n", " <label for=\"keyfile-b04a509f-a4cf-413c-b606-a0fa52f13fe7\">\n", " <span>keyfile</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"port-43ed4191-2cb7-4971-8aca-77ea339f6015\" class=\"att\" disabled=\"\">\n", " <label for=\"port-43ed4191-2cb7-4971-8aca-77ea339f6015\">\n", " <span>port</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"extra-881c37c7-c933-4714-b90b-2153078b8926\" class=\"att\">\n", " <label for=\"extra-881c37c7-c933-4714-b90b-2153078b8926\">extra <span class=\"len\">(0)</span></label>\n", " <ul id=\"extra\">\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"net_devices-60b8bac2-f870-4694-b952-cbe76763ab0f\" class=\"att\">\n", " <label for=\"net_devices-60b8bac2-f870-4694-b952-cbe76763ab0f\">net_devices <span class=\"len\">(0)</span></label>\n", " <ul id=\"net_devices\">\n", " \n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </div>\n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"compute-73cc2dde-95a8-4ebd-9c3b-325f1d168bbb\" class=\"att\">\n", " <label for=\"compute-73cc2dde-95a8-4ebd-9c3b-325f1d168bbb\">compute <span class=\"len\">(1)</span></label>\n", " <ul id=\"compute\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"parasilo-22.rennes.grid5000.fr-3ae44034-bca8-4c29-9b11-bbd2dee0c6e9\" class=\"att\">\n", " <label for=\"parasilo-22.rennes.grid5000.fr-3ae44034-bca8-4c29-9b11-bbd2dee0c6e9\">parasilo-22.rennes.grid5000.fr </label>\n", " <ul id=\"parasilo-22.rennes.grid5000.fr\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.Host'>@0x7fce1ae7e810\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"address-cde30d08-fa7c-4f98-bb99-56306006e942\" class=\"att\" disabled=\"\">\n", " <label for=\"address-cde30d08-fa7c-4f98-bb99-56306006e942\">\n", " <span>address</span>\n", " </label>\n", " <span>parasilo-22.rennes.grid5000.fr</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"alias-1256986c-55f1-43c0-88ea-a7f4cfdd1999\" class=\"att\" disabled=\"\">\n", " <label for=\"alias-1256986c-55f1-43c0-88ea-a7f4cfdd1999\">\n", " <span>alias</span>\n", " </label>\n", " <span>parasilo-22.rennes.grid5000.fr</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"user-e477be81-9545-4fb2-bf73-66319a8a06d4\" class=\"att\" disabled=\"\">\n", " <label for=\"user-e477be81-9545-4fb2-bf73-66319a8a06d4\">\n", " <span>user</span>\n", " </label>\n", " <span>root</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"keyfile-75c5bb2e-3088-418e-881b-9b91c4a788ac\" class=\"att\" disabled=\"\">\n", " <label for=\"keyfile-75c5bb2e-3088-418e-881b-9b91c4a788ac\">\n", " <span>keyfile</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"port-84c0ccfa-6441-4a3c-b2ed-e447291e0883\" class=\"att\" disabled=\"\">\n", " <label for=\"port-84c0ccfa-6441-4a3c-b2ed-e447291e0883\">\n", " <span>port</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"extra-cbd3917a-c6f3-4c21-aef2-378b6fc0667b\" class=\"att\">\n", " <label for=\"extra-cbd3917a-c6f3-4c21-aef2-378b6fc0667b\">extra <span class=\"len\">(0)</span></label>\n", " <ul id=\"extra\">\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"net_devices-71444285-df95-4547-b4ff-5706192a8178\" class=\"att\">\n", " <label for=\"net_devices-71444285-df95-4547-b4ff-5706192a8178\">net_devices <span class=\"len\">(0)</span></label>\n", " <ul id=\"net_devices\">\n", " \n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </div>\n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </div>\n", " </div>\n", " " ], "text/plain": [ "{'control': [Host(address='parasilo-20.rennes.grid5000.fr', alias='parasilo-20.rennes.grid5000.fr', user='root', keyfile=None, port=None, extra={}, net_devices=set())], 'compute': [Host(address='parasilo-22.rennes.grid5000.fr', alias='parasilo-22.rennes.grid5000.fr', user='root', keyfile=None, port=None, extra={}, net_devices=set())]}" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "roles" ] }, { "cell_type": "code", "execution_count": 5, "id": "split-colombia", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[Host(address='parasilo-20.rennes.grid5000.fr', alias='parasilo-20.rennes.grid5000.fr', user='root', keyfile=None, port=None, extra={}, net_devices=set())]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# list of host on a given role\n", "roles[\"control\"]" ] }, { "cell_type": "code", "execution_count": 6, "id": "owned-duration", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " <style> .enoslib {\n", " width: auto;\n", "}\n", "\n", ".enoslib_object {\n", " width: auto;\n", " font-size: 1em;\n", " line-height: 1.5;\n", " background-color: rgb(250, 249, 249);\n", " font-family: 'Segoe UI';\n", " color: black;\n", "}\n", "\n", ".enoslib_object ul {\n", " padding: 0;\n", "}\n", "\n", ".enoslib_object input+label {\n", " margin-bottom: 0%;\n", "}\n", "\n", ".object_name {\n", " padding: 6px 0 6px 3px;\n", " border-bottom-width: 1px;\n", " border-bottom-style: solid;\n", " border-bottom-color: #777;\n", " color: #555;\n", "}\n", "\n", ".object_name>div,\n", ".object_name>ul {\n", " display: inline;\n", " margin-top: 0;\n", " margin-bottom: 0;\n", "}\n", "\n", "ul {\n", " list-style: none !important;\n", " padding: 3px !important;\n", " margin: 0 !important;\n", "}\n", "\n", "input.att+label {\n", " display: inline-block;\n", " /*width: 140px;*/\n", " color: rgb(36, 35, 35);\n", " font-weight: 500;\n", " padding: 4px 0 2px 0;\n", "}\n", "\n", "input.att:enabled+label {\n", " cursor: pointer;\n", " width: auto;\n", "}\n", "\n", "input.att {\n", " display: none;\n", "}\n", "\n", "input.att+label:before {\n", " display: inline-block;\n", " content: '►';\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", "}\n", "\n", "input.att:checked+label:before {\n", " content: '▼';\n", "}\n", "\n", "input.att:disabled+label:before {\n", " content: none;\n", "}\n", "\n", "input.att+label>span {\n", " display: inline-block;\n", " margin-left: 4px;\n", "}\n", "\n", "input.att+label>span.len {\n", " font-size: small;\n", "}\n", "\n", "input.att:checked+label>span.len {\n", " display: none;\n", "}\n", "\n", "label+span {\n", " color: rgb(70, 69, 69);\n", "}\n", "\n", "input.att~ul {\n", " display: none;\n", "}\n", "\n", "input.att:checked~ul {\n", " display: block;\n", "}\n", "\n", "table {\n", " width: auto;\n", " border-collapse: collapse;\n", " margin: 2%;\n", "}\n", "\n", "td,\n", "th {\n", " padding: 8px;\n", " height: 15px;\n", " font-size: small;\n", "}\n", "\n", "td {\n", " text-align: left !important;\n", " color: rgb(160, 160, 160)\n", "}\n", "\n", "th {\n", " text-align: center;\n", " color: black;\n", "}\n", "\n", "input~ul {\n", " position: relative;\n", " left: 25px;\n", "}\n", "\n", "input.att~table {\n", " display: none;\n", "}\n", "\n", "input.att:checked~table {\n", " display: block;\n", "} </style>\n", " <div class=\"enoslib\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.Host'>@0x7fce1ae7e690\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"address-31458927-1150-41de-adab-d0373384c329\" class=\"att\" disabled=\"\">\n", " <label for=\"address-31458927-1150-41de-adab-d0373384c329\">\n", " <span>address</span>\n", " </label>\n", " <span>parasilo-20.rennes.grid5000.fr</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"alias-44b1686a-b6a2-4499-bab9-ea531a19bb8f\" class=\"att\" disabled=\"\">\n", " <label for=\"alias-44b1686a-b6a2-4499-bab9-ea531a19bb8f\">\n", " <span>alias</span>\n", " </label>\n", " <span>parasilo-20.rennes.grid5000.fr</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"user-78edc58d-c2f8-4635-aabd-6a888acb4d47\" class=\"att\" disabled=\"\">\n", " <label for=\"user-78edc58d-c2f8-4635-aabd-6a888acb4d47\">\n", " <span>user</span>\n", " </label>\n", " <span>root</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"keyfile-be8733ee-2c70-48a6-8178-6021f8530a8e\" class=\"att\" disabled=\"\">\n", " <label for=\"keyfile-be8733ee-2c70-48a6-8178-6021f8530a8e\">\n", " <span>keyfile</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"port-f0a7c6c5-d31d-402f-a845-97a4c29300ba\" class=\"att\" disabled=\"\">\n", " <label for=\"port-f0a7c6c5-d31d-402f-a845-97a4c29300ba\">\n", " <span>port</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"extra-cb7f65cc-289e-4cd6-9f76-903d9a9e0e26\" class=\"att\">\n", " <label for=\"extra-cb7f65cc-289e-4cd6-9f76-903d9a9e0e26\">extra <span class=\"len\">(0)</span></label>\n", " <ul id=\"extra\">\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"net_devices-bd0c3439-ccb5-42a1-95fd-87a0be142e66\" class=\"att\">\n", " <label for=\"net_devices-bd0c3439-ccb5-42a1-95fd-87a0be142e66\">net_devices <span class=\"len\">(0)</span></label>\n", " <ul id=\"net_devices\">\n", " \n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </div>\n", " </div>\n", " " ], "text/plain": [ "Host(address='parasilo-20.rennes.grid5000.fr', alias='parasilo-20.rennes.grid5000.fr', user='root', keyfile=None, port=None, extra={}, net_devices=set())" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# a single host\n", "roles[\"control\"][0]" ] }, { "cell_type": "code", "execution_count": 7, "id": "sacred-valuable", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "WARNING:enoslib.infra.enos_g5k.objects:gateway is not yet implemented for <class 'enoslib.infra.enos_g5k.objects.G5kEnosProd6Network'> on the G5k side\n" ] }, { "data": { "text/html": [ "\n", " <style> .enoslib {\n", " width: auto;\n", "}\n", "\n", ".enoslib_object {\n", " width: auto;\n", " font-size: 1em;\n", " line-height: 1.5;\n", " background-color: rgb(250, 249, 249);\n", " font-family: 'Segoe UI';\n", " color: black;\n", "}\n", "\n", ".enoslib_object ul {\n", " padding: 0;\n", "}\n", "\n", ".enoslib_object input+label {\n", " margin-bottom: 0%;\n", "}\n", "\n", ".object_name {\n", " padding: 6px 0 6px 3px;\n", " border-bottom-width: 1px;\n", " border-bottom-style: solid;\n", " border-bottom-color: #777;\n", " color: #555;\n", "}\n", "\n", ".object_name>div,\n", ".object_name>ul {\n", " display: inline;\n", " margin-top: 0;\n", " margin-bottom: 0;\n", "}\n", "\n", "ul {\n", " list-style: none !important;\n", " padding: 3px !important;\n", " margin: 0 !important;\n", "}\n", "\n", "input.att+label {\n", " display: inline-block;\n", " /*width: 140px;*/\n", " color: rgb(36, 35, 35);\n", " font-weight: 500;\n", " padding: 4px 0 2px 0;\n", "}\n", "\n", "input.att:enabled+label {\n", " cursor: pointer;\n", " width: auto;\n", "}\n", "\n", "input.att {\n", " display: none;\n", "}\n", "\n", "input.att+label:before {\n", " display: inline-block;\n", " content: '►';\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", "}\n", "\n", "input.att:checked+label:before {\n", " content: '▼';\n", "}\n", "\n", "input.att:disabled+label:before {\n", " content: none;\n", "}\n", "\n", "input.att+label>span {\n", " display: inline-block;\n", " margin-left: 4px;\n", "}\n", "\n", "input.att+label>span.len {\n", " font-size: small;\n", "}\n", "\n", "input.att:checked+label>span.len {\n", " display: none;\n", "}\n", "\n", "label+span {\n", " color: rgb(70, 69, 69);\n", "}\n", "\n", "input.att~ul {\n", " display: none;\n", "}\n", "\n", "input.att:checked~ul {\n", " display: block;\n", "}\n", "\n", "table {\n", " width: auto;\n", " border-collapse: collapse;\n", " margin: 2%;\n", "}\n", "\n", "td,\n", "th {\n", " padding: 8px;\n", " height: 15px;\n", " font-size: small;\n", "}\n", "\n", "td {\n", " text-align: left !important;\n", " color: rgb(160, 160, 160)\n", "}\n", "\n", "th {\n", " text-align: center;\n", " color: black;\n", "}\n", "\n", "input~ul {\n", " position: relative;\n", " left: 25px;\n", "}\n", "\n", "input.att~table {\n", " display: none;\n", "}\n", "\n", "input.att:checked~table {\n", " display: block;\n", "} </style>\n", " <div class=\"enoslib\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.Networks'>@0x7fce28128b90\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"my_network-5cafdb7e-a8bb-452f-aa8a-b7a34e17e128\" class=\"att\">\n", " <label for=\"my_network-5cafdb7e-a8bb-452f-aa8a-b7a34e17e128\">my_network <span class=\"len\">(2)</span></label>\n", " <ul id=\"my_network\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"172.16.96.0/20-6a506478-5820-424d-bc72-25133598f15e\" class=\"att\">\n", " <label for=\"172.16.96.0/20-6a506478-5820-424d-bc72-25133598f15e\">172.16.96.0/20 </label>\n", " <ul id=\"172.16.96.0/20\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.infra.enos_g5k.objects.G5kEnosProd4Network'>@0x7fce1b8a6350\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"network-7ccbe398-2a62-4b9e-aa2d-580c43b91bb9\" class=\"att\" disabled=\"\">\n", " <label for=\"network-7ccbe398-2a62-4b9e-aa2d-580c43b91bb9\">\n", " <span>network</span>\n", " </label>\n", " <span>172.16.96.0/20</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"gateway-20e60d43-e2a1-4950-b0e8-e578b1af7f52\" class=\"att\" disabled=\"\">\n", " <label for=\"gateway-20e60d43-e2a1-4950-b0e8-e578b1af7f52\">\n", " <span>gateway</span>\n", " </label>\n", " <span>172.16.111.254</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"dns-3f466420-db10-4e26-8302-f50ec2b07067\" class=\"att\" disabled=\"\">\n", " <label for=\"dns-3f466420-db10-4e26-8302-f50ec2b07067\">\n", " <span>dns</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"free_ips-3aabcb2a-d347-483c-84ee-03ca3c60026b\" class=\"att\">\n", " <label for=\"free_ips-3aabcb2a-d347-483c-84ee-03ca3c60026b\">free_ips <span class=\"len\">(0)</span></label>\n", " <ul id=\"free_ips\">\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"free_macs-1336c020-5692-486e-a16e-f6150aeca0e4\" class=\"att\">\n", " <label for=\"free_macs-1336c020-5692-486e-a16e-f6150aeca0e4\">free_macs <span class=\"len\">(0)</span></label>\n", " <ul id=\"free_macs\">\n", " \n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </div>\n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"2001:660:4406:700::/64-e39893ef-e7f6-46c8-8d88-2bc27e8090d6\" class=\"att\">\n", " <label for=\"2001:660:4406:700::/64-e39893ef-e7f6-46c8-8d88-2bc27e8090d6\">2001:660:4406:700::/64 </label>\n", " <ul id=\"2001:660:4406:700::/64\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.infra.enos_g5k.objects.G5kEnosProd6Network'>@0x7fce1ae0a110\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"network-93656db8-a658-4b7d-9c09-0aebacbe7324\" class=\"att\" disabled=\"\">\n", " <label for=\"network-93656db8-a658-4b7d-9c09-0aebacbe7324\">\n", " <span>network</span>\n", " </label>\n", " <span>2001:660:4406:700::/64</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"gateway-1a9bb442-799e-4375-9973-a3620b4351cb\" class=\"att\" disabled=\"\">\n", " <label for=\"gateway-1a9bb442-799e-4375-9973-a3620b4351cb\">\n", " <span>gateway</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"dns-56e3cf8a-0f70-43f5-84cf-b6610ffef989\" class=\"att\" disabled=\"\">\n", " <label for=\"dns-56e3cf8a-0f70-43f5-84cf-b6610ffef989\">\n", " <span>dns</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"free_ips-8dffaa20-8f71-4ae9-814c-85d53b5b7c5e\" class=\"att\">\n", " <label for=\"free_ips-8dffaa20-8f71-4ae9-814c-85d53b5b7c5e\">free_ips <span class=\"len\">(0)</span></label>\n", " <ul id=\"free_ips\">\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"free_macs-6e473ef4-8a50-4863-a251-dbb52fbed9da\" class=\"att\">\n", " <label for=\"free_macs-6e473ef4-8a50-4863-a251-dbb52fbed9da\">free_macs <span class=\"len\">(0)</span></label>\n", " <ul id=\"free_macs\">\n", " \n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </div>\n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </div>\n", " </div>\n", " " ], "text/plain": [ "{'my_network': [<enoslib.infra.enos_g5k.objects.G5kEnosProd4Network object at 0x7fce1b8a6350>, <enoslib.infra.enos_g5k.objects.G5kEnosProd6Network object at 0x7fce1ae0a110>]}" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "networks" ] }, { "cell_type": "markdown", "id": "c9868257-ef58-4e01-af68-1857c842bbce", "metadata": {}, "source": [ "`provider.init` is idempotent. In the Grid'5000 case, you can call it several time in a row. The same reservation will reloaded and the roles and networks will be the same." ] }, { "cell_type": "code", "execution_count": 8, "id": "3700807f-45f4-4590-86ed-e8dcfadc8c61", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading rsd-01 from lille\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading rsd-01 from luxembourg\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading rsd-01 from lyon\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading rsd-01 from nancy\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading rsd-01 from nantes\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading rsd-01 from rennes\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading 1816344 from rennes\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading rsd-01 from sophia\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Waiting for 1816344 on rennes [2021-08-27 10:00:58]\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:All jobs are Running !\n" ] }, { "data": { "text/html": [ "\n", " <style> .enoslib {\n", " width: auto;\n", "}\n", "\n", ".enoslib_object {\n", " width: auto;\n", " font-size: 1em;\n", " line-height: 1.5;\n", " background-color: rgb(250, 249, 249);\n", " font-family: 'Segoe UI';\n", " color: black;\n", "}\n", "\n", ".enoslib_object ul {\n", " padding: 0;\n", "}\n", "\n", ".enoslib_object input+label {\n", " margin-bottom: 0%;\n", "}\n", "\n", ".object_name {\n", " padding: 6px 0 6px 3px;\n", " border-bottom-width: 1px;\n", " border-bottom-style: solid;\n", " border-bottom-color: #777;\n", " color: #555;\n", "}\n", "\n", ".object_name>div,\n", ".object_name>ul {\n", " display: inline;\n", " margin-top: 0;\n", " margin-bottom: 0;\n", "}\n", "\n", "ul {\n", " list-style: none !important;\n", " padding: 3px !important;\n", " margin: 0 !important;\n", "}\n", "\n", "input.att+label {\n", " display: inline-block;\n", " /*width: 140px;*/\n", " color: rgb(36, 35, 35);\n", " font-weight: 500;\n", " padding: 4px 0 2px 0;\n", "}\n", "\n", "input.att:enabled+label {\n", " cursor: pointer;\n", " width: auto;\n", "}\n", "\n", "input.att {\n", " display: none;\n", "}\n", "\n", "input.att+label:before {\n", " display: inline-block;\n", " content: '►';\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", "}\n", "\n", "input.att:checked+label:before {\n", " content: '▼';\n", "}\n", "\n", "input.att:disabled+label:before {\n", " content: none;\n", "}\n", "\n", "input.att+label>span {\n", " display: inline-block;\n", " margin-left: 4px;\n", "}\n", "\n", "input.att+label>span.len {\n", " font-size: small;\n", "}\n", "\n", "input.att:checked+label>span.len {\n", " display: none;\n", "}\n", "\n", "label+span {\n", " color: rgb(70, 69, 69);\n", "}\n", "\n", "input.att~ul {\n", " display: none;\n", "}\n", "\n", "input.att:checked~ul {\n", " display: block;\n", "}\n", "\n", "table {\n", " width: auto;\n", " border-collapse: collapse;\n", " margin: 2%;\n", "}\n", "\n", "td,\n", "th {\n", " padding: 8px;\n", " height: 15px;\n", " font-size: small;\n", "}\n", "\n", "td {\n", " text-align: left !important;\n", " color: rgb(160, 160, 160)\n", "}\n", "\n", "th {\n", " text-align: center;\n", " color: black;\n", "}\n", "\n", "input~ul {\n", " position: relative;\n", " left: 25px;\n", "}\n", "\n", "input.att~table {\n", " display: none;\n", "}\n", "\n", "input.att:checked~table {\n", " display: block;\n", "} </style>\n", " <div class=\"enoslib\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.Roles'>@0x7fce409daa10\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"control-89077330-80ea-4087-a95e-c3b9467c3c92\" class=\"att\">\n", " <label for=\"control-89077330-80ea-4087-a95e-c3b9467c3c92\">control <span class=\"len\">(1)</span></label>\n", " <ul id=\"control\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"parasilo-20.rennes.grid5000.fr-ea082844-eb57-4eb9-b40e-ae82711d6a1b\" class=\"att\">\n", " <label for=\"parasilo-20.rennes.grid5000.fr-ea082844-eb57-4eb9-b40e-ae82711d6a1b\">parasilo-20.rennes.grid5000.fr </label>\n", " <ul id=\"parasilo-20.rennes.grid5000.fr\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.Host'>@0x7fce1be98990\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"address-43189790-3d23-47e8-b8c7-ab17e355e2ad\" class=\"att\" disabled=\"\">\n", " <label for=\"address-43189790-3d23-47e8-b8c7-ab17e355e2ad\">\n", " <span>address</span>\n", " </label>\n", " <span>parasilo-20.rennes.grid5000.fr</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"alias-271a569d-2742-429f-9306-ce492e194959\" class=\"att\" disabled=\"\">\n", " <label for=\"alias-271a569d-2742-429f-9306-ce492e194959\">\n", " <span>alias</span>\n", " </label>\n", " <span>parasilo-20.rennes.grid5000.fr</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"user-6fb5b998-e89d-4bd8-81cd-a3b7c48cbb72\" class=\"att\" disabled=\"\">\n", " <label for=\"user-6fb5b998-e89d-4bd8-81cd-a3b7c48cbb72\">\n", " <span>user</span>\n", " </label>\n", " <span>root</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"keyfile-0c152e8c-4f23-412f-bc3f-a200b5d89f3f\" class=\"att\" disabled=\"\">\n", " <label for=\"keyfile-0c152e8c-4f23-412f-bc3f-a200b5d89f3f\">\n", " <span>keyfile</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"port-1fd283c4-784e-4fc3-a2a6-724e3fc23513\" class=\"att\" disabled=\"\">\n", " <label for=\"port-1fd283c4-784e-4fc3-a2a6-724e3fc23513\">\n", " <span>port</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"extra-6312b589-a7f4-46fe-864b-558ae7539a4a\" class=\"att\">\n", " <label for=\"extra-6312b589-a7f4-46fe-864b-558ae7539a4a\">extra <span class=\"len\">(0)</span></label>\n", " <ul id=\"extra\">\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"net_devices-5b83d077-1f55-4a51-b29c-d943206f7a79\" class=\"att\">\n", " <label for=\"net_devices-5b83d077-1f55-4a51-b29c-d943206f7a79\">net_devices <span class=\"len\">(0)</span></label>\n", " <ul id=\"net_devices\">\n", " \n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </div>\n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"compute-f50d65e4-3b5b-413f-9e9d-53423d6d2d63\" class=\"att\">\n", " <label for=\"compute-f50d65e4-3b5b-413f-9e9d-53423d6d2d63\">compute <span class=\"len\">(1)</span></label>\n", " <ul id=\"compute\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"parasilo-22.rennes.grid5000.fr-8e509339-5c57-4651-b4fb-4271cfb664a9\" class=\"att\">\n", " <label for=\"parasilo-22.rennes.grid5000.fr-8e509339-5c57-4651-b4fb-4271cfb664a9\">parasilo-22.rennes.grid5000.fr </label>\n", " <ul id=\"parasilo-22.rennes.grid5000.fr\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.Host'>@0x7fce1afe2a90\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"address-513afaa0-c126-47e1-a3af-9e4318937cf5\" class=\"att\" disabled=\"\">\n", " <label for=\"address-513afaa0-c126-47e1-a3af-9e4318937cf5\">\n", " <span>address</span>\n", " </label>\n", " <span>parasilo-22.rennes.grid5000.fr</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"alias-ef9f83f3-24e4-49e6-a64f-1537b80492e4\" class=\"att\" disabled=\"\">\n", " <label for=\"alias-ef9f83f3-24e4-49e6-a64f-1537b80492e4\">\n", " <span>alias</span>\n", " </label>\n", " <span>parasilo-22.rennes.grid5000.fr</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"user-201118a3-1943-4a5b-9ca3-c62b50cd0b13\" class=\"att\" disabled=\"\">\n", " <label for=\"user-201118a3-1943-4a5b-9ca3-c62b50cd0b13\">\n", " <span>user</span>\n", " </label>\n", " <span>root</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"keyfile-721c2bad-bdce-454f-8d8e-fd9c99dab913\" class=\"att\" disabled=\"\">\n", " <label for=\"keyfile-721c2bad-bdce-454f-8d8e-fd9c99dab913\">\n", " <span>keyfile</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"port-4bad15ff-1d05-4140-a2c0-01dd66bcef8a\" class=\"att\" disabled=\"\">\n", " <label for=\"port-4bad15ff-1d05-4140-a2c0-01dd66bcef8a\">\n", " <span>port</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"extra-3086af3d-898e-42c4-b463-26dd96fe4122\" class=\"att\">\n", " <label for=\"extra-3086af3d-898e-42c4-b463-26dd96fe4122\">extra <span class=\"len\">(0)</span></label>\n", " <ul id=\"extra\">\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"net_devices-be582c7e-0efb-45b1-847f-6e3ecca10e70\" class=\"att\">\n", " <label for=\"net_devices-be582c7e-0efb-45b1-847f-6e3ecca10e70\">net_devices <span class=\"len\">(0)</span></label>\n", " <ul id=\"net_devices\">\n", " \n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </div>\n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </div>\n", " </div>\n", " " ], "text/plain": [ "{'control': [Host(address='parasilo-20.rennes.grid5000.fr', alias='parasilo-20.rennes.grid5000.fr', user='root', keyfile=None, port=None, extra={}, net_devices=set())], 'compute': [Host(address='parasilo-22.rennes.grid5000.fr', alias='parasilo-22.rennes.grid5000.fr', user='root', keyfile=None, port=None, extra={}, net_devices=set())]}" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "roles, networks = provider.init()\n", "roles" ] }, { "cell_type": "code", "execution_count": 9, "id": "rapid-skating", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "[WARNING]: No inventory was parsed, only implicit localhost is available\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "PLAY [all] ***********************************************************************************************************************************************************************************\n", "\n", "TASK [hostname] ******************************************************************************************************************************************************************************\n", " [started TASK: hostname on parasilo-20.rennes.grid5000.fr]\n", " [started TASK: hostname on parasilo-22.rennes.grid5000.fr]\n", "changed: [parasilo-22.rennes.grid5000.fr]\n", "changed: [parasilo-20.rennes.grid5000.fr]\n", "\n", "PLAY [Gather facts for all hosts] ************************************************************************************************************************************************************\n", "\n", "TASK [Gathering Facts] ***********************************************************************************************************************************************************************\n", "ok: [parasilo-22.rennes.grid5000.fr]\n", "ok: [parasilo-20.rennes.grid5000.fr]\n", "\n", "TASK [setup] *********************************************************************************************************************************************************************************\n", "ok: [parasilo-22.rennes.grid5000.fr]\n", "ok: [parasilo-20.rennes.grid5000.fr]\n", "\n", "PLAY [Utils functions] ***********************************************************************************************************************************************************************\n", "\n", "TASK [Gathering Facts] ***********************************************************************************************************************************************************************\n", "ok: [parasilo-22.rennes.grid5000.fr]\n", "ok: [parasilo-20.rennes.grid5000.fr]\n", "\n", "TASK [utils : include] ***********************************************************************************************************************************************************************\n", "included: /home/msimonin/workspace/repos/enoslib/enoslib/ansible/roles/utils/tasks/check_network.yml for parasilo-20.rennes.grid5000.fr, parasilo-22.rennes.grid5000.fr\n", "\n", "TASK [utils : Dump network information in a file] ********************************************************************************************************************************************\n", "changed: [parasilo-20.rennes.grid5000.fr]\n", "\n", "TASK [utils : Create the fake interfaces] ****************************************************************************************************************************************************\n", "skipping: [parasilo-20.rennes.grid5000.fr]\n", "skipping: [parasilo-22.rennes.grid5000.fr]\n", "\n", "PLAY RECAP ***********************************************************************************************************************************************************************************\n", "parasilo-20.rennes.grid5000.fr : ok=5 changed=1 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0 \n", "parasilo-22.rennes.grid5000.fr : ok=4 changed=0 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0 \n", "\n" ] }, { "data": { "text/html": [ "\n", " <style> .enoslib {\n", " width: auto;\n", "}\n", "\n", ".enoslib_object {\n", " width: auto;\n", " font-size: 1em;\n", " line-height: 1.5;\n", " background-color: rgb(250, 249, 249);\n", " font-family: 'Segoe UI';\n", " color: black;\n", "}\n", "\n", ".enoslib_object ul {\n", " padding: 0;\n", "}\n", "\n", ".enoslib_object input+label {\n", " margin-bottom: 0%;\n", "}\n", "\n", ".object_name {\n", " padding: 6px 0 6px 3px;\n", " border-bottom-width: 1px;\n", " border-bottom-style: solid;\n", " border-bottom-color: #777;\n", " color: #555;\n", "}\n", "\n", ".object_name>div,\n", ".object_name>ul {\n", " display: inline;\n", " margin-top: 0;\n", " margin-bottom: 0;\n", "}\n", "\n", "ul {\n", " list-style: none !important;\n", " padding: 3px !important;\n", " margin: 0 !important;\n", "}\n", "\n", "input.att+label {\n", " display: inline-block;\n", " /*width: 140px;*/\n", " color: rgb(36, 35, 35);\n", " font-weight: 500;\n", " padding: 4px 0 2px 0;\n", "}\n", "\n", "input.att:enabled+label {\n", " cursor: pointer;\n", " width: auto;\n", "}\n", "\n", "input.att {\n", " display: none;\n", "}\n", "\n", "input.att+label:before {\n", " display: inline-block;\n", " content: '►';\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", "}\n", "\n", "input.att:checked+label:before {\n", " content: '▼';\n", "}\n", "\n", "input.att:disabled+label:before {\n", " content: none;\n", "}\n", "\n", "input.att+label>span {\n", " display: inline-block;\n", " margin-left: 4px;\n", "}\n", "\n", "input.att+label>span.len {\n", " font-size: small;\n", "}\n", "\n", "input.att:checked+label>span.len {\n", " display: none;\n", "}\n", "\n", "label+span {\n", " color: rgb(70, 69, 69);\n", "}\n", "\n", "input.att~ul {\n", " display: none;\n", "}\n", "\n", "input.att:checked~ul {\n", " display: block;\n", "}\n", "\n", "table {\n", " width: auto;\n", " border-collapse: collapse;\n", " margin: 2%;\n", "}\n", "\n", "td,\n", "th {\n", " padding: 8px;\n", " height: 15px;\n", " font-size: small;\n", "}\n", "\n", "td {\n", " text-align: left !important;\n", " color: rgb(160, 160, 160)\n", "}\n", "\n", "th {\n", " text-align: center;\n", " color: black;\n", "}\n", "\n", "input~ul {\n", " position: relative;\n", " left: 25px;\n", "}\n", "\n", "input.att~table {\n", " display: none;\n", "}\n", "\n", "input.att:checked~table {\n", " display: block;\n", "} </style>\n", " <div class=\"enoslib\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.Roles'>@0x7fce1a2e5110\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"control-41946fc0-ebeb-4ae4-95c8-ef7ba85c490a\" class=\"att\">\n", " <label for=\"control-41946fc0-ebeb-4ae4-95c8-ef7ba85c490a\">control <span class=\"len\">(1)</span></label>\n", " <ul id=\"control\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"parasilo-20.rennes.grid5000.fr-3c14f25d-98e7-4855-98f9-22dbc4b759f4\" class=\"att\">\n", " <label for=\"parasilo-20.rennes.grid5000.fr-3c14f25d-98e7-4855-98f9-22dbc4b759f4\">parasilo-20.rennes.grid5000.fr </label>\n", " <ul id=\"parasilo-20.rennes.grid5000.fr\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.Host'>@0x7fce18ed77d0\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"address-9030f56e-740a-420a-85d6-e625cf327006\" class=\"att\" disabled=\"\">\n", " <label for=\"address-9030f56e-740a-420a-85d6-e625cf327006\">\n", " <span>address</span>\n", " </label>\n", " <span>parasilo-20.rennes.grid5000.fr</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"alias-e646fe36-16f8-4936-9498-d4b63d965ff4\" class=\"att\" disabled=\"\">\n", " <label for=\"alias-e646fe36-16f8-4936-9498-d4b63d965ff4\">\n", " <span>alias</span>\n", " </label>\n", " <span>parasilo-20.rennes.grid5000.fr</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"user-97caa99f-f6ca-47e5-bcc2-883051b8abd8\" class=\"att\" disabled=\"\">\n", " <label for=\"user-97caa99f-f6ca-47e5-bcc2-883051b8abd8\">\n", " <span>user</span>\n", " </label>\n", " <span>root</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"keyfile-fc8bd848-6424-4f71-8b22-ede866d6eb6e\" class=\"att\" disabled=\"\">\n", " <label for=\"keyfile-fc8bd848-6424-4f71-8b22-ede866d6eb6e\">\n", " <span>keyfile</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"port-5775c7a1-a20c-49e7-9429-8b239b19eb7f\" class=\"att\" disabled=\"\">\n", " <label for=\"port-5775c7a1-a20c-49e7-9429-8b239b19eb7f\">\n", " <span>port</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"extra-be7cd9f8-b405-411a-a060-5ba3a36702e5\" class=\"att\">\n", " <label for=\"extra-be7cd9f8-b405-411a-a060-5ba3a36702e5\">extra <span class=\"len\">(0)</span></label>\n", " <ul id=\"extra\">\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"net_devices-9a0d11a6-66d1-4466-a8ec-f353b02c743b\" class=\"att\">\n", " <label for=\"net_devices-9a0d11a6-66d1-4466-a8ec-f353b02c743b\">net_devices <span class=\"len\">(6)</span></label>\n", " <ul id=\"net_devices\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"eno4-a88f5f06-6a50-4c1e-b62b-3d3fe5cd1c0c\" class=\"att\">\n", " <label for=\"eno4-a88f5f06-6a50-4c1e-b62b-3d3fe5cd1c0c\">eno4 </label>\n", " <ul id=\"eno4\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.NetDevice'>@0x7fce18e56350\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"device-3f267b93-a748-4f33-8054-5dac361fd2e1\" class=\"att\" disabled=\"\">\n", " <label for=\"device-3f267b93-a748-4f33-8054-5dac361fd2e1\">\n", " <span>device</span>\n", " </label>\n", " <span>eno4</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"addresses-67305b42-aba2-450b-bc97-219d6f2e28bb\" class=\"att\">\n", " <label for=\"addresses-67305b42-aba2-450b-bc97-219d6f2e28bb\">addresses <span class=\"len\">(0)</span></label>\n", " <ul id=\"addresses\">\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"type-4f0946c6-903a-45ac-9a83-67913ebae3bd\" class=\"att\" disabled=\"\">\n", " <label for=\"type-4f0946c6-903a-45ac-9a83-67913ebae3bd\">\n", " <span>type</span>\n", " </label>\n", " <span>ether</span>\n", " </li>\n", " </ul>\n", " </div>\n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"eno1-9568591d-935b-4084-8e03-856fe1790ab0\" class=\"att\">\n", " <label for=\"eno1-9568591d-935b-4084-8e03-856fe1790ab0\">eno1 </label>\n", " <ul id=\"eno1\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.NetDevice'>@0x7fce18e56390\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"device-b9b0f1fc-9f00-423b-88f9-b55f34341fe7\" class=\"att\" disabled=\"\">\n", " <label for=\"device-b9b0f1fc-9f00-423b-88f9-b55f34341fe7\">\n", " <span>device</span>\n", " </label>\n", " <span>eno1</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"addresses-96cc86d9-f824-4c2c-a5d5-ae4c51fe5483\" class=\"att\">\n", " <label for=\"addresses-96cc86d9-f824-4c2c-a5d5-ae4c51fe5483\">addresses <span class=\"len\">(0)</span></label>\n", " <ul id=\"addresses\">\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"type-d1914b93-4769-4001-b7cd-5f187db0c07f\" class=\"att\" disabled=\"\">\n", " <label for=\"type-d1914b93-4769-4001-b7cd-5f187db0c07f\">\n", " <span>type</span>\n", " </label>\n", " <span>ether</span>\n", " </li>\n", " </ul>\n", " </div>\n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"lo-c099c0bc-969b-4adb-ac85-cd8fdba35366\" class=\"att\">\n", " <label for=\"lo-c099c0bc-969b-4adb-ac85-cd8fdba35366\">lo </label>\n", " <ul id=\"lo\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.NetDevice'>@0x7fce18e564d0\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"device-ae431d88-0eba-43e6-99db-5e2bb814c85c\" class=\"att\" disabled=\"\">\n", " <label for=\"device-ae431d88-0eba-43e6-99db-5e2bb814c85c\">\n", " <span>device</span>\n", " </label>\n", " <span>lo</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"addresses-2c9c874f-6d5e-4031-9c6a-1cd34fc86a17\" class=\"att\">\n", " <label for=\"addresses-2c9c874f-6d5e-4031-9c6a-1cd34fc86a17\">addresses <span class=\"len\">(2)</span></label>\n", " <ul id=\"addresses\">\n", " <table><thead><tr><th>ip</th></tr></thead><tbody><tr><td>::1/128</td></tr><tr><td>127.0.0.1/8</td></tr></tbody></table>\n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"type-4cdc137b-172c-48b6-8f75-7cc0bc502dcd\" class=\"att\" disabled=\"\">\n", " <label for=\"type-4cdc137b-172c-48b6-8f75-7cc0bc502dcd\">\n", " <span>type</span>\n", " </label>\n", " <span>ether</span>\n", " </li>\n", " </ul>\n", " </div>\n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"eno2-2ea9b94c-c322-4a6d-857b-6fc01dcadc0b\" class=\"att\">\n", " <label for=\"eno2-2ea9b94c-c322-4a6d-857b-6fc01dcadc0b\">eno2 </label>\n", " <ul id=\"eno2\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.NetDevice'>@0x7fce18e56490\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"device-ecddd49b-c02f-4d57-8613-aa509642c9e7\" class=\"att\" disabled=\"\">\n", " <label for=\"device-ecddd49b-c02f-4d57-8613-aa509642c9e7\">\n", " <span>device</span>\n", " </label>\n", " <span>eno2</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"addresses-c1d55856-2218-4731-bd22-9f3dc2b48bcc\" class=\"att\">\n", " <label for=\"addresses-c1d55856-2218-4731-bd22-9f3dc2b48bcc\">addresses <span class=\"len\">(0)</span></label>\n", " <ul id=\"addresses\">\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"type-72a8aa11-5b34-4a0c-9273-5daaaf0ce760\" class=\"att\" disabled=\"\">\n", " <label for=\"type-72a8aa11-5b34-4a0c-9273-5daaaf0ce760\">\n", " <span>type</span>\n", " </label>\n", " <span>ether</span>\n", " </li>\n", " </ul>\n", " </div>\n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"br0-ed48889f-5989-46d8-96bf-0b703785f16e\" class=\"att\">\n", " <label for=\"br0-ed48889f-5989-46d8-96bf-0b703785f16e\">br0 </label>\n", " <ul id=\"br0\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.BridgeDevice'>@0x7fce18e560d0\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"device-dcc9bcd4-55ec-42b0-a25b-cb0239a82724\" class=\"att\" disabled=\"\">\n", " <label for=\"device-dcc9bcd4-55ec-42b0-a25b-cb0239a82724\">\n", " <span>device</span>\n", " </label>\n", " <span>br0</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"addresses-7274d1b5-b1e2-4f1d-ab1a-a2e571ca6dbe\" class=\"att\">\n", " <label for=\"addresses-7274d1b5-b1e2-4f1d-ab1a-a2e571ca6dbe\">addresses <span class=\"len\">(2)</span></label>\n", " <ul id=\"addresses\">\n", " <table><thead><tr><th>ip</th></tr></thead><tbody><tr><td>fe80::eef4:bbff:fed0:fd30/64</td></tr><tr><td>172.16.97.20/20</td></tr></tbody></table>\n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"type-1c4fe7e5-8904-40d6-8d48-db283f1ccafe\" class=\"att\" disabled=\"\">\n", " <label for=\"type-1c4fe7e5-8904-40d6-8d48-db283f1ccafe\">\n", " <span>type</span>\n", " </label>\n", " <span>bridge</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"interfaces-d7bdeae5-f88e-400e-b838-c8c22764afe0\" class=\"att\">\n", " <label for=\"interfaces-d7bdeae5-f88e-400e-b838-c8c22764afe0\">interfaces <span class=\"len\">(1)</span></label>\n", " <ul id=\"interfaces\">\n", " <ul><li>eno1</li></ul>\n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </div>\n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"eno3-ddbe04f3-e2f6-4ca6-9a82-be937bec7176\" class=\"att\">\n", " <label for=\"eno3-ddbe04f3-e2f6-4ca6-9a82-be937bec7176\">eno3 </label>\n", " <ul id=\"eno3\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.NetDevice'>@0x7fce18e56090\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"device-8a0d8e55-280b-4471-bc9f-04fcd6978239\" class=\"att\" disabled=\"\">\n", " <label for=\"device-8a0d8e55-280b-4471-bc9f-04fcd6978239\">\n", " <span>device</span>\n", " </label>\n", " <span>eno3</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"addresses-0c65d6f2-7c10-49a9-bea9-fae29869b330\" class=\"att\">\n", " <label for=\"addresses-0c65d6f2-7c10-49a9-bea9-fae29869b330\">addresses <span class=\"len\">(0)</span></label>\n", " <ul id=\"addresses\">\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"type-38de3d89-3d1f-4a93-804d-bdcc5f8572d7\" class=\"att\" disabled=\"\">\n", " <label for=\"type-38de3d89-3d1f-4a93-804d-bdcc5f8572d7\">\n", " <span>type</span>\n", " </label>\n", " <span>ether</span>\n", " </li>\n", " </ul>\n", " </div>\n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"processor-2c23c7a3-697d-49eb-85cb-12e3ac149485\" class=\"att\">\n", " <label for=\"processor-2c23c7a3-697d-49eb-85cb-12e3ac149485\">processor <span class=\"len\">(32 vcpus)</span></label>\n", " <ul id=\"processor\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"cores-58b48e5c-a9be-4d5b-9315-4b6ab091f183\" class=\"att\" disabled=\"\">\n", " <label for=\"cores-58b48e5c-a9be-4d5b-9315-4b6ab091f183\">\n", " <span>cores</span>\n", " </label>\n", " <span>8</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"count-5f0250d7-6e26-4472-803b-d125f5e4190d\" class=\"att\" disabled=\"\">\n", " <label for=\"count-5f0250d7-6e26-4472-803b-d125f5e4190d\">\n", " <span>count</span>\n", " </label>\n", " <span>2</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"threads_per_core-cc4b49ce-1f74-4175-8701-7fb78bd991b9\" class=\"att\" disabled=\"\">\n", " <label for=\"threads_per_core-cc4b49ce-1f74-4175-8701-7fb78bd991b9\">\n", " <span>threads_per_core</span>\n", " </label>\n", " <span>2</span>\n", " </li>\n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </div>\n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"compute-0c4c0a6c-ef69-4af8-b6fc-05d93695b252\" class=\"att\">\n", " <label for=\"compute-0c4c0a6c-ef69-4af8-b6fc-05d93695b252\">compute <span class=\"len\">(1)</span></label>\n", " <ul id=\"compute\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"parasilo-22.rennes.grid5000.fr-9d485a08-e3b1-4908-9829-60491309fd47\" class=\"att\">\n", " <label for=\"parasilo-22.rennes.grid5000.fr-9d485a08-e3b1-4908-9829-60491309fd47\">parasilo-22.rennes.grid5000.fr </label>\n", " <ul id=\"parasilo-22.rennes.grid5000.fr\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.Host'>@0x7fce18ed7a50\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"address-3c8bb279-c962-40b1-a245-ef2c5ae8ff8a\" class=\"att\" disabled=\"\">\n", " <label for=\"address-3c8bb279-c962-40b1-a245-ef2c5ae8ff8a\">\n", " <span>address</span>\n", " </label>\n", " <span>parasilo-22.rennes.grid5000.fr</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"alias-4a6706c8-c960-4da8-9355-23dd69e8165d\" class=\"att\" disabled=\"\">\n", " <label for=\"alias-4a6706c8-c960-4da8-9355-23dd69e8165d\">\n", " <span>alias</span>\n", " </label>\n", " <span>parasilo-22.rennes.grid5000.fr</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"user-5a0d4ba4-bd67-473f-a231-229f9357844e\" class=\"att\" disabled=\"\">\n", " <label for=\"user-5a0d4ba4-bd67-473f-a231-229f9357844e\">\n", " <span>user</span>\n", " </label>\n", " <span>root</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"keyfile-96a41b96-7dd5-455b-a59a-ffa6d0d7f717\" class=\"att\" disabled=\"\">\n", " <label for=\"keyfile-96a41b96-7dd5-455b-a59a-ffa6d0d7f717\">\n", " <span>keyfile</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"port-a0e14fd6-6ecc-4d4f-b1ed-9275ca3092da\" class=\"att\" disabled=\"\">\n", " <label for=\"port-a0e14fd6-6ecc-4d4f-b1ed-9275ca3092da\">\n", " <span>port</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"extra-d6f779dd-dae4-4747-9feb-71ffde2cc896\" class=\"att\">\n", " <label for=\"extra-d6f779dd-dae4-4747-9feb-71ffde2cc896\">extra <span class=\"len\">(0)</span></label>\n", " <ul id=\"extra\">\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"net_devices-b73239d2-10c4-4431-89df-27932c811da1\" class=\"att\">\n", " <label for=\"net_devices-b73239d2-10c4-4431-89df-27932c811da1\">net_devices <span class=\"len\">(6)</span></label>\n", " <ul id=\"net_devices\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"eno4-a986545a-9b9b-4cf2-9b76-2720563821e9\" class=\"att\">\n", " <label for=\"eno4-a986545a-9b9b-4cf2-9b76-2720563821e9\">eno4 </label>\n", " <ul id=\"eno4\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.NetDevice'>@0x7fce18e56d50\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"device-f0dce5eb-6b57-415b-8f7b-c1f8146286e5\" class=\"att\" disabled=\"\">\n", " <label for=\"device-f0dce5eb-6b57-415b-8f7b-c1f8146286e5\">\n", " <span>device</span>\n", " </label>\n", " <span>eno4</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"addresses-0d56b606-af96-4e96-9917-da5cc4b61d51\" class=\"att\">\n", " <label for=\"addresses-0d56b606-af96-4e96-9917-da5cc4b61d51\">addresses <span class=\"len\">(0)</span></label>\n", " <ul id=\"addresses\">\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"type-a24b37ad-2106-423c-a2e4-df24e635e760\" class=\"att\" disabled=\"\">\n", " <label for=\"type-a24b37ad-2106-423c-a2e4-df24e635e760\">\n", " <span>type</span>\n", " </label>\n", " <span>ether</span>\n", " </li>\n", " </ul>\n", " </div>\n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"eno1-f0f2996a-9baf-4bb2-aa1e-a10b536e7045\" class=\"att\">\n", " <label for=\"eno1-f0f2996a-9baf-4bb2-aa1e-a10b536e7045\">eno1 </label>\n", " <ul id=\"eno1\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.NetDevice'>@0x7fce18e56cd0\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"device-2ff83fa2-bd9e-405a-8949-6207657990e5\" class=\"att\" disabled=\"\">\n", " <label for=\"device-2ff83fa2-bd9e-405a-8949-6207657990e5\">\n", " <span>device</span>\n", " </label>\n", " <span>eno1</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"addresses-4eaf69de-3e81-4132-8368-855f88ac6bf4\" class=\"att\">\n", " <label for=\"addresses-4eaf69de-3e81-4132-8368-855f88ac6bf4\">addresses <span class=\"len\">(0)</span></label>\n", " <ul id=\"addresses\">\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"type-0978f922-3666-45ed-9f50-d6e8683abc07\" class=\"att\" disabled=\"\">\n", " <label for=\"type-0978f922-3666-45ed-9f50-d6e8683abc07\">\n", " <span>type</span>\n", " </label>\n", " <span>ether</span>\n", " </li>\n", " </ul>\n", " </div>\n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"lo-98a74f05-5e6f-4d48-be8b-de75bb7c0fa2\" class=\"att\">\n", " <label for=\"lo-98a74f05-5e6f-4d48-be8b-de75bb7c0fa2\">lo </label>\n", " <ul id=\"lo\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.NetDevice'>@0x7fce18e56890\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"device-dfc5e7c7-28d0-43e3-aa26-b3df422be5d7\" class=\"att\" disabled=\"\">\n", " <label for=\"device-dfc5e7c7-28d0-43e3-aa26-b3df422be5d7\">\n", " <span>device</span>\n", " </label>\n", " <span>lo</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"addresses-5b473ed2-fd0d-4d16-9125-147bafdb22ac\" class=\"att\">\n", " <label for=\"addresses-5b473ed2-fd0d-4d16-9125-147bafdb22ac\">addresses <span class=\"len\">(2)</span></label>\n", " <ul id=\"addresses\">\n", " <table><thead><tr><th>ip</th></tr></thead><tbody><tr><td>::1/128</td></tr><tr><td>127.0.0.1/8</td></tr></tbody></table>\n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"type-9c4202ba-67e2-42af-8aba-f6c01b05276e\" class=\"att\" disabled=\"\">\n", " <label for=\"type-9c4202ba-67e2-42af-8aba-f6c01b05276e\">\n", " <span>type</span>\n", " </label>\n", " <span>ether</span>\n", " </li>\n", " </ul>\n", " </div>\n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"eno2-407aa954-2223-43e1-a93e-e9fda2912e97\" class=\"att\">\n", " <label for=\"eno2-407aa954-2223-43e1-a93e-e9fda2912e97\">eno2 </label>\n", " <ul id=\"eno2\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.NetDevice'>@0x7fce18e56a50\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"device-7ac5f855-6fa8-4b73-bf85-751e4678b1aa\" class=\"att\" disabled=\"\">\n", " <label for=\"device-7ac5f855-6fa8-4b73-bf85-751e4678b1aa\">\n", " <span>device</span>\n", " </label>\n", " <span>eno2</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"addresses-5d0c9427-1d88-42a0-8912-b8ad081ed518\" class=\"att\">\n", " <label for=\"addresses-5d0c9427-1d88-42a0-8912-b8ad081ed518\">addresses <span class=\"len\">(0)</span></label>\n", " <ul id=\"addresses\">\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"type-06432d26-6163-4104-8ded-e59145a5582e\" class=\"att\" disabled=\"\">\n", " <label for=\"type-06432d26-6163-4104-8ded-e59145a5582e\">\n", " <span>type</span>\n", " </label>\n", " <span>ether</span>\n", " </li>\n", " </ul>\n", " </div>\n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"br0-0d64eed8-a5f1-4a10-b23d-f1cb14584ad7\" class=\"att\">\n", " <label for=\"br0-0d64eed8-a5f1-4a10-b23d-f1cb14584ad7\">br0 </label>\n", " <ul id=\"br0\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.BridgeDevice'>@0x7fce18e56050\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"device-1f699e56-dd8a-477f-b975-389ac766822a\" class=\"att\" disabled=\"\">\n", " <label for=\"device-1f699e56-dd8a-477f-b975-389ac766822a\">\n", " <span>device</span>\n", " </label>\n", " <span>br0</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"addresses-06e645dc-80bf-47c5-be93-08263c77da1f\" class=\"att\">\n", " <label for=\"addresses-06e645dc-80bf-47c5-be93-08263c77da1f\">addresses <span class=\"len\">(2)</span></label>\n", " <ul id=\"addresses\">\n", " <table><thead><tr><th>ip</th></tr></thead><tbody><tr><td>fe80::eef4:bbff:fed1:60/64</td></tr><tr><td>172.16.97.22/20</td></tr></tbody></table>\n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"type-56505541-a1ed-452e-81e7-8a12d39ae3ee\" class=\"att\" disabled=\"\">\n", " <label for=\"type-56505541-a1ed-452e-81e7-8a12d39ae3ee\">\n", " <span>type</span>\n", " </label>\n", " <span>bridge</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"interfaces-90580ab2-0232-48a2-bfeb-a1b21c0f3b3d\" class=\"att\">\n", " <label for=\"interfaces-90580ab2-0232-48a2-bfeb-a1b21c0f3b3d\">interfaces <span class=\"len\">(1)</span></label>\n", " <ul id=\"interfaces\">\n", " <ul><li>eno1</li></ul>\n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </div>\n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"eno3-a3536011-43d6-4103-8576-a789ad03285c\" class=\"att\">\n", " <label for=\"eno3-a3536011-43d6-4103-8576-a789ad03285c\">eno3 </label>\n", " <ul id=\"eno3\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.NetDevice'>@0x7fce18e56ad0\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"device-e7d513ad-88fc-42df-a2cc-0f218008cf37\" class=\"att\" disabled=\"\">\n", " <label for=\"device-e7d513ad-88fc-42df-a2cc-0f218008cf37\">\n", " <span>device</span>\n", " </label>\n", " <span>eno3</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"addresses-bc567071-6c0c-414b-b978-954ae62a093d\" class=\"att\">\n", " <label for=\"addresses-bc567071-6c0c-414b-b978-954ae62a093d\">addresses <span class=\"len\">(0)</span></label>\n", " <ul id=\"addresses\">\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"type-62d7d71f-86d1-446f-96d4-4fb08463d503\" class=\"att\" disabled=\"\">\n", " <label for=\"type-62d7d71f-86d1-446f-96d4-4fb08463d503\">\n", " <span>type</span>\n", " </label>\n", " <span>ether</span>\n", " </li>\n", " </ul>\n", " </div>\n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"processor-f8f69e74-752d-479d-b1ab-fdc119cf360e\" class=\"att\">\n", " <label for=\"processor-f8f69e74-752d-479d-b1ab-fdc119cf360e\">processor <span class=\"len\">(32 vcpus)</span></label>\n", " <ul id=\"processor\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"cores-ac161fb3-430d-4808-b907-4117a07c48df\" class=\"att\" disabled=\"\">\n", " <label for=\"cores-ac161fb3-430d-4808-b907-4117a07c48df\">\n", " <span>cores</span>\n", " </label>\n", " <span>8</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"count-f00349d1-e6c5-4a39-8eff-e37416db0d49\" class=\"att\" disabled=\"\">\n", " <label for=\"count-f00349d1-e6c5-4a39-8eff-e37416db0d49\">\n", " <span>count</span>\n", " </label>\n", " <span>2</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"threads_per_core-dfa4f28f-4039-4fe1-8a62-5065d5dab0d1\" class=\"att\" disabled=\"\">\n", " <label for=\"threads_per_core-dfa4f28f-4039-4fe1-8a62-5065d5dab0d1\">\n", " <span>threads_per_core</span>\n", " </label>\n", " <span>2</span>\n", " </li>\n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </div>\n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </div>\n", " </div>\n", " " ], "text/plain": [ "{'control': [Host(address='parasilo-20.rennes.grid5000.fr', alias='parasilo-20.rennes.grid5000.fr', user='root', keyfile=None, port=None, extra={}, net_devices={NetDevice(name='eno4', addresses=set()), NetDevice(name='eno1', addresses=set()), NetDevice(name='lo', addresses={IPAddress(network=None, ip=IPv6Interface('::1/128')), IPAddress(network=None, ip=IPv4Interface('127.0.0.1/8'))}), NetDevice(name='eno2', addresses=set()), BridgeDevice(name='br0', addresses={IPAddress(network=None, ip=IPv6Interface('fe80::eef4:bbff:fed0:fd30/64')), IPAddress(network=<enoslib.infra.enos_g5k.objects.G5kEnosProd4Network object at 0x7fce1b8a6ed0>, ip=IPv4Interface('172.16.97.20/20'))}, bridged=['eno1']), NetDevice(name='eno3', addresses=set())})], 'compute': [Host(address='parasilo-22.rennes.grid5000.fr', alias='parasilo-22.rennes.grid5000.fr', user='root', keyfile=None, port=None, extra={}, net_devices={NetDevice(name='eno4', addresses=set()), NetDevice(name='eno1', addresses=set()), NetDevice(name='lo', addresses={IPAddress(network=None, ip=IPv6Interface('::1/128')), IPAddress(network=None, ip=IPv4Interface('127.0.0.1/8'))}), NetDevice(name='eno2', addresses=set()), BridgeDevice(name='br0', addresses={IPAddress(network=None, ip=IPv6Interface('fe80::eef4:bbff:fed1:60/64')), IPAddress(network=<enoslib.infra.enos_g5k.objects.G5kEnosProd4Network object at 0x7fce1b8a6ed0>, ip=IPv4Interface('172.16.97.22/20'))}, bridged=['eno1']), NetDevice(name='eno3', addresses=set())})]}" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# sync some more information in the host data structure (for illustration purpose here)\n", "en.sync_info(roles, networks)" ] }, { "cell_type": "markdown", "id": "caring-glance", "metadata": {}, "source": [ "## Acting on remote nodes\n", "\n", "### run a command, filter results" ] }, { "cell_type": "code", "execution_count": 10, "id": "political-praise", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "PLAY [all] ***********************************************************************************************************************************************************************************\n", "\n", "TASK [whoami] ********************************************************************************************************************************************************************************\n", " [started TASK: whoami on parasilo-20.rennes.grid5000.fr]\n", " [started TASK: whoami on parasilo-22.rennes.grid5000.fr]\n", "changed: [parasilo-20.rennes.grid5000.fr]\n", "changed: [parasilo-22.rennes.grid5000.fr]\n" ] }, { "data": { "text/html": [ "\n", " <style> .enoslib {\n", " width: auto;\n", "}\n", "\n", ".enoslib_object {\n", " width: auto;\n", " font-size: 1em;\n", " line-height: 1.5;\n", " background-color: rgb(250, 249, 249);\n", " font-family: 'Segoe UI';\n", " color: black;\n", "}\n", "\n", ".enoslib_object ul {\n", " padding: 0;\n", "}\n", "\n", ".enoslib_object input+label {\n", " margin-bottom: 0%;\n", "}\n", "\n", ".object_name {\n", " padding: 6px 0 6px 3px;\n", " border-bottom-width: 1px;\n", " border-bottom-style: solid;\n", " border-bottom-color: #777;\n", " color: #555;\n", "}\n", "\n", ".object_name>div,\n", ".object_name>ul {\n", " display: inline;\n", " margin-top: 0;\n", " margin-bottom: 0;\n", "}\n", "\n", "ul {\n", " list-style: none !important;\n", " padding: 3px !important;\n", " margin: 0 !important;\n", "}\n", "\n", "input.att+label {\n", " display: inline-block;\n", " /*width: 140px;*/\n", " color: rgb(36, 35, 35);\n", " font-weight: 500;\n", " padding: 4px 0 2px 0;\n", "}\n", "\n", "input.att:enabled+label {\n", " cursor: pointer;\n", " width: auto;\n", "}\n", "\n", "input.att {\n", " display: none;\n", "}\n", "\n", "input.att+label:before {\n", " display: inline-block;\n", " content: '►';\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", "}\n", "\n", "input.att:checked+label:before {\n", " content: '▼';\n", "}\n", "\n", "input.att:disabled+label:before {\n", " content: none;\n", "}\n", "\n", "input.att+label>span {\n", " display: inline-block;\n", " margin-left: 4px;\n", "}\n", "\n", "input.att+label>span.len {\n", " font-size: small;\n", "}\n", "\n", "input.att:checked+label>span.len {\n", " display: none;\n", "}\n", "\n", "label+span {\n", " color: rgb(70, 69, 69);\n", "}\n", "\n", "input.att~ul {\n", " display: none;\n", "}\n", "\n", "input.att:checked~ul {\n", " display: block;\n", "}\n", "\n", "table {\n", " width: auto;\n", " border-collapse: collapse;\n", " margin: 2%;\n", "}\n", "\n", "td,\n", "th {\n", " padding: 8px;\n", " height: 15px;\n", " font-size: small;\n", "}\n", "\n", "td {\n", " text-align: left !important;\n", " color: rgb(160, 160, 160)\n", "}\n", "\n", "th {\n", " text-align: center;\n", " color: black;\n", "}\n", "\n", "input~ul {\n", " position: relative;\n", " left: 25px;\n", "}\n", "\n", "input.att~table {\n", " display: none;\n", "}\n", "\n", "input.att:checked~table {\n", " display: block;\n", "} </style>\n", " <div class=\"enoslib\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.api.Results'>\n", " </div>\n", " <ul class=\"list\">\n", " <table><thead><tr><th>host</th><th>task</th><th>status</th><th>payload</th></tr></thead><tbody><tr><td>parasilo-20.rennes.grid5000.fr</td><td>whoami</td><td>OK</td><td><table><tr><th>stdout</th><td>root</td></tr><tr><th>stderr</th><td></td></tr><tr><th>rc</th><td>0</td></tr></table></td></tr><tr><td>parasilo-22.rennes.grid5000.fr</td><td>whoami</td><td>OK</td><td><table><tr><th>stdout</th><td>root</td></tr><tr><th>stderr</th><td></td></tr><tr><th>rc</th><td>0</td></tr></table></td></tr></tbody></table>\n", " </ul>\n", " </div>\n", " </div>\n", " " ], "text/plain": [ "CommandResult(host='parasilo-20.rennes.grid5000.fr', task='whoami', status='OK', payload={'cmd': 'whoami', 'stdout': 'root', 'stderr': '', 'rc': 0, 'start': '2021-08-27 10:01:28.920997', 'end': '2021-08-27 10:01:28.929490', 'delta': '0:00:00.008493', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'whoami', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['root'], 'stderr_lines': [], '_ansible_no_log': False})\n", "CommandResult(host='parasilo-22.rennes.grid5000.fr', task='whoami', status='OK', payload={'cmd': 'whoami', 'stdout': 'root', 'stderr': '', 'rc': 0, 'start': '2021-08-27 10:01:28.928952', 'end': '2021-08-27 10:01:28.940732', 'delta': '0:00:00.011780', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'whoami', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['root'], 'stderr_lines': [], '_ansible_no_log': False})" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "results = en.run_command(\"whoami\", roles=roles)\n", "results" ] }, { "cell_type": "code", "execution_count": 11, "id": "willing-senate", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " <style> .enoslib {\n", " width: auto;\n", "}\n", "\n", ".enoslib_object {\n", " width: auto;\n", " font-size: 1em;\n", " line-height: 1.5;\n", " background-color: rgb(250, 249, 249);\n", " font-family: 'Segoe UI';\n", " color: black;\n", "}\n", "\n", ".enoslib_object ul {\n", " padding: 0;\n", "}\n", "\n", ".enoslib_object input+label {\n", " margin-bottom: 0%;\n", "}\n", "\n", ".object_name {\n", " padding: 6px 0 6px 3px;\n", " border-bottom-width: 1px;\n", " border-bottom-style: solid;\n", " border-bottom-color: #777;\n", " color: #555;\n", "}\n", "\n", ".object_name>div,\n", ".object_name>ul {\n", " display: inline;\n", " margin-top: 0;\n", " margin-bottom: 0;\n", "}\n", "\n", "ul {\n", " list-style: none !important;\n", " padding: 3px !important;\n", " margin: 0 !important;\n", "}\n", "\n", "input.att+label {\n", " display: inline-block;\n", " /*width: 140px;*/\n", " color: rgb(36, 35, 35);\n", " font-weight: 500;\n", " padding: 4px 0 2px 0;\n", "}\n", "\n", "input.att:enabled+label {\n", " cursor: pointer;\n", " width: auto;\n", "}\n", "\n", "input.att {\n", " display: none;\n", "}\n", "\n", "input.att+label:before {\n", " display: inline-block;\n", " content: '►';\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", "}\n", "\n", "input.att:checked+label:before {\n", " content: '▼';\n", "}\n", "\n", "input.att:disabled+label:before {\n", " content: none;\n", "}\n", "\n", "input.att+label>span {\n", " display: inline-block;\n", " margin-left: 4px;\n", "}\n", "\n", "input.att+label>span.len {\n", " font-size: small;\n", "}\n", "\n", "input.att:checked+label>span.len {\n", " display: none;\n", "}\n", "\n", "label+span {\n", " color: rgb(70, 69, 69);\n", "}\n", "\n", "input.att~ul {\n", " display: none;\n", "}\n", "\n", "input.att:checked~ul {\n", " display: block;\n", "}\n", "\n", "table {\n", " width: auto;\n", " border-collapse: collapse;\n", " margin: 2%;\n", "}\n", "\n", "td,\n", "th {\n", " padding: 8px;\n", " height: 15px;\n", " font-size: small;\n", "}\n", "\n", "td {\n", " text-align: left !important;\n", " color: rgb(160, 160, 160)\n", "}\n", "\n", "th {\n", " text-align: center;\n", " color: black;\n", "}\n", "\n", "input~ul {\n", " position: relative;\n", " left: 25px;\n", "}\n", "\n", "input.att~table {\n", " display: none;\n", "}\n", "\n", "input.att:checked~table {\n", " display: block;\n", "} </style>\n", " <div class=\"enoslib\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.api.CommandResult'>\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"host-f40b768a-4d18-4fba-b610-c1561824f211\" class=\"att\" disabled=\"\">\n", " <label for=\"host-f40b768a-4d18-4fba-b610-c1561824f211\">\n", " <span>host</span>\n", " </label>\n", " <span>parasilo-20.rennes.grid5000.fr</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"task-4e3db1f0-6faf-4e63-9a20-df7a73c4bf87\" class=\"att\" disabled=\"\">\n", " <label for=\"task-4e3db1f0-6faf-4e63-9a20-df7a73c4bf87\">\n", " <span>task</span>\n", " </label>\n", " <span>whoami</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"status-e210dcd2-0b21-4e00-a9a4-e6e9d87f041e\" class=\"att\" disabled=\"\">\n", " <label for=\"status-e210dcd2-0b21-4e00-a9a4-e6e9d87f041e\">\n", " <span>status</span>\n", " </label>\n", " <span>OK</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"payload-e603bb02-4ce6-4800-a1ab-b9279460064a\" class=\"att\">\n", " <label for=\"payload-e603bb02-4ce6-4800-a1ab-b9279460064a\">payload <span class=\"len\">(12)</span></label>\n", " <ul id=\"payload\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"cmd-0f8745fb-2be4-4856-923a-2ec908b20ae8\" class=\"att\" disabled=\"\">\n", " <label for=\"cmd-0f8745fb-2be4-4856-923a-2ec908b20ae8\">\n", " <span>cmd</span>\n", " </label>\n", " <span>whoami</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"stdout-1094ec10-51c6-426b-b16d-9300f381d874\" class=\"att\" disabled=\"\">\n", " <label for=\"stdout-1094ec10-51c6-426b-b16d-9300f381d874\">\n", " <span>stdout</span>\n", " </label>\n", " <span>root</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"stderr-d1a59ad8-91f3-4fd5-94a3-2e4cde78bc88\" class=\"att\" disabled=\"\">\n", " <label for=\"stderr-d1a59ad8-91f3-4fd5-94a3-2e4cde78bc88\">\n", " <span>stderr</span>\n", " </label>\n", " <span></span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"rc-b08e45e9-6aa9-4ad2-9d6c-af1626d689d1\" class=\"att\" disabled=\"\">\n", " <label for=\"rc-b08e45e9-6aa9-4ad2-9d6c-af1626d689d1\">\n", " <span>rc</span>\n", " </label>\n", " <span>0</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"start-71af19d5-02ff-44bd-9d1a-5cef1bbfee9f\" class=\"att\" disabled=\"\">\n", " <label for=\"start-71af19d5-02ff-44bd-9d1a-5cef1bbfee9f\">\n", " <span>start</span>\n", " </label>\n", " <span>2021-08-27 10:01:28.920997</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"end-0b069cc7-9c3c-4eca-9b02-e1ec87d68b1d\" class=\"att\" disabled=\"\">\n", " <label for=\"end-0b069cc7-9c3c-4eca-9b02-e1ec87d68b1d\">\n", " <span>end</span>\n", " </label>\n", " <span>2021-08-27 10:01:28.929490</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"delta-96789b99-1094-4585-8a6c-84154241569a\" class=\"att\" disabled=\"\">\n", " <label for=\"delta-96789b99-1094-4585-8a6c-84154241569a\">\n", " <span>delta</span>\n", " </label>\n", " <span>0:00:00.008493</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"changed-b2cad1a8-63b0-405d-8757-c3ec33b39e68\" class=\"att\" disabled=\"\">\n", " <label for=\"changed-b2cad1a8-63b0-405d-8757-c3ec33b39e68\">\n", " <span>changed</span>\n", " </label>\n", " <span>True</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"invocation-6b46b285-d4c1-4a36-9d4c-107df77df1f8\" class=\"att\">\n", " <label for=\"invocation-6b46b285-d4c1-4a36-9d4c-107df77df1f8\">invocation <span class=\"len\">(1)</span></label>\n", " <ul id=\"invocation\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"module_args-92ae3642-75c6-4644-87d0-801f4681488e\" class=\"att\">\n", " <label for=\"module_args-92ae3642-75c6-4644-87d0-801f4681488e\">module_args <span class=\"len\">(11)</span></label>\n", " <ul id=\"module_args\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"_raw_params-a0bed345-6117-42ca-ad3d-4f25093c1b77\" class=\"att\" disabled=\"\">\n", " <label for=\"_raw_params-a0bed345-6117-42ca-ad3d-4f25093c1b77\">\n", " <span>_raw_params</span>\n", " </label>\n", " <span>whoami</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"_uses_shell-df6850bb-d50c-47c5-829a-47eb4bc36ceb\" class=\"att\" disabled=\"\">\n", " <label for=\"_uses_shell-df6850bb-d50c-47c5-829a-47eb4bc36ceb\">\n", " <span>_uses_shell</span>\n", " </label>\n", " <span>True</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"warn-e13abef3-d05a-443a-a07f-a7c78fdc2ff0\" class=\"att\" disabled=\"\">\n", " <label for=\"warn-e13abef3-d05a-443a-a07f-a7c78fdc2ff0\">\n", " <span>warn</span>\n", " </label>\n", " <span>True</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"stdin_add_newline-35798c9b-6b4c-4af3-9aa3-0f09fa8b75b9\" class=\"att\" disabled=\"\">\n", " <label for=\"stdin_add_newline-35798c9b-6b4c-4af3-9aa3-0f09fa8b75b9\">\n", " <span>stdin_add_newline</span>\n", " </label>\n", " <span>True</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"strip_empty_ends-25305b76-e343-4007-b1d6-3d942b0f122d\" class=\"att\" disabled=\"\">\n", " <label for=\"strip_empty_ends-25305b76-e343-4007-b1d6-3d942b0f122d\">\n", " <span>strip_empty_ends</span>\n", " </label>\n", " <span>True</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"argv-0d8c72e1-5ad0-4b10-a93f-ab9849103e52\" class=\"att\" disabled=\"\">\n", " <label for=\"argv-0d8c72e1-5ad0-4b10-a93f-ab9849103e52\">\n", " <span>argv</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"chdir-4284f2e7-4ec7-4b95-89ec-dda31b4494b0\" class=\"att\" disabled=\"\">\n", " <label for=\"chdir-4284f2e7-4ec7-4b95-89ec-dda31b4494b0\">\n", " <span>chdir</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"executable-f7b50bf0-1f91-4a87-b5e9-7c5b0d1a3f87\" class=\"att\" disabled=\"\">\n", " <label for=\"executable-f7b50bf0-1f91-4a87-b5e9-7c5b0d1a3f87\">\n", " <span>executable</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"creates-5d76dee4-afae-41b1-80d6-47b0b7697660\" class=\"att\" disabled=\"\">\n", " <label for=\"creates-5d76dee4-afae-41b1-80d6-47b0b7697660\">\n", " <span>creates</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"removes-f04d3ae8-bc12-4493-8c5b-f095d69c2361\" class=\"att\" disabled=\"\">\n", " <label for=\"removes-f04d3ae8-bc12-4493-8c5b-f095d69c2361\">\n", " <span>removes</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"stdin-c2f71d99-ad5b-44cb-b4df-fdc48d316969\" class=\"att\" disabled=\"\">\n", " <label for=\"stdin-c2f71d99-ad5b-44cb-b4df-fdc48d316969\">\n", " <span>stdin</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"stdout_lines-22d4058c-d962-4c2e-b48f-e8812ff6e953\" class=\"att\">\n", " <label for=\"stdout_lines-22d4058c-d962-4c2e-b48f-e8812ff6e953\">stdout_lines <span class=\"len\">(1)</span></label>\n", " <ul id=\"stdout_lines\">\n", " <ul><li>root</li></ul>\n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"stderr_lines-a26b75e8-9735-401b-a1b9-1bdeea5002f0\" class=\"att\">\n", " <label for=\"stderr_lines-a26b75e8-9735-401b-a1b9-1bdeea5002f0\">stderr_lines <span class=\"len\">(0)</span></label>\n", " <ul id=\"stderr_lines\">\n", " \n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"_ansible_no_log-9c780740-f779-4579-8ab5-1a7f1b6490f7\" class=\"att\" disabled=\"\">\n", " <label for=\"_ansible_no_log-9c780740-f779-4579-8ab5-1a7f1b6490f7\">\n", " <span>_ansible_no_log</span>\n", " </label>\n", " <span>False</span>\n", " </li>\n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </div>\n", " </div>\n", " " ], "text/plain": [ "CommandResult(host='parasilo-20.rennes.grid5000.fr', task='whoami', status='OK', payload={'cmd': 'whoami', 'stdout': 'root', 'stderr': '', 'rc': 0, 'start': '2021-08-27 10:01:28.920997', 'end': '2021-08-27 10:01:28.929490', 'delta': '0:00:00.008493', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'whoami', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['root'], 'stderr_lines': [], '_ansible_no_log': False})" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "one_result = results.filter(host=roles[\"control\"][0].alias)[0]\n", "one_result" ] }, { "cell_type": "code", "execution_count": 12, "id": "specified-restriction", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'root'" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "one_result.payload[\"stdout\"]" ] }, { "cell_type": "markdown", "id": "coastal-poverty", "metadata": {}, "source": [ "There are some specific shortcuts when the remote actions is a remote (shell) command: `.stdout`, `.stderr`, `.rc`" ] }, { "cell_type": "code", "execution_count": 13, "id": "gentle-implementation", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "stdout = root\n", " stderr=\n", " return code = 0\n" ] } ], "source": [ "print(f\"stdout = {one_result.stdout}\\n\", f\"stderr={one_result.stderr}\\n\", f\"return code = {one_result.rc}\")" ] }, { "cell_type": "markdown", "id": "searching-favorite", "metadata": {}, "source": [ "### Filtering hosts on which the command is run\n", "\n", "`run_command` acts on remote hosts. Those hosts can be given as a `Roles` type (output of `provider.init`) or as a list of `Host` or a single `Host`. \n" ] }, { "cell_type": "code", "execution_count": 14, "id": "israeli-delivery", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "PLAY [all] ***********************************************************************************************************************************************************************************\n", "\n", "TASK [date] **********************************************************************************************************************************************************************************\n", " [started TASK: date on parasilo-20.rennes.grid5000.fr]\n", " [started TASK: date on parasilo-22.rennes.grid5000.fr]\n", "changed: [parasilo-20.rennes.grid5000.fr]\n", "changed: [parasilo-22.rennes.grid5000.fr]\n" ] }, { "data": { "text/html": [ "\n", " <style> .enoslib {\n", " width: auto;\n", "}\n", "\n", ".enoslib_object {\n", " width: auto;\n", " font-size: 1em;\n", " line-height: 1.5;\n", " background-color: rgb(250, 249, 249);\n", " font-family: 'Segoe UI';\n", " color: black;\n", "}\n", "\n", ".enoslib_object ul {\n", " padding: 0;\n", "}\n", "\n", ".enoslib_object input+label {\n", " margin-bottom: 0%;\n", "}\n", "\n", ".object_name {\n", " padding: 6px 0 6px 3px;\n", " border-bottom-width: 1px;\n", " border-bottom-style: solid;\n", " border-bottom-color: #777;\n", " color: #555;\n", "}\n", "\n", ".object_name>div,\n", ".object_name>ul {\n", " display: inline;\n", " margin-top: 0;\n", " margin-bottom: 0;\n", "}\n", "\n", "ul {\n", " list-style: none !important;\n", " padding: 3px !important;\n", " margin: 0 !important;\n", "}\n", "\n", "input.att+label {\n", " display: inline-block;\n", " /*width: 140px;*/\n", " color: rgb(36, 35, 35);\n", " font-weight: 500;\n", " padding: 4px 0 2px 0;\n", "}\n", "\n", "input.att:enabled+label {\n", " cursor: pointer;\n", " width: auto;\n", "}\n", "\n", "input.att {\n", " display: none;\n", "}\n", "\n", "input.att+label:before {\n", " display: inline-block;\n", " content: '►';\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", "}\n", "\n", "input.att:checked+label:before {\n", " content: '▼';\n", "}\n", "\n", "input.att:disabled+label:before {\n", " content: none;\n", "}\n", "\n", "input.att+label>span {\n", " display: inline-block;\n", " margin-left: 4px;\n", "}\n", "\n", "input.att+label>span.len {\n", " font-size: small;\n", "}\n", "\n", "input.att:checked+label>span.len {\n", " display: none;\n", "}\n", "\n", "label+span {\n", " color: rgb(70, 69, 69);\n", "}\n", "\n", "input.att~ul {\n", " display: none;\n", "}\n", "\n", "input.att:checked~ul {\n", " display: block;\n", "}\n", "\n", "table {\n", " width: auto;\n", " border-collapse: collapse;\n", " margin: 2%;\n", "}\n", "\n", "td,\n", "th {\n", " padding: 8px;\n", " height: 15px;\n", " font-size: small;\n", "}\n", "\n", "td {\n", " text-align: left !important;\n", " color: rgb(160, 160, 160)\n", "}\n", "\n", "th {\n", " text-align: center;\n", " color: black;\n", "}\n", "\n", "input~ul {\n", " position: relative;\n", " left: 25px;\n", "}\n", "\n", "input.att~table {\n", " display: none;\n", "}\n", "\n", "input.att:checked~table {\n", " display: block;\n", "} </style>\n", " <div class=\"enoslib\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.api.Results'>\n", " </div>\n", " <ul class=\"list\">\n", " <table><thead><tr><th>host</th><th>task</th><th>status</th><th>payload</th></tr></thead><tbody><tr><td>parasilo-20.rennes.grid5000.fr</td><td>date</td><td>OK</td><td><table><tr><th>stdout</th><td>Fri 27 Aug 2021 10:01:29 AM CEST</td></tr><tr><th>stderr</th><td></td></tr><tr><th>rc</th><td>0</td></tr></table></td></tr><tr><td>parasilo-22.rennes.grid5000.fr</td><td>date</td><td>OK</td><td><table><tr><th>stdout</th><td>Fri 27 Aug 2021 10:01:29 AM CEST</td></tr><tr><th>stderr</th><td></td></tr><tr><th>rc</th><td>0</td></tr></table></td></tr></tbody></table>\n", " </ul>\n", " </div>\n", " </div>\n", " " ], "text/plain": [ "CommandResult(host='parasilo-20.rennes.grid5000.fr', task='date', status='OK', payload={'cmd': 'date', 'stdout': 'Fri 27 Aug 2021 10:01:29 AM CEST', 'stderr': '', 'rc': 0, 'start': '2021-08-27 10:01:29.257670', 'end': '2021-08-27 10:01:29.259796', 'delta': '0:00:00.002126', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'date', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['Fri 27 Aug 2021 10:01:29 AM CEST'], 'stderr_lines': [], '_ansible_no_log': False})\n", "CommandResult(host='parasilo-22.rennes.grid5000.fr', task='date', status='OK', payload={'cmd': 'date', 'stdout': 'Fri 27 Aug 2021 10:01:29 AM CEST', 'stderr': '', 'rc': 0, 'start': '2021-08-27 10:01:29.293038', 'end': '2021-08-27 10:01:29.295371', 'delta': '0:00:00.002333', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'date', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['Fri 27 Aug 2021 10:01:29 AM CEST'], 'stderr_lines': [], '_ansible_no_log': False})" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# some roles\n", "en.run_command(\"date\", roles = roles)" ] }, { "cell_type": "code", "execution_count": 15, "id": "excessive-novelty", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "PLAY [all] ***********************************************************************************************************************************************************************************\n", "\n", "TASK [date] **********************************************************************************************************************************************************************************\n", " [started TASK: date on parasilo-20.rennes.grid5000.fr]\n", "changed: [parasilo-20.rennes.grid5000.fr]\n" ] }, { "data": { "text/html": [ "\n", " <style> .enoslib {\n", " width: auto;\n", "}\n", "\n", ".enoslib_object {\n", " width: auto;\n", " font-size: 1em;\n", " line-height: 1.5;\n", " background-color: rgb(250, 249, 249);\n", " font-family: 'Segoe UI';\n", " color: black;\n", "}\n", "\n", ".enoslib_object ul {\n", " padding: 0;\n", "}\n", "\n", ".enoslib_object input+label {\n", " margin-bottom: 0%;\n", "}\n", "\n", ".object_name {\n", " padding: 6px 0 6px 3px;\n", " border-bottom-width: 1px;\n", " border-bottom-style: solid;\n", " border-bottom-color: #777;\n", " color: #555;\n", "}\n", "\n", ".object_name>div,\n", ".object_name>ul {\n", " display: inline;\n", " margin-top: 0;\n", " margin-bottom: 0;\n", "}\n", "\n", "ul {\n", " list-style: none !important;\n", " padding: 3px !important;\n", " margin: 0 !important;\n", "}\n", "\n", "input.att+label {\n", " display: inline-block;\n", " /*width: 140px;*/\n", " color: rgb(36, 35, 35);\n", " font-weight: 500;\n", " padding: 4px 0 2px 0;\n", "}\n", "\n", "input.att:enabled+label {\n", " cursor: pointer;\n", " width: auto;\n", "}\n", "\n", "input.att {\n", " display: none;\n", "}\n", "\n", "input.att+label:before {\n", " display: inline-block;\n", " content: '►';\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", "}\n", "\n", "input.att:checked+label:before {\n", " content: '▼';\n", "}\n", "\n", "input.att:disabled+label:before {\n", " content: none;\n", "}\n", "\n", "input.att+label>span {\n", " display: inline-block;\n", " margin-left: 4px;\n", "}\n", "\n", "input.att+label>span.len {\n", " font-size: small;\n", "}\n", "\n", "input.att:checked+label>span.len {\n", " display: none;\n", "}\n", "\n", "label+span {\n", " color: rgb(70, 69, 69);\n", "}\n", "\n", "input.att~ul {\n", " display: none;\n", "}\n", "\n", "input.att:checked~ul {\n", " display: block;\n", "}\n", "\n", "table {\n", " width: auto;\n", " border-collapse: collapse;\n", " margin: 2%;\n", "}\n", "\n", "td,\n", "th {\n", " padding: 8px;\n", " height: 15px;\n", " font-size: small;\n", "}\n", "\n", "td {\n", " text-align: left !important;\n", " color: rgb(160, 160, 160)\n", "}\n", "\n", "th {\n", " text-align: center;\n", " color: black;\n", "}\n", "\n", "input~ul {\n", " position: relative;\n", " left: 25px;\n", "}\n", "\n", "input.att~table {\n", " display: none;\n", "}\n", "\n", "input.att:checked~table {\n", " display: block;\n", "} </style>\n", " <div class=\"enoslib\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.api.Results'>\n", " </div>\n", " <ul class=\"list\">\n", " <table><thead><tr><th>host</th><th>task</th><th>status</th><th>payload</th></tr></thead><tbody><tr><td>parasilo-20.rennes.grid5000.fr</td><td>date</td><td>OK</td><td><table><tr><th>stdout</th><td>Fri 27 Aug 2021 10:01:29 AM CEST</td></tr><tr><th>stderr</th><td></td></tr><tr><th>rc</th><td>0</td></tr></table></td></tr></tbody></table>\n", " </ul>\n", " </div>\n", " </div>\n", " " ], "text/plain": [ "CommandResult(host='parasilo-20.rennes.grid5000.fr', task='date', status='OK', payload={'cmd': 'date', 'stdout': 'Fri 27 Aug 2021 10:01:29 AM CEST', 'stderr': '', 'rc': 0, 'start': '2021-08-27 10:01:29.603930', 'end': '2021-08-27 10:01:29.606062', 'delta': '0:00:00.002132', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'date', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['Fri 27 Aug 2021 10:01:29 AM CEST'], 'stderr_lines': [], '_ansible_no_log': False})" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# a list of hosts\n", "en.run_command(\"date\", roles = roles[\"control\"])" ] }, { "cell_type": "code", "execution_count": 16, "id": "genetic-aurora", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "PLAY [all] ***********************************************************************************************************************************************************************************\n", "\n", "TASK [date] **********************************************************************************************************************************************************************************\n", " [started TASK: date on parasilo-20.rennes.grid5000.fr]\n", "changed: [parasilo-20.rennes.grid5000.fr]\n" ] }, { "data": { "text/html": [ "\n", " <style> .enoslib {\n", " width: auto;\n", "}\n", "\n", ".enoslib_object {\n", " width: auto;\n", " font-size: 1em;\n", " line-height: 1.5;\n", " background-color: rgb(250, 249, 249);\n", " font-family: 'Segoe UI';\n", " color: black;\n", "}\n", "\n", ".enoslib_object ul {\n", " padding: 0;\n", "}\n", "\n", ".enoslib_object input+label {\n", " margin-bottom: 0%;\n", "}\n", "\n", ".object_name {\n", " padding: 6px 0 6px 3px;\n", " border-bottom-width: 1px;\n", " border-bottom-style: solid;\n", " border-bottom-color: #777;\n", " color: #555;\n", "}\n", "\n", ".object_name>div,\n", ".object_name>ul {\n", " display: inline;\n", " margin-top: 0;\n", " margin-bottom: 0;\n", "}\n", "\n", "ul {\n", " list-style: none !important;\n", " padding: 3px !important;\n", " margin: 0 !important;\n", "}\n", "\n", "input.att+label {\n", " display: inline-block;\n", " /*width: 140px;*/\n", " color: rgb(36, 35, 35);\n", " font-weight: 500;\n", " padding: 4px 0 2px 0;\n", "}\n", "\n", "input.att:enabled+label {\n", " cursor: pointer;\n", " width: auto;\n", "}\n", "\n", "input.att {\n", " display: none;\n", "}\n", "\n", "input.att+label:before {\n", " display: inline-block;\n", " content: '►';\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", "}\n", "\n", "input.att:checked+label:before {\n", " content: '▼';\n", "}\n", "\n", "input.att:disabled+label:before {\n", " content: none;\n", "}\n", "\n", "input.att+label>span {\n", " display: inline-block;\n", " margin-left: 4px;\n", "}\n", "\n", "input.att+label>span.len {\n", " font-size: small;\n", "}\n", "\n", "input.att:checked+label>span.len {\n", " display: none;\n", "}\n", "\n", "label+span {\n", " color: rgb(70, 69, 69);\n", "}\n", "\n", "input.att~ul {\n", " display: none;\n", "}\n", "\n", "input.att:checked~ul {\n", " display: block;\n", "}\n", "\n", "table {\n", " width: auto;\n", " border-collapse: collapse;\n", " margin: 2%;\n", "}\n", "\n", "td,\n", "th {\n", " padding: 8px;\n", " height: 15px;\n", " font-size: small;\n", "}\n", "\n", "td {\n", " text-align: left !important;\n", " color: rgb(160, 160, 160)\n", "}\n", "\n", "th {\n", " text-align: center;\n", " color: black;\n", "}\n", "\n", "input~ul {\n", " position: relative;\n", " left: 25px;\n", "}\n", "\n", "input.att~table {\n", " display: none;\n", "}\n", "\n", "input.att:checked~table {\n", " display: block;\n", "} </style>\n", " <div class=\"enoslib\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.api.Results'>\n", " </div>\n", " <ul class=\"list\">\n", " <table><thead><tr><th>host</th><th>task</th><th>status</th><th>payload</th></tr></thead><tbody><tr><td>parasilo-20.rennes.grid5000.fr</td><td>date</td><td>OK</td><td><table><tr><th>stdout</th><td>Fri 27 Aug 2021 10:01:29 AM CEST</td></tr><tr><th>stderr</th><td></td></tr><tr><th>rc</th><td>0</td></tr></table></td></tr></tbody></table>\n", " </ul>\n", " </div>\n", " </div>\n", " " ], "text/plain": [ "CommandResult(host='parasilo-20.rennes.grid5000.fr', task='date', status='OK', payload={'cmd': 'date', 'stdout': 'Fri 27 Aug 2021 10:01:29 AM CEST', 'stderr': '', 'rc': 0, 'start': '2021-08-27 10:01:29.927075', 'end': '2021-08-27 10:01:29.929257', 'delta': '0:00:00.002182', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'date', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['Fri 27 Aug 2021 10:01:29 AM CEST'], 'stderr_lines': [], '_ansible_no_log': False})" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# a single host\n", "en.run_command(\"date\", roles=roles[\"control\"][0])" ] }, { "cell_type": "code", "execution_count": 17, "id": "8251db69-92a7-48e9-99c1-8fa7f2825408", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "PLAY [all] ***********************************************************************************************************************************************************************************\n", "\n", "TASK [date] **********************************************************************************************************************************************************************************\n", " [started TASK: date on rennes.grid5000.fr]\n", "changed: [rennes.grid5000.fr]\n" ] }, { "data": { "text/html": [ "\n", " <style> .enoslib {\n", " width: auto;\n", "}\n", "\n", ".enoslib_object {\n", " width: auto;\n", " font-size: 1em;\n", " line-height: 1.5;\n", " background-color: rgb(250, 249, 249);\n", " font-family: 'Segoe UI';\n", " color: black;\n", "}\n", "\n", ".enoslib_object ul {\n", " padding: 0;\n", "}\n", "\n", ".enoslib_object input+label {\n", " margin-bottom: 0%;\n", "}\n", "\n", ".object_name {\n", " padding: 6px 0 6px 3px;\n", " border-bottom-width: 1px;\n", " border-bottom-style: solid;\n", " border-bottom-color: #777;\n", " color: #555;\n", "}\n", "\n", ".object_name>div,\n", ".object_name>ul {\n", " display: inline;\n", " margin-top: 0;\n", " margin-bottom: 0;\n", "}\n", "\n", "ul {\n", " list-style: none !important;\n", " padding: 3px !important;\n", " margin: 0 !important;\n", "}\n", "\n", "input.att+label {\n", " display: inline-block;\n", " /*width: 140px;*/\n", " color: rgb(36, 35, 35);\n", " font-weight: 500;\n", " padding: 4px 0 2px 0;\n", "}\n", "\n", "input.att:enabled+label {\n", " cursor: pointer;\n", " width: auto;\n", "}\n", "\n", "input.att {\n", " display: none;\n", "}\n", "\n", "input.att+label:before {\n", " display: inline-block;\n", " content: '►';\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", "}\n", "\n", "input.att:checked+label:before {\n", " content: '▼';\n", "}\n", "\n", "input.att:disabled+label:before {\n", " content: none;\n", "}\n", "\n", "input.att+label>span {\n", " display: inline-block;\n", " margin-left: 4px;\n", "}\n", "\n", "input.att+label>span.len {\n", " font-size: small;\n", "}\n", "\n", "input.att:checked+label>span.len {\n", " display: none;\n", "}\n", "\n", "label+span {\n", " color: rgb(70, 69, 69);\n", "}\n", "\n", "input.att~ul {\n", " display: none;\n", "}\n", "\n", "input.att:checked~ul {\n", " display: block;\n", "}\n", "\n", "table {\n", " width: auto;\n", " border-collapse: collapse;\n", " margin: 2%;\n", "}\n", "\n", "td,\n", "th {\n", " padding: 8px;\n", " height: 15px;\n", " font-size: small;\n", "}\n", "\n", "td {\n", " text-align: left !important;\n", " color: rgb(160, 160, 160)\n", "}\n", "\n", "th {\n", " text-align: center;\n", " color: black;\n", "}\n", "\n", "input~ul {\n", " position: relative;\n", " left: 25px;\n", "}\n", "\n", "input.att~table {\n", " display: none;\n", "}\n", "\n", "input.att:checked~table {\n", " display: block;\n", "} </style>\n", " <div class=\"enoslib\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.api.Results'>\n", " </div>\n", " <ul class=\"list\">\n", " <table><thead><tr><th>host</th><th>task</th><th>status</th><th>payload</th></tr></thead><tbody><tr><td>rennes.grid5000.fr</td><td>date</td><td>OK</td><td><table><tr><th>stdout</th><td>Fri 27 Aug 2021 10:01:33 AM CEST</td></tr><tr><th>stderr</th><td></td></tr><tr><th>rc</th><td>0</td></tr></table></td></tr></tbody></table>\n", " </ul>\n", " </div>\n", " </div>\n", " " ], "text/plain": [ "CommandResult(host='rennes.grid5000.fr', task='date', status='OK', payload={'cmd': 'date', 'stdout': 'Fri 27 Aug 2021 10:01:33 AM CEST', 'stderr': '', 'rc': 0, 'start': '2021-08-27 10:01:33.395495', 'end': '2021-08-27 10:01:33.431158', 'delta': '0:00:00.035663', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'date', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['Fri 27 Aug 2021 10:01:33 AM CEST'], 'stderr_lines': [], '_ansible_no_log': False})" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# you can forge some host yourself\n", "# This should work if your SSH parameters are correct\n", "en.run_command(\"date\", roles=en.Host(\"rennes.grid5000.fr\", user=en.g5k_api_utils.get_api_username()))" ] }, { "cell_type": "markdown", "id": "roman-rental", "metadata": { "tags": [], "toc-hr-collapsed": true }, "source": [ "### Remote actions\n", "\n", "Tools like Ansible, Puppet, Chef, Terraform ... are shipped with a set of predefined remote actions to ease the administrator life.\n", "\n", "Actions like copying file, adding some users, managing packages, making sure a line is absent from a configuration file, managing docker containers ... are first-class citizens actions and brings some nice garantees of correctness and idempotency.\n", "\n", "There are 1000+ modules available:\n", "https://docs.ansible.com/ansible/2.9/modules/list_of_all_modules.html\n", "\n", "---\n", "\n", "EnOSlib wraps Ansible module and let you use them from Python (without writting any YAML file). You can call any module by using the `actions` context manager:\n", "\n", "In the following we install docker (using g5k provided script) and a docker container. We also need to install the python docker binding on the remote machine so that Ansible can interact with the docker daemons on the remote machines. This block of actions is idempotent.\n" ] }, { "cell_type": "code", "execution_count": 18, "id": "19670f80-8514-42f2-9039-dc44258cea6a", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "PLAY [all] ***********************************************************************************************************************************************************************************\n", "\n", "TASK [which docker || /grid5000/code/bin/g5k-setup-docker] ***********************************************************************************************************************************\n", " [started TASK: which docker || /grid5000/code/bin/g5k-setup-docker on parasilo-20.rennes.grid5000.fr]\n", " [started TASK: which docker || /grid5000/code/bin/g5k-setup-docker on parasilo-22.rennes.grid5000.fr]\n", "changed: [parasilo-20.rennes.grid5000.fr]\n", "changed: [parasilo-22.rennes.grid5000.fr]\n", "\n", "TASK [pip] ***********************************************************************************************************************************************************************************\n", " [started TASK: pip on parasilo-20.rennes.grid5000.fr]\n", " [started TASK: pip on parasilo-22.rennes.grid5000.fr]\n", "changed: [parasilo-20.rennes.grid5000.fr]\n", "changed: [parasilo-22.rennes.grid5000.fr]\n", "\n", "TASK [docker_container] **********************************************************************************************************************************************************************\n", " [started TASK: docker_container on parasilo-20.rennes.grid5000.fr]\n", " [started TASK: docker_container on parasilo-22.rennes.grid5000.fr]\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "[DEPRECATION WARNING]: The container_default_behavior option will change its default value from \"compatibility\" to \"no_defaults\" in community.docker 2.0.0. To remove this warning, please \n", "specify an explicit value for it now. This feature will be removed from community.docker in version 2.0.0. Deprecation warnings can be disabled by setting deprecation_warnings=False in \n", "ansible.cfg.\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "changed: [parasilo-20.rennes.grid5000.fr]\n", "changed: [parasilo-22.rennes.grid5000.fr]\n", "\n", "TASK [wait_for] ******************************************************************************************************************************************************************************\n", " [started TASK: wait_for on parasilo-20.rennes.grid5000.fr]\n", " [started TASK: wait_for on parasilo-22.rennes.grid5000.fr]\n", "ok: [parasilo-22.rennes.grid5000.fr]\n", "ok: [parasilo-20.rennes.grid5000.fr]\n" ] } ], "source": [ "with en.actions(roles=roles) as a:\n", " # installing the docker daemon\n", " # prepending with a guard to make the command idempotent\n", " a.shell(\"which docker || /grid5000/code/bin/g5k-setup-docker\")\n", " # install the python docker binding on the remote host\n", " # mandatory by the docker_container module\n", " a.pip(name=\"docker\", state=\"present\")\n", " # fire up a container (forward port 80 at the host level)\n", " a.docker_container(name=\"myserver\", image=\"nginx\", state=\"started\", ports=[\"80:80\"])\n", " # wait for the connection on the port 80 to be ready\n", " a.wait_for(port=80, state=\"started\")\n", " # keep track of the result of each modules\n", " # not mandatory but nice :)\n", " results = a.results" ] }, { "cell_type": "code", "execution_count": null, "id": "transparent-tourism", "metadata": {}, "outputs": [], "source": [ "with en.actions(roles=roles) as a:\n", " # prepending with `which docker ||` makes this task idempotent\n", " a.shell(\"which docker || /grid5000/code/bin/g5k-setup-docker\")\n", " a.pip(name=\"docker\", state=\"present\")\n", " a.docker_container(image=\"nginx\", state=\"started\", name=\"my_webserver\")\n", " # we can capture the outputs if we really want to\n", " results = a.results\n", "results" ] }, { "cell_type": "code", "execution_count": null, "id": "affected-zealand", "metadata": {}, "outputs": [], "source": [ "results.filter(task=\"docker_container\")[0]" ] }, { "cell_type": "markdown", "id": "existing-istanbul", "metadata": {}, "source": [ "### Background actions\n", "\n", "Sometime you need to fire a process on some remote machines that needs to survive the remote connection that started it. EnOSlib provides a `keyword` argument for this purpose and can be used when calling modules (when supported)." ] }, { "cell_type": "code", "execution_count": 21, "id": "prepared-needle", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "PLAY [all] ***********************************************************************************************************************************************************************************\n", "\n", "TASK [for i in $(seq 1 10); do sleep 1; echo toto; done] *************************************************************************************************************************************\n", " [started TASK: for i in $(seq 1 10); do sleep 1; echo toto; done on parasilo-20.rennes.grid5000.fr]\n", " [started TASK: for i in $(seq 1 10); do sleep 1; echo toto; done on parasilo-22.rennes.grid5000.fr]\n", "changed: [parasilo-20.rennes.grid5000.fr]\n", "changed: [parasilo-22.rennes.grid5000.fr]\n" ] }, { "data": { "text/html": [ "\n", " <style> .enoslib {\n", " width: auto;\n", "}\n", "\n", ".enoslib_object {\n", " width: auto;\n", " font-size: 1em;\n", " line-height: 1.5;\n", " background-color: rgb(250, 249, 249);\n", " font-family: 'Segoe UI';\n", " color: black;\n", "}\n", "\n", ".enoslib_object ul {\n", " padding: 0;\n", "}\n", "\n", ".enoslib_object input+label {\n", " margin-bottom: 0%;\n", "}\n", "\n", ".object_name {\n", " padding: 6px 0 6px 3px;\n", " border-bottom-width: 1px;\n", " border-bottom-style: solid;\n", " border-bottom-color: #777;\n", " color: #555;\n", "}\n", "\n", ".object_name>div,\n", ".object_name>ul {\n", " display: inline;\n", " margin-top: 0;\n", " margin-bottom: 0;\n", "}\n", "\n", "ul {\n", " list-style: none !important;\n", " padding: 3px !important;\n", " margin: 0 !important;\n", "}\n", "\n", "input.att+label {\n", " display: inline-block;\n", " /*width: 140px;*/\n", " color: rgb(36, 35, 35);\n", " font-weight: 500;\n", " padding: 4px 0 2px 0;\n", "}\n", "\n", "input.att:enabled+label {\n", " cursor: pointer;\n", " width: auto;\n", "}\n", "\n", "input.att {\n", " display: none;\n", "}\n", "\n", "input.att+label:before {\n", " display: inline-block;\n", " content: '►';\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", "}\n", "\n", "input.att:checked+label:before {\n", " content: '▼';\n", "}\n", "\n", "input.att:disabled+label:before {\n", " content: none;\n", "}\n", "\n", "input.att+label>span {\n", " display: inline-block;\n", " margin-left: 4px;\n", "}\n", "\n", "input.att+label>span.len {\n", " font-size: small;\n", "}\n", "\n", "input.att:checked+label>span.len {\n", " display: none;\n", "}\n", "\n", "label+span {\n", " color: rgb(70, 69, 69);\n", "}\n", "\n", "input.att~ul {\n", " display: none;\n", "}\n", "\n", "input.att:checked~ul {\n", " display: block;\n", "}\n", "\n", "table {\n", " width: auto;\n", " border-collapse: collapse;\n", " margin: 2%;\n", "}\n", "\n", "td,\n", "th {\n", " padding: 8px;\n", " height: 15px;\n", " font-size: small;\n", "}\n", "\n", "td {\n", " text-align: left !important;\n", " color: rgb(160, 160, 160)\n", "}\n", "\n", "th {\n", " text-align: center;\n", " color: black;\n", "}\n", "\n", "input~ul {\n", " position: relative;\n", " left: 25px;\n", "}\n", "\n", "input.att~table {\n", " display: none;\n", "}\n", "\n", "input.att:checked~table {\n", " display: block;\n", "} </style>\n", " <div class=\"enoslib\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.api.Results'>\n", " </div>\n", " <ul class=\"list\">\n", " <table><thead><tr><th>host</th><th>task</th><th>status</th><th>payload</th></tr></thead><tbody><tr><td>parasilo-20.rennes.grid5000.fr</td><td>for i in $(seq 1 10); do sleep 1; echo toto; done</td><td>OK</td><td><table><tr><th>stdout</th><td>toto\n", "toto\n", "toto\n", "toto\n", "toto\n", "toto\n", "toto\n", "toto\n", "toto\n", "toto</td></tr><tr><th>stderr</th><td></td></tr><tr><th>rc</th><td>0</td></tr></table></td></tr><tr><td>parasilo-22.rennes.grid5000.fr</td><td>for i in $(seq 1 10); do sleep 1; echo toto; done</td><td>OK</td><td><table><tr><th>stdout</th><td>toto\n", "toto\n", "toto\n", "toto\n", "toto\n", "toto\n", "toto\n", "toto\n", "toto\n", "toto</td></tr><tr><th>stderr</th><td></td></tr><tr><th>rc</th><td>0</td></tr></table></td></tr></tbody></table>\n", " </ul>\n", " </div>\n", " </div>\n", " " ], "text/plain": [ "CommandResult(host='parasilo-20.rennes.grid5000.fr', task='for i in $(seq 1 10); do sleep 1; echo toto; done', status='OK', payload={'cmd': 'for i in $(seq 1 10); do sleep 1; echo toto; done', 'stdout': 'toto\\ntoto\\ntoto\\ntoto\\ntoto\\ntoto\\ntoto\\ntoto\\ntoto\\ntoto', 'stderr': '', 'rc': 0, 'start': '2021-08-27 10:02:22.212301', 'end': '2021-08-27 10:02:32.225737', 'delta': '0:00:10.013436', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'for i in $(seq 1 10); do sleep 1; echo toto; done', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['toto', 'toto', 'toto', 'toto', 'toto', 'toto', 'toto', 'toto', 'toto', 'toto'], 'stderr_lines': [], '_ansible_no_log': False})\n", "CommandResult(host='parasilo-22.rennes.grid5000.fr', task='for i in $(seq 1 10); do sleep 1; echo toto; done', status='OK', payload={'cmd': 'for i in $(seq 1 10); do sleep 1; echo toto; done', 'stdout': 'toto\\ntoto\\ntoto\\ntoto\\ntoto\\ntoto\\ntoto\\ntoto\\ntoto\\ntoto', 'stderr': '', 'rc': 0, 'start': '2021-08-27 10:02:22.219646', 'end': '2021-08-27 10:02:32.241039', 'delta': '0:00:10.021393', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'for i in $(seq 1 10); do sleep 1; echo toto; done', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['toto', 'toto', 'toto', 'toto', 'toto', 'toto', 'toto', 'toto', 'toto', 'toto'], 'stderr_lines': [], '_ansible_no_log': False})" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# synchronous execution, will wait until the end of the shell command\n", "results = en.run_command(\"for i in $(seq 1 10); do sleep 1; echo toto; done\", roles=roles)\n", "results" ] }, { "cell_type": "code", "execution_count": 22, "id": "driving-frederick", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "PLAY [all] ***********************************************************************************************************************************************************************************\n", "\n", "TASK [for i in $(seq 1 10); do sleep 1; echo toto; done] *************************************************************************************************************************************\n", " [started TASK: for i in $(seq 1 10); do sleep 1; echo toto; done on parasilo-20.rennes.grid5000.fr]\n", " [started TASK: for i in $(seq 1 10); do sleep 1; echo toto; done on parasilo-22.rennes.grid5000.fr]\n", "changed: [parasilo-20.rennes.grid5000.fr]\n", "changed: [parasilo-22.rennes.grid5000.fr]\n" ] }, { "data": { "text/html": [ "\n", " <style> .enoslib {\n", " width: auto;\n", "}\n", "\n", ".enoslib_object {\n", " width: auto;\n", " font-size: 1em;\n", " line-height: 1.5;\n", " background-color: rgb(250, 249, 249);\n", " font-family: 'Segoe UI';\n", " color: black;\n", "}\n", "\n", ".enoslib_object ul {\n", " padding: 0;\n", "}\n", "\n", ".enoslib_object input+label {\n", " margin-bottom: 0%;\n", "}\n", "\n", ".object_name {\n", " padding: 6px 0 6px 3px;\n", " border-bottom-width: 1px;\n", " border-bottom-style: solid;\n", " border-bottom-color: #777;\n", " color: #555;\n", "}\n", "\n", ".object_name>div,\n", ".object_name>ul {\n", " display: inline;\n", " margin-top: 0;\n", " margin-bottom: 0;\n", "}\n", "\n", "ul {\n", " list-style: none !important;\n", " padding: 3px !important;\n", " margin: 0 !important;\n", "}\n", "\n", "input.att+label {\n", " display: inline-block;\n", " /*width: 140px;*/\n", " color: rgb(36, 35, 35);\n", " font-weight: 500;\n", " padding: 4px 0 2px 0;\n", "}\n", "\n", "input.att:enabled+label {\n", " cursor: pointer;\n", " width: auto;\n", "}\n", "\n", "input.att {\n", " display: none;\n", "}\n", "\n", "input.att+label:before {\n", " display: inline-block;\n", " content: '►';\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", "}\n", "\n", "input.att:checked+label:before {\n", " content: '▼';\n", "}\n", "\n", "input.att:disabled+label:before {\n", " content: none;\n", "}\n", "\n", "input.att+label>span {\n", " display: inline-block;\n", " margin-left: 4px;\n", "}\n", "\n", "input.att+label>span.len {\n", " font-size: small;\n", "}\n", "\n", "input.att:checked+label>span.len {\n", " display: none;\n", "}\n", "\n", "label+span {\n", " color: rgb(70, 69, 69);\n", "}\n", "\n", "input.att~ul {\n", " display: none;\n", "}\n", "\n", "input.att:checked~ul {\n", " display: block;\n", "}\n", "\n", "table {\n", " width: auto;\n", " border-collapse: collapse;\n", " margin: 2%;\n", "}\n", "\n", "td,\n", "th {\n", " padding: 8px;\n", " height: 15px;\n", " font-size: small;\n", "}\n", "\n", "td {\n", " text-align: left !important;\n", " color: rgb(160, 160, 160)\n", "}\n", "\n", "th {\n", " text-align: center;\n", " color: black;\n", "}\n", "\n", "input~ul {\n", " position: relative;\n", " left: 25px;\n", "}\n", "\n", "input.att~table {\n", " display: none;\n", "}\n", "\n", "input.att:checked~table {\n", " display: block;\n", "} </style>\n", " <div class=\"enoslib\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.api.Results'>\n", " </div>\n", " <ul class=\"list\">\n", " <table><thead><tr><th>host</th><th>task</th><th>status</th><th>payload</th></tr></thead><tbody><tr><td>parasilo-20.rennes.grid5000.fr</td><td>for i in $(seq 1 10); do sleep 1; echo toto; done</td><td>OK</td><td><table><tr><th>results_file</th><td>/root/.ansible_async/637941494077.30972</td></tr><tr><th>ansible_job_id</th><td>637941494077.30972</td></tr></table></td></tr><tr><td>parasilo-22.rennes.grid5000.fr</td><td>for i in $(seq 1 10); do sleep 1; echo toto; done</td><td>OK</td><td><table><tr><th>results_file</th><td>/root/.ansible_async/545447948435.15233</td></tr><tr><th>ansible_job_id</th><td>545447948435.15233</td></tr></table></td></tr></tbody></table>\n", " </ul>\n", " </div>\n", " </div>\n", " " ], "text/plain": [ "AsyncCommandResult(host='parasilo-20.rennes.grid5000.fr', task='for i in $(seq 1 10); do sleep 1; echo toto; done', status='OK', payload={'started': 1, 'finished': 0, 'ansible_job_id': '637941494077.30972', 'results_file': '/root/.ansible_async/637941494077.30972', 'changed': True, '_ansible_no_log': False})\n", "AsyncCommandResult(host='parasilo-22.rennes.grid5000.fr', task='for i in $(seq 1 10); do sleep 1; echo toto; done', status='OK', payload={'started': 1, 'finished': 0, 'ansible_job_id': '545447948435.15233', 'results_file': '/root/.ansible_async/545447948435.15233', 'changed': True, '_ansible_no_log': False})" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# The remote command will be daemonize on the remote machines\n", "results = en.run_command(\"for i in $(seq 1 10); do sleep 1; echo toto; done\", roles=roles, background=True)\n", "results" ] }, { "cell_type": "code", "execution_count": 25, "id": "middle-ozone", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "PLAY [all] ***********************************************************************************************************************************************************************************\n", "\n", "TASK [cat /root/.ansible_async/637941494077.30972] *******************************************************************************************************************************************\n", " [started TASK: cat /root/.ansible_async/637941494077.30972 on parasilo-20.rennes.grid5000.fr]\n", "changed: [parasilo-20.rennes.grid5000.fr]\n" ] }, { "data": { "text/html": [ "\n", " <style> .enoslib {\n", " width: auto;\n", "}\n", "\n", ".enoslib_object {\n", " width: auto;\n", " font-size: 1em;\n", " line-height: 1.5;\n", " background-color: rgb(250, 249, 249);\n", " font-family: 'Segoe UI';\n", " color: black;\n", "}\n", "\n", ".enoslib_object ul {\n", " padding: 0;\n", "}\n", "\n", ".enoslib_object input+label {\n", " margin-bottom: 0%;\n", "}\n", "\n", ".object_name {\n", " padding: 6px 0 6px 3px;\n", " border-bottom-width: 1px;\n", " border-bottom-style: solid;\n", " border-bottom-color: #777;\n", " color: #555;\n", "}\n", "\n", ".object_name>div,\n", ".object_name>ul {\n", " display: inline;\n", " margin-top: 0;\n", " margin-bottom: 0;\n", "}\n", "\n", "ul {\n", " list-style: none !important;\n", " padding: 3px !important;\n", " margin: 0 !important;\n", "}\n", "\n", "input.att+label {\n", " display: inline-block;\n", " /*width: 140px;*/\n", " color: rgb(36, 35, 35);\n", " font-weight: 500;\n", " padding: 4px 0 2px 0;\n", "}\n", "\n", "input.att:enabled+label {\n", " cursor: pointer;\n", " width: auto;\n", "}\n", "\n", "input.att {\n", " display: none;\n", "}\n", "\n", "input.att+label:before {\n", " display: inline-block;\n", " content: '►';\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", "}\n", "\n", "input.att:checked+label:before {\n", " content: '▼';\n", "}\n", "\n", "input.att:disabled+label:before {\n", " content: none;\n", "}\n", "\n", "input.att+label>span {\n", " display: inline-block;\n", " margin-left: 4px;\n", "}\n", "\n", "input.att+label>span.len {\n", " font-size: small;\n", "}\n", "\n", "input.att:checked+label>span.len {\n", " display: none;\n", "}\n", "\n", "label+span {\n", " color: rgb(70, 69, 69);\n", "}\n", "\n", "input.att~ul {\n", " display: none;\n", "}\n", "\n", "input.att:checked~ul {\n", " display: block;\n", "}\n", "\n", "table {\n", " width: auto;\n", " border-collapse: collapse;\n", " margin: 2%;\n", "}\n", "\n", "td,\n", "th {\n", " padding: 8px;\n", " height: 15px;\n", " font-size: small;\n", "}\n", "\n", "td {\n", " text-align: left !important;\n", " color: rgb(160, 160, 160)\n", "}\n", "\n", "th {\n", " text-align: center;\n", " color: black;\n", "}\n", "\n", "input~ul {\n", " position: relative;\n", " left: 25px;\n", "}\n", "\n", "input.att~table {\n", " display: none;\n", "}\n", "\n", "input.att:checked~table {\n", " display: block;\n", "} </style>\n", " <div class=\"enoslib\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.api.Results'>\n", " </div>\n", " <ul class=\"list\">\n", " <table><thead><tr><th>host</th><th>task</th><th>status</th><th>payload</th></tr></thead><tbody><tr><td>parasilo-20.rennes.grid5000.fr</td><td>cat /root/.ansible_async/637941494077.30972</td><td>OK</td><td><table><tr><th>stdout</th><td>{"cmd": "for i in $(seq 1 10); do sleep 1; echo to[...]</td></tr><tr><th>stderr</th><td></td></tr><tr><th>rc</th><td>0</td></tr></table></td></tr></tbody></table>\n", " </ul>\n", " </div>\n", " </div>\n", " " ], "text/plain": [ "CommandResult(host='parasilo-20.rennes.grid5000.fr', task='cat /root/.ansible_async/637941494077.30972', status='OK', payload={'cmd': 'cat /root/.ansible_async/637941494077.30972', 'stdout': '{\"cmd\": \"for i in $(seq 1 10); do sleep 1; echo toto; done\", \"stdout\": \"toto\\\\ntoto\\\\ntoto\\\\ntoto\\\\ntoto\\\\ntoto\\\\ntoto\\\\ntoto\\\\ntoto\\\\ntoto\", \"stderr\": \"\", \"rc\": 0, \"start\": \"2021-08-27 10:02:34.096318\", \"end\": \"2021-08-27 10:02:44.106273\", \"delta\": \"0:00:10.009955\", \"changed\": true, \"invocation\": {\"module_args\": {\"_raw_params\": \"for i in $(seq 1 10); do sleep 1; echo toto; done\", \"_uses_shell\": true, \"warn\": true, \"stdin_add_newline\": true, \"strip_empty_ends\": true, \"argv\": null, \"chdir\": null, \"executable\": null, \"creates\": null, \"removes\": null, \"stdin\": null}}}', 'stderr': '', 'rc': 0, 'start': '2021-08-27 10:02:44.221192', 'end': '2021-08-27 10:02:44.223592', 'delta': '0:00:00.002400', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'cat /root/.ansible_async/637941494077.30972', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['{\"cmd\": \"for i in $(seq 1 10); do sleep 1; echo toto; done\", \"stdout\": \"toto\\\\ntoto\\\\ntoto\\\\ntoto\\\\ntoto\\\\ntoto\\\\ntoto\\\\ntoto\\\\ntoto\\\\ntoto\", \"stderr\": \"\", \"rc\": 0, \"start\": \"2021-08-27 10:02:34.096318\", \"end\": \"2021-08-27 10:02:44.106273\", \"delta\": \"0:00:10.009955\", \"changed\": true, \"invocation\": {\"module_args\": {\"_raw_params\": \"for i in $(seq 1 10); do sleep 1; echo toto; done\", \"_uses_shell\": true, \"warn\": true, \"stdin_add_newline\": true, \"strip_empty_ends\": true, \"argv\": null, \"chdir\": null, \"executable\": null, \"creates\": null, \"removes\": null, \"stdin\": null}}}'], 'stderr_lines': [], '_ansible_no_log': False})" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# you can get back the status of the daemonized process by reading the remote results_file\n", "h = roles[\"control\"][0]\n", "result_file = results.filter(host=h.alias)[0].results_file\n", "cat_result = en.run_command(f\"cat {result_file}\",roles=h)\n", "cat_result" ] }, { "cell_type": "code", "execution_count": 26, "id": "cognitive-travel", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "toto\n", "toto\n", "toto\n", "toto\n", "toto\n", "toto\n", "toto\n", "toto\n", "toto\n", "toto\n" ] } ], "source": [ "# the result_file content is json encoded so decoding it\n", "import json\n", "print(json.loads(cat_result[0].stdout)[\"stdout\"])" ] }, { "cell_type": "markdown", "id": "involved-screening", "metadata": {}, "source": [ "## Using variables" ] }, { "cell_type": "markdown", "id": "impressive-gibraltar", "metadata": {}, "source": [ "### Same variable value for everyone\n", "\n", "Nothing surprising here, you can use regular python interpolation (e.g a `f-string`).\n", "String are interpolated by the interpreter before being manipulated." ] }, { "cell_type": "code", "execution_count": 27, "id": "ideal-transparency", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "PLAY [all] ***********************************************************************************************************************************************************************************\n", "\n", "TASK [ping -c 5 parasilo-20.rennes.grid5000.fr] **********************************************************************************************************************************************\n", " [started TASK: ping -c 5 parasilo-20.rennes.grid5000.fr on parasilo-20.rennes.grid5000.fr]\n", " [started TASK: ping -c 5 parasilo-20.rennes.grid5000.fr on parasilo-22.rennes.grid5000.fr]\n", "changed: [parasilo-20.rennes.grid5000.fr]\n", "changed: [parasilo-22.rennes.grid5000.fr]\n" ] }, { "data": { "text/html": [ "\n", " <style> .enoslib {\n", " width: auto;\n", "}\n", "\n", ".enoslib_object {\n", " width: auto;\n", " font-size: 1em;\n", " line-height: 1.5;\n", " background-color: rgb(250, 249, 249);\n", " font-family: 'Segoe UI';\n", " color: black;\n", "}\n", "\n", ".enoslib_object ul {\n", " padding: 0;\n", "}\n", "\n", ".enoslib_object input+label {\n", " margin-bottom: 0%;\n", "}\n", "\n", ".object_name {\n", " padding: 6px 0 6px 3px;\n", " border-bottom-width: 1px;\n", " border-bottom-style: solid;\n", " border-bottom-color: #777;\n", " color: #555;\n", "}\n", "\n", ".object_name>div,\n", ".object_name>ul {\n", " display: inline;\n", " margin-top: 0;\n", " margin-bottom: 0;\n", "}\n", "\n", "ul {\n", " list-style: none !important;\n", " padding: 3px !important;\n", " margin: 0 !important;\n", "}\n", "\n", "input.att+label {\n", " display: inline-block;\n", " /*width: 140px;*/\n", " color: rgb(36, 35, 35);\n", " font-weight: 500;\n", " padding: 4px 0 2px 0;\n", "}\n", "\n", "input.att:enabled+label {\n", " cursor: pointer;\n", " width: auto;\n", "}\n", "\n", "input.att {\n", " display: none;\n", "}\n", "\n", "input.att+label:before {\n", " display: inline-block;\n", " content: '►';\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", "}\n", "\n", "input.att:checked+label:before {\n", " content: '▼';\n", "}\n", "\n", "input.att:disabled+label:before {\n", " content: none;\n", "}\n", "\n", "input.att+label>span {\n", " display: inline-block;\n", " margin-left: 4px;\n", "}\n", "\n", "input.att+label>span.len {\n", " font-size: small;\n", "}\n", "\n", "input.att:checked+label>span.len {\n", " display: none;\n", "}\n", "\n", "label+span {\n", " color: rgb(70, 69, 69);\n", "}\n", "\n", "input.att~ul {\n", " display: none;\n", "}\n", "\n", "input.att:checked~ul {\n", " display: block;\n", "}\n", "\n", "table {\n", " width: auto;\n", " border-collapse: collapse;\n", " margin: 2%;\n", "}\n", "\n", "td,\n", "th {\n", " padding: 8px;\n", " height: 15px;\n", " font-size: small;\n", "}\n", "\n", "td {\n", " text-align: left !important;\n", " color: rgb(160, 160, 160)\n", "}\n", "\n", "th {\n", " text-align: center;\n", " color: black;\n", "}\n", "\n", "input~ul {\n", " position: relative;\n", " left: 25px;\n", "}\n", "\n", "input.att~table {\n", " display: none;\n", "}\n", "\n", "input.att:checked~table {\n", " display: block;\n", "} </style>\n", " <div class=\"enoslib\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.api.Results'>\n", " </div>\n", " <ul class=\"list\">\n", " <table><thead><tr><th>host</th><th>task</th><th>status</th><th>payload</th></tr></thead><tbody><tr><td>parasilo-20.rennes.grid5000.fr</td><td>ping -c 5 parasilo-20.rennes.grid5000.fr</td><td>OK</td><td><table><tr><th>stdout</th><td>PING parasilo-20.rennes.grid5000.fr (172.16.97.20)[...]</td></tr><tr><th>stderr</th><td></td></tr><tr><th>rc</th><td>0</td></tr></table></td></tr><tr><td>parasilo-22.rennes.grid5000.fr</td><td>ping -c 5 parasilo-20.rennes.grid5000.fr</td><td>OK</td><td><table><tr><th>stdout</th><td>PING parasilo-20.rennes.grid5000.fr (172.16.97.20)[...]</td></tr><tr><th>stderr</th><td></td></tr><tr><th>rc</th><td>0</td></tr></table></td></tr></tbody></table>\n", " </ul>\n", " </div>\n", " </div>\n", " " ], "text/plain": [ "CommandResult(host='parasilo-20.rennes.grid5000.fr', task='ping -c 5 parasilo-20.rennes.grid5000.fr', status='OK', payload={'cmd': 'ping -c 5 parasilo-20.rennes.grid5000.fr', 'stdout': 'PING parasilo-20.rennes.grid5000.fr (172.16.97.20) 56(84) bytes of data.\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=1 ttl=64 time=0.041 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=2 ttl=64 time=0.031 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=3 ttl=64 time=0.017 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=4 ttl=64 time=0.032 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=5 ttl=64 time=0.017 ms\\n\\n--- parasilo-20.rennes.grid5000.fr ping statistics ---\\n5 packets transmitted, 5 received, 0% packet loss, time 85ms\\nrtt min/avg/max/mdev = 0.017/0.027/0.041/0.010 ms', 'stderr': '', 'rc': 0, 'start': '2021-08-27 10:02:49.579346', 'end': '2021-08-27 10:02:53.677186', 'delta': '0:00:04.097840', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'ping -c 5 parasilo-20.rennes.grid5000.fr', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['PING parasilo-20.rennes.grid5000.fr (172.16.97.20) 56(84) bytes of data.', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=1 ttl=64 time=0.041 ms', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=2 ttl=64 time=0.031 ms', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=3 ttl=64 time=0.017 ms', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=4 ttl=64 time=0.032 ms', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=5 ttl=64 time=0.017 ms', '', '--- parasilo-20.rennes.grid5000.fr ping statistics ---', '5 packets transmitted, 5 received, 0% packet loss, time 85ms', 'rtt min/avg/max/mdev = 0.017/0.027/0.041/0.010 ms'], 'stderr_lines': [], '_ansible_no_log': False})\n", "CommandResult(host='parasilo-22.rennes.grid5000.fr', task='ping -c 5 parasilo-20.rennes.grid5000.fr', status='OK', payload={'cmd': 'ping -c 5 parasilo-20.rennes.grid5000.fr', 'stdout': 'PING parasilo-20.rennes.grid5000.fr (172.16.97.20) 56(84) bytes of data.\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=1 ttl=64 time=0.312 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=2 ttl=64 time=0.197 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=3 ttl=64 time=0.189 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=4 ttl=64 time=0.169 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=5 ttl=64 time=0.154 ms\\n\\n--- parasilo-20.rennes.grid5000.fr ping statistics ---\\n5 packets transmitted, 5 received, 0% packet loss, time 102ms\\nrtt min/avg/max/mdev = 0.154/0.204/0.312/0.056 ms', 'stderr': '', 'rc': 0, 'start': '2021-08-27 10:02:49.604515', 'end': '2021-08-27 10:02:53.717385', 'delta': '0:00:04.112870', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'ping -c 5 parasilo-20.rennes.grid5000.fr', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['PING parasilo-20.rennes.grid5000.fr (172.16.97.20) 56(84) bytes of data.', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=1 ttl=64 time=0.312 ms', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=2 ttl=64 time=0.197 ms', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=3 ttl=64 time=0.189 ms', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=4 ttl=64 time=0.169 ms', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=5 ttl=64 time=0.154 ms', '', '--- parasilo-20.rennes.grid5000.fr ping statistics ---', '5 packets transmitted, 5 received, 0% packet loss, time 102ms', 'rtt min/avg/max/mdev = 0.154/0.204/0.312/0.056 ms'], 'stderr_lines': [], '_ansible_no_log': False})" ] }, "execution_count": 27, "metadata": {}, "output_type": "execute_result" } ], "source": [ "host_to_ping = roles[\"control\"][0].alias\n", "host_to_ping\n", "\n", "results = en.run_command(f\"ping -c 5 {host_to_ping}\", roles=roles)\n", "results" ] }, { "cell_type": "code", "execution_count": 28, "id": "bored-cardiff", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[('parasilo-20.rennes.grid5000.fr',\n", " 'PING parasilo-20.rennes.grid5000.fr (172.16.97.20) 56(84) bytes of data.\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=1 ttl=64 time=0.041 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=2 ttl=64 time=0.031 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=3 ttl=64 time=0.017 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=4 ttl=64 time=0.032 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=5 ttl=64 time=0.017 ms\\n\\n--- parasilo-20.rennes.grid5000.fr ping statistics ---\\n5 packets transmitted, 5 received, 0% packet loss, time 85ms\\nrtt min/avg/max/mdev = 0.017/0.027/0.041/0.010 ms'),\n", " ('parasilo-22.rennes.grid5000.fr',\n", " 'PING parasilo-20.rennes.grid5000.fr (172.16.97.20) 56(84) bytes of data.\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=1 ttl=64 time=0.312 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=2 ttl=64 time=0.197 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=3 ttl=64 time=0.189 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=4 ttl=64 time=0.169 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=5 ttl=64 time=0.154 ms\\n\\n--- parasilo-20.rennes.grid5000.fr ping statistics ---\\n5 packets transmitted, 5 received, 0% packet loss, time 102ms\\nrtt min/avg/max/mdev = 0.154/0.204/0.312/0.056 ms')]" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "[(r.host, r.stdout) for r in results]" ] }, { "cell_type": "markdown", "id": "disciplinary-participation", "metadata": {}, "source": [ "### Using templates / Ansible variables\n", "\n", "There's an alternative way to pass a variable to a task: using `extra_vars`.\n", "The difference with the previous case (python interpreted variables) is the fact that the variable is interpolated right before execution happens on the remote node.\n", "One could imagine the the value is broadcasted to all nodes and replaced right before the execution.\n", "\n", "To indicate that we want to use this kind of variables, we need to pass its value using the `extra_vars` dictionnary and use a template (`{{ ... }}`) in the task description." ] }, { "cell_type": "code", "execution_count": 29, "id": "solar-eleven", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "PLAY [all] ***********************************************************************************************************************************************************************************\n", "\n", "TASK [ping -c 5 parasilo-20.rennes.grid5000.fr] **********************************************************************************************************************************************\n", " [started TASK: ping -c 5 {{ my_template_variable }} on parasilo-20.rennes.grid5000.fr]\n", " [started TASK: ping -c 5 {{ my_template_variable }} on parasilo-22.rennes.grid5000.fr]\n", "changed: [parasilo-20.rennes.grid5000.fr]\n", "changed: [parasilo-22.rennes.grid5000.fr]\n" ] }, { "data": { "text/html": [ "\n", " <style> .enoslib {\n", " width: auto;\n", "}\n", "\n", ".enoslib_object {\n", " width: auto;\n", " font-size: 1em;\n", " line-height: 1.5;\n", " background-color: rgb(250, 249, 249);\n", " font-family: 'Segoe UI';\n", " color: black;\n", "}\n", "\n", ".enoslib_object ul {\n", " padding: 0;\n", "}\n", "\n", ".enoslib_object input+label {\n", " margin-bottom: 0%;\n", "}\n", "\n", ".object_name {\n", " padding: 6px 0 6px 3px;\n", " border-bottom-width: 1px;\n", " border-bottom-style: solid;\n", " border-bottom-color: #777;\n", " color: #555;\n", "}\n", "\n", ".object_name>div,\n", ".object_name>ul {\n", " display: inline;\n", " margin-top: 0;\n", " margin-bottom: 0;\n", "}\n", "\n", "ul {\n", " list-style: none !important;\n", " padding: 3px !important;\n", " margin: 0 !important;\n", "}\n", "\n", "input.att+label {\n", " display: inline-block;\n", " /*width: 140px;*/\n", " color: rgb(36, 35, 35);\n", " font-weight: 500;\n", " padding: 4px 0 2px 0;\n", "}\n", "\n", "input.att:enabled+label {\n", " cursor: pointer;\n", " width: auto;\n", "}\n", "\n", "input.att {\n", " display: none;\n", "}\n", "\n", "input.att+label:before {\n", " display: inline-block;\n", " content: '►';\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", "}\n", "\n", "input.att:checked+label:before {\n", " content: '▼';\n", "}\n", "\n", "input.att:disabled+label:before {\n", " content: none;\n", "}\n", "\n", "input.att+label>span {\n", " display: inline-block;\n", " margin-left: 4px;\n", "}\n", "\n", "input.att+label>span.len {\n", " font-size: small;\n", "}\n", "\n", "input.att:checked+label>span.len {\n", " display: none;\n", "}\n", "\n", "label+span {\n", " color: rgb(70, 69, 69);\n", "}\n", "\n", "input.att~ul {\n", " display: none;\n", "}\n", "\n", "input.att:checked~ul {\n", " display: block;\n", "}\n", "\n", "table {\n", " width: auto;\n", " border-collapse: collapse;\n", " margin: 2%;\n", "}\n", "\n", "td,\n", "th {\n", " padding: 8px;\n", " height: 15px;\n", " font-size: small;\n", "}\n", "\n", "td {\n", " text-align: left !important;\n", " color: rgb(160, 160, 160)\n", "}\n", "\n", "th {\n", " text-align: center;\n", " color: black;\n", "}\n", "\n", "input~ul {\n", " position: relative;\n", " left: 25px;\n", "}\n", "\n", "input.att~table {\n", " display: none;\n", "}\n", "\n", "input.att:checked~table {\n", " display: block;\n", "} </style>\n", " <div class=\"enoslib\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.api.Results'>\n", " </div>\n", " <ul class=\"list\">\n", " <table><thead><tr><th>host</th><th>task</th><th>status</th><th>payload</th></tr></thead><tbody><tr><td>parasilo-20.rennes.grid5000.fr</td><td>ping -c 5 parasilo-20.rennes.grid5000.fr</td><td>OK</td><td><table><tr><th>stdout</th><td>PING parasilo-20.rennes.grid5000.fr (172.16.97.20)[...]</td></tr><tr><th>stderr</th><td></td></tr><tr><th>rc</th><td>0</td></tr></table></td></tr><tr><td>parasilo-22.rennes.grid5000.fr</td><td>ping -c 5 parasilo-20.rennes.grid5000.fr</td><td>OK</td><td><table><tr><th>stdout</th><td>PING parasilo-20.rennes.grid5000.fr (172.16.97.20)[...]</td></tr><tr><th>stderr</th><td></td></tr><tr><th>rc</th><td>0</td></tr></table></td></tr></tbody></table>\n", " </ul>\n", " </div>\n", " </div>\n", " " ], "text/plain": [ "CommandResult(host='parasilo-20.rennes.grid5000.fr', task='ping -c 5 parasilo-20.rennes.grid5000.fr', status='OK', payload={'cmd': 'ping -c 5 parasilo-20.rennes.grid5000.fr', 'stdout': 'PING parasilo-20.rennes.grid5000.fr (172.16.97.20) 56(84) bytes of data.\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=1 ttl=64 time=0.040 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=2 ttl=64 time=0.031 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=3 ttl=64 time=0.032 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=4 ttl=64 time=0.017 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=5 ttl=64 time=0.032 ms\\n\\n--- parasilo-20.rennes.grid5000.fr ping statistics ---\\n5 packets transmitted, 5 received, 0% packet loss, time 81ms\\nrtt min/avg/max/mdev = 0.017/0.030/0.040/0.008 ms', 'stderr': '', 'rc': 0, 'start': '2021-08-27 10:03:03.324193', 'end': '2021-08-27 10:03:07.405223', 'delta': '0:00:04.081030', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'ping -c 5 parasilo-20.rennes.grid5000.fr', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['PING parasilo-20.rennes.grid5000.fr (172.16.97.20) 56(84) bytes of data.', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=1 ttl=64 time=0.040 ms', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=2 ttl=64 time=0.031 ms', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=3 ttl=64 time=0.032 ms', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=4 ttl=64 time=0.017 ms', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=5 ttl=64 time=0.032 ms', '', '--- parasilo-20.rennes.grid5000.fr ping statistics ---', '5 packets transmitted, 5 received, 0% packet loss, time 81ms', 'rtt min/avg/max/mdev = 0.017/0.030/0.040/0.008 ms'], 'stderr_lines': [], '_ansible_no_log': False})\n", "CommandResult(host='parasilo-22.rennes.grid5000.fr', task='ping -c 5 parasilo-20.rennes.grid5000.fr', status='OK', payload={'cmd': 'ping -c 5 parasilo-20.rennes.grid5000.fr', 'stdout': 'PING parasilo-20.rennes.grid5000.fr (172.16.97.20) 56(84) bytes of data.\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=1 ttl=64 time=0.189 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=2 ttl=64 time=0.198 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=3 ttl=64 time=0.198 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=4 ttl=64 time=0.174 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=5 ttl=64 time=0.151 ms\\n\\n--- parasilo-20.rennes.grid5000.fr ping statistics ---\\n5 packets transmitted, 5 received, 0% packet loss, time 108ms\\nrtt min/avg/max/mdev = 0.151/0.182/0.198/0.017 ms', 'stderr': '', 'rc': 0, 'start': '2021-08-27 10:03:03.368123', 'end': '2021-08-27 10:03:07.477422', 'delta': '0:00:04.109299', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'ping -c 5 parasilo-20.rennes.grid5000.fr', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['PING parasilo-20.rennes.grid5000.fr (172.16.97.20) 56(84) bytes of data.', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=1 ttl=64 time=0.189 ms', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=2 ttl=64 time=0.198 ms', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=3 ttl=64 time=0.198 ms', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=4 ttl=64 time=0.174 ms', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=5 ttl=64 time=0.151 ms', '', '--- parasilo-20.rennes.grid5000.fr ping statistics ---', '5 packets transmitted, 5 received, 0% packet loss, time 108ms', 'rtt min/avg/max/mdev = 0.151/0.182/0.198/0.017 ms'], 'stderr_lines': [], '_ansible_no_log': False})" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "host_to_ping = roles[\"control\"][0].alias\n", "host_to_ping\n", "\n", "results = en.run_command(\"ping -c 5 {{ my_template_variable }}\", roles=roles, extra_vars=dict(my_template_variable=host_to_ping))\n", "results" ] }, { "cell_type": "markdown", "id": "psychological-burns", "metadata": {}, "source": [ "### Host specific variables\n", "\n", "In the above, we've seen how a common value can be broadcasted to all remote nodes. What if we want host specific value ?\n", "\n", "For instance in our case we'd like `host 1` to ping `host 2` and `host 2` to ping `host 1`. That make the `host_to_ping` variable host-specific.\n", "\n", "For this purpose you can use the `extra` attribute of the `Host` objects and use a template as before." ] }, { "cell_type": "code", "execution_count": 33, "id": "irish-syria", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " <style> .enoslib {\n", " width: auto;\n", "}\n", "\n", ".enoslib_object {\n", " width: auto;\n", " font-size: 1em;\n", " line-height: 1.5;\n", " background-color: rgb(250, 249, 249);\n", " font-family: 'Segoe UI';\n", " color: black;\n", "}\n", "\n", ".enoslib_object ul {\n", " padding: 0;\n", "}\n", "\n", ".enoslib_object input+label {\n", " margin-bottom: 0%;\n", "}\n", "\n", ".object_name {\n", " padding: 6px 0 6px 3px;\n", " border-bottom-width: 1px;\n", " border-bottom-style: solid;\n", " border-bottom-color: #777;\n", " color: #555;\n", "}\n", "\n", ".object_name>div,\n", ".object_name>ul {\n", " display: inline;\n", " margin-top: 0;\n", " margin-bottom: 0;\n", "}\n", "\n", "ul {\n", " list-style: none !important;\n", " padding: 3px !important;\n", " margin: 0 !important;\n", "}\n", "\n", "input.att+label {\n", " display: inline-block;\n", " /*width: 140px;*/\n", " color: rgb(36, 35, 35);\n", " font-weight: 500;\n", " padding: 4px 0 2px 0;\n", "}\n", "\n", "input.att:enabled+label {\n", " cursor: pointer;\n", " width: auto;\n", "}\n", "\n", "input.att {\n", " display: none;\n", "}\n", "\n", "input.att+label:before {\n", " display: inline-block;\n", " content: '►';\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", "}\n", "\n", "input.att:checked+label:before {\n", " content: '▼';\n", "}\n", "\n", "input.att:disabled+label:before {\n", " content: none;\n", "}\n", "\n", "input.att+label>span {\n", " display: inline-block;\n", " margin-left: 4px;\n", "}\n", "\n", "input.att+label>span.len {\n", " font-size: small;\n", "}\n", "\n", "input.att:checked+label>span.len {\n", " display: none;\n", "}\n", "\n", "label+span {\n", " color: rgb(70, 69, 69);\n", "}\n", "\n", "input.att~ul {\n", " display: none;\n", "}\n", "\n", "input.att:checked~ul {\n", " display: block;\n", "}\n", "\n", "table {\n", " width: auto;\n", " border-collapse: collapse;\n", " margin: 2%;\n", "}\n", "\n", "td,\n", "th {\n", " padding: 8px;\n", " height: 15px;\n", " font-size: small;\n", "}\n", "\n", "td {\n", " text-align: left !important;\n", " color: rgb(160, 160, 160)\n", "}\n", "\n", "th {\n", " text-align: center;\n", " color: black;\n", "}\n", "\n", "input~ul {\n", " position: relative;\n", " left: 25px;\n", "}\n", "\n", "input.att~table {\n", " display: none;\n", "}\n", "\n", "input.att:checked~table {\n", " display: block;\n", "} </style>\n", " <div class=\"enoslib\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.objects.Host'>@0x7fce1be98990\n", " </div>\n", " <ul class=\"list\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"address-c1e1304c-6522-4301-9e19-dc0e8b1a8453\" class=\"att\" disabled=\"\">\n", " <label for=\"address-c1e1304c-6522-4301-9e19-dc0e8b1a8453\">\n", " <span>address</span>\n", " </label>\n", " <span>parasilo-20.rennes.grid5000.fr</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"alias-55722757-7211-4d2c-b912-0fa84d92e78a\" class=\"att\" disabled=\"\">\n", " <label for=\"alias-55722757-7211-4d2c-b912-0fa84d92e78a\">\n", " <span>alias</span>\n", " </label>\n", " <span>parasilo-20.rennes.grid5000.fr</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"user-3328eded-5cc3-433a-b581-263018012f10\" class=\"att\" disabled=\"\">\n", " <label for=\"user-3328eded-5cc3-433a-b581-263018012f10\">\n", " <span>user</span>\n", " </label>\n", " <span>root</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"keyfile-9627e002-7922-4d75-ab46-fe35015051db\" class=\"att\" disabled=\"\">\n", " <label for=\"keyfile-9627e002-7922-4d75-ab46-fe35015051db\">\n", " <span>keyfile</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"port-654d0940-bbe8-421f-9162-24cc4b1f09fb\" class=\"att\" disabled=\"\">\n", " <label for=\"port-654d0940-bbe8-421f-9162-24cc4b1f09fb\">\n", " <span>port</span>\n", " </label>\n", " <span>None</span>\n", " </li>\n", " <li>\n", " <input type=\"checkbox\" id=\"extra-29843d84-6b4c-48ee-99f5-a778e6da94e2\" class=\"att\">\n", " <label for=\"extra-29843d84-6b4c-48ee-99f5-a778e6da94e2\">extra <span class=\"len\">(1)</span></label>\n", " <ul id=\"extra\">\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"host_to_ping-15b7df2a-4a94-4dce-afbc-c79b7ef8f10e\" class=\"att\" disabled=\"\">\n", " <label for=\"host_to_ping-15b7df2a-4a94-4dce-afbc-c79b7ef8f10e\">\n", " <span>host_to_ping</span>\n", " </label>\n", " <span>parasilo-22.rennes.grid5000.fr</span>\n", " </li>\n", " </ul>\n", " </li>\n", " \n", " <li>\n", " <input type=\"checkbox\" id=\"net_devices-a7c024b8-558b-4109-af40-b1f238905f7b\" class=\"att\">\n", " <label for=\"net_devices-a7c024b8-558b-4109-af40-b1f238905f7b\">net_devices <span class=\"len\">(0)</span></label>\n", " <ul id=\"net_devices\">\n", " \n", " </ul>\n", " </li>\n", " \n", " </ul>\n", " </div>\n", " </div>\n", " " ], "text/plain": [ "Host(address='parasilo-20.rennes.grid5000.fr', alias='parasilo-20.rennes.grid5000.fr', user='root', keyfile=None, port=None, extra={'host_to_ping': 'parasilo-22.rennes.grid5000.fr'}, net_devices=set())" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "control_host = roles[\"control\"][0]\n", "compute_host = roles[\"compute\"][0]\n", "control_host.extra.update(host_to_ping=compute_host.address)\n", "compute_host.extra.update(host_to_ping=control_host.address)\n", "control_host" ] }, { "cell_type": "markdown", "id": "cooperative-market", "metadata": {}, "source": [ "> Note that the `extra` attribute is mutable :(" ] }, { "cell_type": "code", "execution_count": 31, "id": "joined-stand", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "PLAY [all] ***********************************************************************************************************************************************************************************\n", "\n", "TASK [ping -c 5 parasilo-22.rennes.grid5000.fr] **********************************************************************************************************************************************\n", " [started TASK: ping -c 5 {{ host_to_ping }} on parasilo-20.rennes.grid5000.fr]\n", " [started TASK: ping -c 5 {{ host_to_ping }} on parasilo-22.rennes.grid5000.fr]\n", "changed: [parasilo-22.rennes.grid5000.fr]\n", "changed: [parasilo-20.rennes.grid5000.fr]\n" ] }, { "data": { "text/html": [ "\n", " <style> .enoslib {\n", " width: auto;\n", "}\n", "\n", ".enoslib_object {\n", " width: auto;\n", " font-size: 1em;\n", " line-height: 1.5;\n", " background-color: rgb(250, 249, 249);\n", " font-family: 'Segoe UI';\n", " color: black;\n", "}\n", "\n", ".enoslib_object ul {\n", " padding: 0;\n", "}\n", "\n", ".enoslib_object input+label {\n", " margin-bottom: 0%;\n", "}\n", "\n", ".object_name {\n", " padding: 6px 0 6px 3px;\n", " border-bottom-width: 1px;\n", " border-bottom-style: solid;\n", " border-bottom-color: #777;\n", " color: #555;\n", "}\n", "\n", ".object_name>div,\n", ".object_name>ul {\n", " display: inline;\n", " margin-top: 0;\n", " margin-bottom: 0;\n", "}\n", "\n", "ul {\n", " list-style: none !important;\n", " padding: 3px !important;\n", " margin: 0 !important;\n", "}\n", "\n", "input.att+label {\n", " display: inline-block;\n", " /*width: 140px;*/\n", " color: rgb(36, 35, 35);\n", " font-weight: 500;\n", " padding: 4px 0 2px 0;\n", "}\n", "\n", "input.att:enabled+label {\n", " cursor: pointer;\n", " width: auto;\n", "}\n", "\n", "input.att {\n", " display: none;\n", "}\n", "\n", "input.att+label:before {\n", " display: inline-block;\n", " content: '►';\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", "}\n", "\n", "input.att:checked+label:before {\n", " content: '▼';\n", "}\n", "\n", "input.att:disabled+label:before {\n", " content: none;\n", "}\n", "\n", "input.att+label>span {\n", " display: inline-block;\n", " margin-left: 4px;\n", "}\n", "\n", "input.att+label>span.len {\n", " font-size: small;\n", "}\n", "\n", "input.att:checked+label>span.len {\n", " display: none;\n", "}\n", "\n", "label+span {\n", " color: rgb(70, 69, 69);\n", "}\n", "\n", "input.att~ul {\n", " display: none;\n", "}\n", "\n", "input.att:checked~ul {\n", " display: block;\n", "}\n", "\n", "table {\n", " width: auto;\n", " border-collapse: collapse;\n", " margin: 2%;\n", "}\n", "\n", "td,\n", "th {\n", " padding: 8px;\n", " height: 15px;\n", " font-size: small;\n", "}\n", "\n", "td {\n", " text-align: left !important;\n", " color: rgb(160, 160, 160)\n", "}\n", "\n", "th {\n", " text-align: center;\n", " color: black;\n", "}\n", "\n", "input~ul {\n", " position: relative;\n", " left: 25px;\n", "}\n", "\n", "input.att~table {\n", " display: none;\n", "}\n", "\n", "input.att:checked~table {\n", " display: block;\n", "} </style>\n", " <div class=\"enoslib\">\n", " <div class=\"enoslib_object\">\n", " <div class=\"object_name\">\n", " <class 'enoslib.api.Results'>\n", " </div>\n", " <ul class=\"list\">\n", " <table><thead><tr><th>host</th><th>task</th><th>status</th><th>payload</th></tr></thead><tbody><tr><td>parasilo-22.rennes.grid5000.fr</td><td>ping -c 5 parasilo-20.rennes.grid5000.fr</td><td>OK</td><td><table><tr><th>stdout</th><td>PING parasilo-20.rennes.grid5000.fr (172.16.97.20)[...]</td></tr><tr><th>stderr</th><td></td></tr><tr><th>rc</th><td>0</td></tr></table></td></tr><tr><td>parasilo-20.rennes.grid5000.fr</td><td>ping -c 5 parasilo-22.rennes.grid5000.fr</td><td>OK</td><td><table><tr><th>stdout</th><td>PING parasilo-22.rennes.grid5000.fr (172.16.97.22)[...]</td></tr><tr><th>stderr</th><td></td></tr><tr><th>rc</th><td>0</td></tr></table></td></tr></tbody></table>\n", " </ul>\n", " </div>\n", " </div>\n", " " ], "text/plain": [ "CommandResult(host='parasilo-22.rennes.grid5000.fr', task='ping -c 5 parasilo-20.rennes.grid5000.fr', status='OK', payload={'cmd': 'ping -c 5 parasilo-20.rennes.grid5000.fr', 'stdout': 'PING parasilo-20.rennes.grid5000.fr (172.16.97.20) 56(84) bytes of data.\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=1 ttl=64 time=0.141 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=2 ttl=64 time=0.139 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=3 ttl=64 time=0.120 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=4 ttl=64 time=0.138 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=5 ttl=64 time=0.177 ms\\n\\n--- parasilo-20.rennes.grid5000.fr ping statistics ---\\n5 packets transmitted, 5 received, 0% packet loss, time 104ms\\nrtt min/avg/max/mdev = 0.120/0.143/0.177/0.018 ms', 'stderr': '', 'rc': 0, 'start': '2021-08-27 10:03:07.884501', 'end': '2021-08-27 10:03:11.989088', 'delta': '0:00:04.104587', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'ping -c 5 parasilo-20.rennes.grid5000.fr', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['PING parasilo-20.rennes.grid5000.fr (172.16.97.20) 56(84) bytes of data.', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=1 ttl=64 time=0.141 ms', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=2 ttl=64 time=0.139 ms', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=3 ttl=64 time=0.120 ms', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=4 ttl=64 time=0.138 ms', '64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=5 ttl=64 time=0.177 ms', '', '--- parasilo-20.rennes.grid5000.fr ping statistics ---', '5 packets transmitted, 5 received, 0% packet loss, time 104ms', 'rtt min/avg/max/mdev = 0.120/0.143/0.177/0.018 ms'], 'stderr_lines': [], '_ansible_no_log': False})\n", "CommandResult(host='parasilo-20.rennes.grid5000.fr', task='ping -c 5 parasilo-22.rennes.grid5000.fr', status='OK', payload={'cmd': 'ping -c 5 parasilo-22.rennes.grid5000.fr', 'stdout': 'PING parasilo-22.rennes.grid5000.fr (172.16.97.22) 56(84) bytes of data.\\n64 bytes from parasilo-22.rennes.grid5000.fr (172.16.97.22): icmp_seq=1 ttl=64 time=0.119 ms\\n64 bytes from parasilo-22.rennes.grid5000.fr (172.16.97.22): icmp_seq=2 ttl=64 time=0.183 ms\\n64 bytes from parasilo-22.rennes.grid5000.fr (172.16.97.22): icmp_seq=3 ttl=64 time=0.171 ms\\n64 bytes from parasilo-22.rennes.grid5000.fr (172.16.97.22): icmp_seq=4 ttl=64 time=0.061 ms\\n64 bytes from parasilo-22.rennes.grid5000.fr (172.16.97.22): icmp_seq=5 ttl=64 time=0.091 ms\\n\\n--- parasilo-22.rennes.grid5000.fr ping statistics ---\\n5 packets transmitted, 5 received, 0% packet loss, time 108ms\\nrtt min/avg/max/mdev = 0.061/0.125/0.183/0.046 ms', 'stderr': '', 'rc': 0, 'start': '2021-08-27 10:03:07.872591', 'end': '2021-08-27 10:03:11.981287', 'delta': '0:00:04.108696', 'changed': True, 'invocation': {'module_args': {'_raw_params': 'ping -c 5 parasilo-22.rennes.grid5000.fr', '_uses_shell': True, 'warn': True, 'stdin_add_newline': True, 'strip_empty_ends': True, 'argv': None, 'chdir': None, 'executable': None, 'creates': None, 'removes': None, 'stdin': None}}, 'stdout_lines': ['PING parasilo-22.rennes.grid5000.fr (172.16.97.22) 56(84) bytes of data.', '64 bytes from parasilo-22.rennes.grid5000.fr (172.16.97.22): icmp_seq=1 ttl=64 time=0.119 ms', '64 bytes from parasilo-22.rennes.grid5000.fr (172.16.97.22): icmp_seq=2 ttl=64 time=0.183 ms', '64 bytes from parasilo-22.rennes.grid5000.fr (172.16.97.22): icmp_seq=3 ttl=64 time=0.171 ms', '64 bytes from parasilo-22.rennes.grid5000.fr (172.16.97.22): icmp_seq=4 ttl=64 time=0.061 ms', '64 bytes from parasilo-22.rennes.grid5000.fr (172.16.97.22): icmp_seq=5 ttl=64 time=0.091 ms', '', '--- parasilo-22.rennes.grid5000.fr ping statistics ---', '5 packets transmitted, 5 received, 0% packet loss, time 108ms', 'rtt min/avg/max/mdev = 0.061/0.125/0.183/0.046 ms'], 'stderr_lines': [], '_ansible_no_log': False})" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "results = en.run_command(\"ping -c 5 {{ host_to_ping }}\", roles=roles)\n", "results" ] }, { "cell_type": "code", "execution_count": 32, "id": "nervous-difference", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[('parasilo-22.rennes.grid5000.fr',\n", " 'PING parasilo-20.rennes.grid5000.fr (172.16.97.20) 56(84) bytes of data.\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=1 ttl=64 time=0.141 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=2 ttl=64 time=0.139 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=3 ttl=64 time=0.120 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=4 ttl=64 time=0.138 ms\\n64 bytes from parasilo-20.rennes.grid5000.fr (172.16.97.20): icmp_seq=5 ttl=64 time=0.177 ms\\n\\n--- parasilo-20.rennes.grid5000.fr ping statistics ---\\n5 packets transmitted, 5 received, 0% packet loss, time 104ms\\nrtt min/avg/max/mdev = 0.120/0.143/0.177/0.018 ms'),\n", " ('parasilo-20.rennes.grid5000.fr',\n", " 'PING parasilo-22.rennes.grid5000.fr (172.16.97.22) 56(84) bytes of data.\\n64 bytes from parasilo-22.rennes.grid5000.fr (172.16.97.22): icmp_seq=1 ttl=64 time=0.119 ms\\n64 bytes from parasilo-22.rennes.grid5000.fr (172.16.97.22): icmp_seq=2 ttl=64 time=0.183 ms\\n64 bytes from parasilo-22.rennes.grid5000.fr (172.16.97.22): icmp_seq=3 ttl=64 time=0.171 ms\\n64 bytes from parasilo-22.rennes.grid5000.fr (172.16.97.22): icmp_seq=4 ttl=64 time=0.061 ms\\n64 bytes from parasilo-22.rennes.grid5000.fr (172.16.97.22): icmp_seq=5 ttl=64 time=0.091 ms\\n\\n--- parasilo-22.rennes.grid5000.fr ping statistics ---\\n5 packets transmitted, 5 received, 0% packet loss, time 108ms\\nrtt min/avg/max/mdev = 0.061/0.125/0.183/0.046 ms')]" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "[(r.host, r.stdout) for r in results]" ] }, { "cell_type": "markdown", "id": "practical-arnold", "metadata": { "tags": [] }, "source": [ "## Cleaning" ] }, { "cell_type": "code", "execution_count": 34, "id": "decent-syracuse", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading rsd-01 from lille\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading rsd-01 from luxembourg\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading rsd-01 from lyon\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading rsd-01 from nancy\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading rsd-01 from nantes\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading rsd-01 from rennes\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading 1816344 from rennes\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Reloading rsd-01 from sophia\n", "INFO:enoslib.infra.enos_g5k.g5k_api_utils:Killing the job (rennes, 1816344)\n" ] } ], "source": [ "provider.destroy()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.6.5 64-bit ('enoslib': pyenv)", "language": "python", "name": "python36564bitenoslibpyenv42af5fcd7f544e0ea2701891938e2c86" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.9" }, "toc-autonumbering": false, "toc-showcode": false, "toc-showmarkdowntxt": false }, "nbformat": 4, "nbformat_minor": 5 }