{ "info": { "author": "Andrei Pozolotin", "author_email": "andrei.pozolotin@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: Information Technology", "Intended Audience :: System Administrators", "License :: OSI Approved :: Apache Software License", "Operating System :: POSIX :: Linux", "Programming Language :: Python", "Programming Language :: Python :: 3.7", "Topic :: System :: Systems Administration", "Topic :: Terminals", "Topic :: Utilities" ], "description": "## nspawn\n\n[![Travis Status][travis_icon]][travis_link]\n[![Appvey Status][appvey_icon]][appvey_link]\n[![Package Version][pypi_icon]][pypi_link]\n[![Python Versions][python_icon]][python_link]\n\nContainers with [`systemd-nspawn`](https://www.freedesktop.org/software/systemd/man/systemd-nspawn.html)\n\nFeatures:\n* differential image [overlays](https://en.wikipedia.org/wiki/OverlayFS)\n* supports multiple inheritance for images\n* provides [dsl](https://en.wikipedia.org/wiki/Domain-specific_language)\n for image `build` and machine `setup`\n* machine is\n [completely represented](https://github.com/random-python/nspawn/tree/master/src/main/nspawn/template)\n by generated\n [machine.service unit file](https://www.freedesktop.org/software/systemd/man/systemd.unit.html)\n\n### Install\n\nTo install python package:\n\n```\nsudo pip install nspawn\n```\n\n### Build Script\n\nTo build an image, provide and invoke executable `build.py` script, for example:\n* alpine: https://github.com/random-python/nspawn/blob/master/demo/alpine/base/build.py\n* archux: https://github.com/random-python/nspawn/blob/master/demo/archux/base/build.py\n* ubuntu: https://github.com/random-python/nspawn/blob/master/demo/ubuntu/base/build.py\n\nFor available build options run `./build.py --help`\n\n### Setup Script\n\nTo setup a machine, provide and invoke executable `setup.py` script, for example:\n* alpine: https://github.com/random-python/nspawn/blob/master/demo/alpine/base/setup.py\n* archux: https://github.com/random-python/nspawn/blob/master/demo/archux/base/setup.py\n* ubuntu: https://github.com/random-python/nspawn/blob/master/demo/ubuntu/base/setup.py\n\nFor available setup options run `./setup.py --help`\n\n### Machine Service\n\nTo review provisioned, generated and running machine service, run:\n```\nmachinectl\nsystemctl status \ncat /etc/systemd/system/.service\n```\nfor example, demo generated services:\n* alpine: https://github.com/random-python/nspawn/blob/master/demo/alpine-base.service\n* archux: https://github.com/random-python/nspawn/blob/master/demo/archux-base.service\n* ubuntu: https://github.com/random-python/nspawn/blob/master/demo/ubuntu-base.service\n\n### Machine Resources\n\nLocation of machine files and folders:\n```\n/etc/systemd/system/.service\n/var/lib/machines/\n/var/lib/nspawn/runtime/\n```\n\n### Machine Management\n\nTo interact with live machine:\n* for machines registered with `machinectl`\n* for machines with `systemd` `init`, such as `archlinux`\n```\n# start interactive shell:\nsudo machinectl shell \n```\n```\n# invoke command with args:\nsudo machinectl shell /bin/command arg1 arg2 ... \n```\n* for machines not registered with `machinectl`\n* for machines without `systemd` `init`, such as `alpine linux`\n```\n# start interactive shell:\n./setup.py --action=nsenter \n```\n* alternatively, use package-provided `nspawn-enter` command:\n```\n# start interactive shell:\nnspawn-enter \n```\n```\n# invoke command with args:\nnspawn-enter \"command arg1 arg2 ...\" \n```\n\n### Configuration\n\nAvailable configuration options are described in\n[config.ini](https://github.com/random-python/nspawn/blob/master/src/main/nspawn/config.ini) \nfile.\n\nUse `config/path_list` option to control configuration override file list.\n\n### Image Server\n\nPackage comes with provisioning command `nspawn-hatch`\nwhich can build and setup local http/https image server.\n```\n# review available services:\nnspawn-hatch list\n```\n```\n# provision image server service:\nnspawn-hatch update image-server\n```\n```\n# verify image server machine status:\nmachinectl\n```\n\nImage server settings:\n* https://github.com/random-python/nspawn/tree/master/src/main/nspawn/app/hatcher/service/image-server\n\n### Build DSL\n\nBuild DSL is used in `build.py`, is activated by `from nspawn.build import *` and provides keywords:\n```\n 'TOOL',\n 'IMAGE',\n 'PULL',\n 'EXEC',\n 'WITH',\n 'FETCH',\n 'COPY',\n 'CAST',\n 'RUN',\n 'SH',\n 'PUSH',\n```\n\n### Setup DSL\n\nSetup DSL is used in `setup.py`, is activated by `from nspawn.setup import *` and provides keywords:\n```\n 'TOOL',\n 'IMAGE',\n 'MACHINE',\n 'WITH',\n 'EXEC',\n 'COPY',\n 'CAST',\n 'RUN',\n 'SH',\n```\n\n### DSL Syntax\n\n#### `TOOL`\n\nExpose build/setup utility functions:\n* https://github.com/random-python/nspawn/tree/master/src/main/nspawn/tool\n```\nTOOL.(...)\n```\n\n#### `IMAGE()`\n\nDeclare image identity:\n```\nIMAGE(\"http://host/path/package.tar.gz\")\nIMAGE(url=\"http://host/path/package.tar.gz\")\n```\n\n#### `PULL()`\n\nProvision dependency image:\n```\nPULL(\"http://host/path/package.tar.gz\")\nPULL(url=\"http://host/path/package.tar.gz\")\n```\n\n#### `EXEC()`\n\nDeclare image entry point executable i.e. `COMMAND [ARGS...]`:\n* https://www.freedesktop.org/software/systemd/man/systemd-nspawn.html\n```\nEXEC(['/usr/bin/env', 'sh', '-c', 'echo \"hello-kitty\"'])\nEXEC(command=['/usr/bin/env', 'sh', '-c', 'echo \"hello-kitty\"'])\n```\n\n#### `WITH()`\n\nCustomize machine features using nspawn container settings:\n* https://www.freedesktop.org/software/systemd/man/systemd.nspawn.html\n```\nWITH(\n SettingName1='setting 1 value a',\n SettingName2='setting 2 value b',\n ...,\n)\n```\n\n#### `COPY()`\n\nCopy local resources:\n* when used in `build.py`: target is in the image\n* when used in `setup.py`: target is on the host\n```\nCOPY(\"/etc\")\nCOPY(path=\"/etc\")\nCOPY(source=\"/root/input.md\", target=\"/root/output.md\")\n```\n\n#### `CAST()`\n\nTemplate local resources:\n* when used in `build.py`: target is in the image\n* when used in `setup.py`: target is on the host\n```\nCAST(\"/root/readme.md\", variable=\"template varialbe\", ...)\nCAST(path=\"/root/readme.md\", variable=\"template varialbe\", ...)\nCAST(source=\"/root/input.md\", target=\"/root/output.md\", variable=\"template varialbe\", ...)\n```\n\nTemplate uses [python/jinja](https://jinja.palletsprojects.com/en/2.10.x/)\nformat, i.e:\n```\nthis template variable will be substituted: {{variable}}\n```\n\n#### `FETCH()`\n\nDownload and extract remote resource:\n```\nFETCH( # use when source and target are the same\n url=\"http://server/package.tar.gz\", # url for remote resource\n path=\"/common-path\", # path inside the package source and image target\n)\nFETCH( # use when source and target are different\n url=\"http://server/package.tar.gz\", # url for remote resource\n source=\"/package-path\", # path inside the package extract\n target=\"/opt/resource\", # path inside the build image target\n)\n```\n\n#### `RUN()`\n\nInvoke command, with target depending on the context:\n* when used in `build.py`: invoke inside the image\n* when used in `setup.py`: invoke on the host\n```\nRUN(['/usr/bin/env', 'ls', '-las'])\nRUN(command=['/usr/bin/env', 'ls', '-las'])\n```\n\n#### `SH()`\n\nInvoke shell script, with target depending on the context:\n* when used in `build.py`: invoke inside the image\n* when used in `setup.py`: invoke on the host\n```\nSH(\"ls -las\")\nSH(script=\"ls -las\")\n```\nNote:\n* `SH(script)` is equivalent to `RUN(command=['/usr/bin/env', 'sh', '-c', script])`\n\n#### `PUSH()`\n\nPublish image result to the declared url:\n```\nPUSH()\n```\n\n#### `MACHINE()`\n\nDeclare machine service:\n```\nMACHINE('machine-name')\nMACHINE(name='machine-name')\nMACHINE(name='machine-name', template='/path/to/service/template/machine.service')\n```\n\nDesign custom service templates based on package-provided defaults, for example:\n* https://github.com/random-python/nspawn/tree/master/src/main/nspawn/template\n\n[travis_icon]: https://travis-ci.org/random-python/nspawn.svg?branch=master\n[travis_link]: https://travis-ci.org/random-python/nspawn/builds\n\n[appvey_icon]: https://ci.appveyor.com/api/projects/status/fbjgg6ana9kkww6p?svg=true\n[appvey_link]: https://ci.appveyor.com/project/Andrei-Pozolotin/nspawn/history \n\n[pypi_icon]: https://badge.fury.io/py/nspawn.svg\n[pypi_link]: https://pypi.python.org/pypi/nspawn\n\n[python_icon]: https://img.shields.io/pypi/pyversions/nspawn.svg\n[python_link]: https://pypi.python.org/pypi/nspawn\n\n[tokei_icon]: https://tokei.rs/b1/github/random-python/nspawn\n[tokei_link]: https://github.com/random-python/nspawn/tree/master/src", "description_content_type": "text/markdown; charset=UTF-8", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/random-python/nspawn", "keywords": "nspawn,systemd,systemd-nspawn", "license": "Apache-2", "maintainer": "", "maintainer_email": "", "name": "nspawn", "package_url": "https://pypi.org/project/nspawn/", "platform": "", "project_url": "https://pypi.org/project/nspawn/", "project_urls": { "Homepage": "https://github.com/random-python/nspawn" }, "release_url": "https://pypi.org/project/nspawn/0.5.7.dev1/", "requires_dist": null, "requires_python": "", "summary": "Containers with systemd-nspawn", "version": "0.5.7.dev1" }, "last_serial": 5829395, "releases": { "0.5.7.dev1": [ { "comment_text": "", "digests": { "md5": "1c9083d3908178a9c6e416cc4c8326b8", "sha256": "d34ee3542c0353e6ac55bd1541adf8ecbba961460262c167ebf8895ac39db76c" }, "downloads": -1, "filename": "nspawn-0.5.7.dev1.zip", "has_sig": false, "md5_digest": "1c9083d3908178a9c6e416cc4c8326b8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 213818, "upload_time": "2019-09-14T14:28:46", "url": "https://files.pythonhosted.org/packages/36/3e/69f881335d06ee116cbff39c8f1efffd6c639280e7a11cbb8767053e8c69/nspawn-0.5.7.dev1.zip" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1c9083d3908178a9c6e416cc4c8326b8", "sha256": "d34ee3542c0353e6ac55bd1541adf8ecbba961460262c167ebf8895ac39db76c" }, "downloads": -1, "filename": "nspawn-0.5.7.dev1.zip", "has_sig": false, "md5_digest": "1c9083d3908178a9c6e416cc4c8326b8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 213818, "upload_time": "2019-09-14T14:28:46", "url": "https://files.pythonhosted.org/packages/36/3e/69f881335d06ee116cbff39c8f1efffd6c639280e7a11cbb8767053e8c69/nspawn-0.5.7.dev1.zip" } ] }