{ "info": { "author": "Pit Rho Corporation", "author_email": "", "bugtrack_url": null, "classifiers": [ "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: System Administrators", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6" ], "description": "```\n8888888b. 888 .d8888b. \n888 Y88b 888 d88P Y88b \n888 888 888 888 888 \n888 d88P 8888b. 88888b. .d8888b 88888b. .d88b. 888d888 888 .d88b. 88888b. \n8888888P\" \"88b 888 \"88b d88P\" 888 \"88b d8P Y8b 888P\" 888 88888 d8P Y8b 888 \"88b\n888 T88b .d888888 888 888 888 888 888 88888888 888 888888 888 888 88888888 888 888\n888 T88b 888 888 888 888 Y88b. 888 888 Y8b. 888 Y88b d88P Y8b. 888 888\n888 T88b \"Y888888 888 888 \"Y8888P 888 888 \"Y8888 888 \"Y8888P88 \"Y8888 888 888\n```\n\nFile generator that renders templates using Rancher API. Inspired by\n[docker-gen](https://github.com/jwilder/docker-gen).\n\nThis program listens for changes on Rancher services and renders a\n[Jinja2](http://jinja.pocoo.org/docs/dev/) template. It also has the ability\nno run a notification command after the template has been rendered. This could\nbe useful for generating configuration files for services like Nginx.\n\n## Installation\n\n pip install rancher-gen\n\n\n## How to use rancher-gen\n\n```\nusage: rancher-gen [--host HOST] [--port PORT] [--access-key ACCESS_KEY]\n [--secret-key SECRET_KEY] [--project-id PROJECT_ID] [-h]\n [--log-level {DEBUG,INFO,WARNING,CRITICAL,ERROR}]\n [--stack STACK] [--service SERVICE] [--ssl]\n [--notify NOTIFY]\n template dest\n\nGenerate files from rancher meta-data\n\npositional arguments:\n template Path to template to generate\n dest Output path for generated file\n\nnamed arguments:\n --host HOST Rancher host (defaults to localhost)\n --port PORT Rancher port (defaults to 80 or 443 if ssl is\n specified)\n --access-key ACCESS_KEY\n The Rancher access key\n --secret-key SECRET_KEY\n The Rancher secret key\n --project-id PROJECT_ID\n Rancher's project id\n\noptional arguments:\n -h, --help show this help message and exit\n --log-level {DEBUG,INFO,WARNING,CRITICAL,ERROR}\n Set the log level.\n --stack STACK The name of the rancher stack\n --service SERVICE The name of the rancher service\n --ssl User secure connections (https and wss)\n --notify NOTIFY Command to run after template is generated (e.g\n restart some-service)\n\n```\n\nIn order to run rancher-gen, you must specify at least the following parameters:\n * host: The ip/dns name of the rancher server.\n * port: The port of the rancher server. It defaults to 80 or 443 for SSL.\n * access-key: The access key to access the Rancher server.\n * secret-key: The secret key to access the Rancher server.\n * proejct-id: The project id (environment) from Rancher.\n\n## What's passed to the templates\nA list of container instances is passed to the template when is rendered. So,\nyou can do something like:\n\n {% for container in containers %}\n {{container['primaryIpAddress']}}\n {% endfor %}\n\n### Example of container data that is being passed to the template\n\n```\n{\n \"id\": \"1i258\",\n \"type\": \"container\",\n \"links\": {\n \"self\": \"\u2026/v1/projects/1a5/containers/1i258\",\n \"account\": \"\u2026/v1/projects/1a5/containers/1i258/account\",\n \"credentials\": \"\u2026/v1/projects/1a5/containers/1i258/credentials\",\n \"healthcheckInstanceHostMaps\": \"\u2026/v1/projects/1a5/containers/1i258/healthcheckinstancehostmaps\",\n \"hosts\": \"\u2026/v1/projects/1a5/containers/1i258/hosts\",\n \"instanceLabels\": \"\u2026/v1/projects/1a5/containers/1i258/instancelabels\",\n \"instanceLinks\": \"\u2026/v1/projects/1a5/containers/1i258/instancelinks\",\n \"instances\": \"\u2026/v1/projects/1a5/containers/1i258/instances\",\n \"mounts\": \"\u2026/v1/projects/1a5/containers/1i258/mounts\",\n \"ports\": \"\u2026/v1/projects/1a5/containers/1i258/ports\",\n \"serviceEvents\": \"\u2026/v1/projects/1a5/containers/1i258/serviceevents\",\n \"serviceExposeMaps\": \"\u2026/v1/projects/1a5/containers/1i258/serviceexposemaps\",\n \"services\": \"\u2026/v1/projects/1a5/containers/1i258/services\",\n \"targetInstanceLinks\": \"\u2026/v1/projects/1a5/containers/1i258/targetinstancelinks\",\n \"volumes\": \"\u2026/v1/projects/1a5/containers/1i258/volumes\",\n \"stats\": \"\u2026/v1/projects/1a5/containers/1i258/stats\",\n \"containerStats\": \"\u2026/v1/projects/1a5/containers/1i258/containerstats\",\n },\n \"actions\": {\n \"update\": \"\u2026/v1/projects/1a5/containers/1i258/?action=update\",\n \"stop\": \"\u2026/v1/projects/1a5/containers/1i258/?action=stop\",\n \"restart\": \"\u2026/v1/projects/1a5/containers/1i258/?action=restart\",\n \"migrate\": \"\u2026/v1/projects/1a5/containers/1i258/?action=migrate\",\n \"logs\": \"\u2026/v1/projects/1a5/containers/1i258/?action=logs\",\n \"setlabels\": \"\u2026/v1/projects/1a5/containers/1i258/?action=setlabels\",\n \"execute\": \"\u2026/v1/projects/1a5/containers/1i258/?action=execute\",\n \"proxy\": \"\u2026/v1/projects/1a5/containers/1i258/?action=proxy\",\n },\n \"name\": \"foo_nginx2_1\",\n \"state\": \"running\",\n \"accountId\": \"1a5\",\n \"blkioDeviceOptions\": null,\n \"build\": null,\n \"capAdd\": null,\n \"capDrop\": null,\n \"command\": null,\n \"cpuSet\": null,\n \"cpuShares\": null,\n \"createIndex\": 1,\n \"created\": \"2016-09-07T01:37:19Z\",\n \"createdTS\": 1473212239000,\n \"dataVolumeMounts\": {},\n \"dataVolumes\": [\n \"/tmp/nginxconf:/nginxconf\",\n ],\n \"dataVolumesFrom\": null,\n \"deploymentUnitUuid\": \"e4af719b-39ad-4576-8402-8a29a6ec97d6\",\n \"description\": null,\n \"devices\": null,\n \"dns\": [\n \"169.254.169.250\",\n ],\n \"dnsSearch\": [\n 3items\"foo.rancher.internal\",\n \"nginx2.foo.rancher.internal\",\n \"rancher.internal\",\n ],\n \"domainName\": null,\n \"entryPoint\": null,\n \"environment\": {\n \"NGINX_RUN_TYPE\": \"rancher-gen\",\n \"RANCHER_GEN_ACCESS_KEY\": \"37AF1F5CD18843DF00CC\",\n \"RANCHER_GEN_HOST\": \"192.168.0.15\",\n \"RANCHER_GEN_OPTIONS\": \"--port 8080 --stack foo --service hello\",\n \"RANCHER_GEN_PROJECT_ID\": \"1a5\",\n \"RANCHER_GEN_SECRET_KEY\": \"7D7Bio7bcK1vGbj5jNGVCnAEZFrnmZXPjaEZ8Fs2\",\n },\n \"expose\": null,\n \"externalId\": \"f61757f4ede26d6bbbb2ddc31aa8b17dd4227a3bbca12225ddab66e77d76971d\",\n \"extraHosts\": null,\n \"firstRunning\": \"2016-09-07T01:37:20Z\",\n \"firstRunningTS\": 1473212240000,\n \"healthCheck\": null,\n \"healthState\": null,\n \"hostId\": \"1h2\",\n \"hostname\": null,\n \"imageUuid\": \"docker:pitrho/nginx:dev\",\n \"kind\": \"container\",\n \"labels\": {\n \"io.rancher.project.name\": \"foo\",\n \"io.rancher.service.deployment.unit\": \"e4af719b-39ad-4576-8402-8a29a6ec97d6\",\n \"io.rancher.service.launch.config\": \"io.rancher.service.primary.launch.config\",\n \"io.rancher.project_service.name\": \"foo/nginx2\",\n \"io.rancher.stack.name\": \"foo\",\n \"io.rancher.stack_service.name\": \"foo/nginx2\",\n \"io.rancher.service.hash\": \"ddf05372f057253876d50b81c26eb1a350438d49\",\n \"io.rancher.container.uuid\": \"90028a61-6fd5-460a-a8b7-f90bcaf664f2\",\n \"io.rancher.container.name\": \"foo_nginx2_1\",\n \"io.rancher.container.ip\": \"10.42.172.71/16\",\n },\n \"logConfig\": {},\n \"lxcConf\": null,\n \"memory\": null,\n \"memorySwap\": null,\n \"nativeContainer\": false,\n \"networkContainerId\": null,\n \"networkMode\": \"managed\",\n \"pidMode\": null,\n \"ports\": [\n \"80:80/tcp\",\n ],\n \"primaryIpAddress\": \"10.42.172.71\",\n \"privileged\": false,\n \"publishAllPorts\": false,\n \"readOnly\": false,\n \"registryCredentialId\": null,\n \"removed\": null,\n \"requestedHostId\": null,\n \"restartPolicy\": null,\n \"securityOpt\": null,\n \"startCount\": 1,\n \"startOnCreate\": true,\n \"stdinOpen\": false,\n \"systemContainer\": null,\n \"transitioning\": \"no\",\n \"transitioningMessage\": null,\n \"transitioningProgress\": null,\n \"tty\": false,\n \"user\": null,\n \"uuid\": \"90028a61-6fd5-460a-a8b7-f90bcaf664f2\",\n \"version\": \"0\",\n \"volumeDriver\": null,\n \"workingDir\": null,\n}\n```\n\n\n## Examples\n\n### Listening for changes at the project level\n\n rancher-gen --host rancher.mycompany.com --port 8080 --access-key 1234567890 --secret-key 123ABC456DEF789GHI --project-id 1a5 --template /tmp/template.j2:/tmp/output.txt\n\n### Listening for changes at the stack level\n\n rancher-gen --host rancher.mycompany.com --port 8080 --access-key 1234567890 --secret-key 123ABC456DEF789GHI --project-id 1a5 --stack mystack --template /tmp/template.j2:/tmp/output.txt\n\n### Listening for changes at the service level\n\n rancher-gen --host rancher.mycompany.com --port 8080 --access-key 1234567890 --secret-key 123ABC456DEF789GHI --project-id 1a5 --stack mystack --service myservice --template /tmp/template.j2:/tmp/output.txt\n\n### Listening for changes on multiple services under the same stack\n\n rancher-gen --host rancher.mycompany.com --port 8080 --access-key 1234567890 --secret-key 123ABC456DEF789GHI --project-id 1a5 --stack mystack --service myservice1 --service myservice2 --template /tmp/template.j2:/tmp/output.txt\n\n### Using secure connections\n\n rancher-gen --host rancher.mycompany.com --access-key 1234567890 --secret-key 123ABC456DEF789GHI --project-id 1a5 --stack mystack --service myservice --ssl --template /tmp/template.j2:/tmp/output.txt\n\n### Creating nginx config and reloading (notify)\n\n rancher-gen --host rancher.mycompany.com --port 8080 --access-key 1234567890 --secret-key 123ABC456DEF789GHI --project-id 1a5 --stack mystack --service myservice --ssl --notify \"service nginx reload\" --template /tmp/template.j2:/tmp/output.txt\n\n### Rendering multiple templates\n\n rancher-gen --host rancher.mycompany.com --port 8080 --access-key 1234567890 --secret-key 123ABC456DEF789GHI --project-id 1a5 --template /tmp/template1.j2:/tmp/output1.txt --template /tmp/template2.j2:/tmp/output2.txt\n\n## License\nMIT", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/pitrho/rancher-gen", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "rancher-gen", "package_url": "https://pypi.org/project/rancher-gen/", "platform": "", "project_url": "https://pypi.org/project/rancher-gen/", "project_urls": { "Homepage": "https://github.com/pitrho/rancher-gen" }, "release_url": "https://pypi.org/project/rancher-gen/0.4.1/", "requires_dist": null, "requires_python": "", "summary": "File generator that renders templates using Rancher API", "version": "0.4.1" }, "last_serial": 4177302, "releases": { "0.1.2": [ { "comment_text": "", "digests": { "md5": "5e7aee4487daf44dd0f1e4f4afb4d891", "sha256": "c76d7129860d6d6dc64e980a780c9fad4c7da45779e390c50a7a61a0a5b287fa" }, "downloads": -1, "filename": "rancher-gen-0.1.2.tar.gz", "has_sig": false, "md5_digest": "5e7aee4487daf44dd0f1e4f4afb4d891", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12549, "upload_time": "2016-09-09T19:49:29", "url": "https://files.pythonhosted.org/packages/a1/58/fe1ed14291bea2d6cad75cbac0434bbb59afd6469ec4232c2d66ddb1d79c/rancher-gen-0.1.2.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "2f584e564b31c2befe07e8df427650ee", "sha256": "b3da0111512999406d3fe876a952bcfe5b27818d3050d1ffdb98c8b8ed6cf729" }, "downloads": -1, "filename": "rancher-gen-0.2.0.tar.gz", "has_sig": false, "md5_digest": "2f584e564b31c2befe07e8df427650ee", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13447, "upload_time": "2016-10-07T19:04:34", "url": "https://files.pythonhosted.org/packages/4c/71/8d0443293dc1bc8a39ddc2b4da6d14bcb79799452cd2c7a2fc5fda72233a/rancher-gen-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "e2821a5b99b74b37bbc7f8a4e6b91019", "sha256": "3cedacb2b12d1a7726a414956dee26d746b53ee360dc76fe23bc9319b94beac2" }, "downloads": -1, "filename": "rancher-gen-0.2.1.tar.gz", "has_sig": false, "md5_digest": "e2821a5b99b74b37bbc7f8a4e6b91019", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13525, "upload_time": "2016-10-07T19:35:54", "url": "https://files.pythonhosted.org/packages/30/45/979347a019a13c3f8f50acaae21329b1d0bf817fdfb63f5674fc613781c8/rancher-gen-0.2.1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "c08b2079b6689fa035b63248b2d697a9", "sha256": "227f0c7ae3cd747fbc983c83d87584f4181ea25171623dfd14b3f897a79f6bea" }, "downloads": -1, "filename": "rancher-gen-0.3.0.tar.gz", "has_sig": false, "md5_digest": "c08b2079b6689fa035b63248b2d697a9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13720, "upload_time": "2017-01-18T19:52:12", "url": "https://files.pythonhosted.org/packages/84/4e/095528cdb81981d80620d23a02bea47bb30a6c670b9ef18815fe42704955/rancher-gen-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "9942504c933e0378e34d1eb5cab82787", "sha256": "e3952a6eb039af4cf4984268e0473d2bd1a82c601956519c9838eb50679c9e90" }, "downloads": -1, "filename": "rancher-gen-0.4.0.tar.gz", "has_sig": false, "md5_digest": "9942504c933e0378e34d1eb5cab82787", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13951, "upload_time": "2018-08-08T04:29:28", "url": "https://files.pythonhosted.org/packages/6d/9b/ea1e7b60b9761e6e95e2ffad4eb9dcb509b922700508a10ee9348f4e1166/rancher-gen-0.4.0.tar.gz" } ], "0.4.1": [ { "comment_text": "", "digests": { "md5": "b945c067c05377bf5edb9ba3803d0a3f", "sha256": "313492a54331c259ec3076ff42bf87b9e819de50998bbad01338bf3c23c3cbe0" }, "downloads": -1, "filename": "rancher-gen-0.4.1.tar.gz", "has_sig": false, "md5_digest": "b945c067c05377bf5edb9ba3803d0a3f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14102, "upload_time": "2018-08-16T16:42:37", "url": "https://files.pythonhosted.org/packages/cd/39/3162b52cf68f8428489d933853aa379ee9c39599a7b4a8e19e2e2e05b410/rancher-gen-0.4.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "b945c067c05377bf5edb9ba3803d0a3f", "sha256": "313492a54331c259ec3076ff42bf87b9e819de50998bbad01338bf3c23c3cbe0" }, "downloads": -1, "filename": "rancher-gen-0.4.1.tar.gz", "has_sig": false, "md5_digest": "b945c067c05377bf5edb9ba3803d0a3f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14102, "upload_time": "2018-08-16T16:42:37", "url": "https://files.pythonhosted.org/packages/cd/39/3162b52cf68f8428489d933853aa379ee9c39599a7b4a8e19e2e2e05b410/rancher-gen-0.4.1.tar.gz" } ] }