{ "info": { "author": "Behzad Dastur", "author_email": "bdastur@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "pyAnsible\n=========\n[![PyPI Version](https://img.shields.io/pypi/v/pyansible.svg)](https://pypi.python.org/pypi/pyansible)\n\nA python module that interfaces with Ansible Runner and Inventory. Provides an API interface\nto directly invoke ansible module from python API.\n\n--------\n\n+ [Introduction] (https://github.com/bdastur/spam/blob/master/README.md#introduction)\n+ [Installation] (https://github.com/bdastur/spam/blob/master/README.md#installation)\n+ [Sample Usage] (https://github.com/bdastur/spam/blob/master/README.md#usage)\n\n\n# Introduction\n[Ansible] (http://docs.ansible.com/ansible/index.html) is an IT automation tool. It is \nexcellent for configuration management, orchestration and deployment automation. Ansible\nis gaining popularity over other tools due to it's simplicity in usage and architecture.\nIf you are not familiar with Ansible, you can read the [Ansible documentation] (http://docs.ansible.com/ansible/index.html).\n \n**So what is pyAnsible**\npyAnsible is a python module that interfaces with the Ansible.Runner and Ansible.Inventory modules\nand provides a simple python API that you can invoke to directly access ansible modules.\n\n*How is this useful?*: The most common way of using playbooks is great for most operations with ansible, \nbut consider some use cases where you want to do discovery for instance, or take action based on the results\nfrom output of the ansible modules run on remote hosts. \n\nSome usecases where I have used this module:\n - Given a list of hosts/hypervisors, get all the VMs running on them and check the linux distribution on them.\n - Developed a [remote execution CLI] (https://github.com/bdastur/relic) to execute commands on multiple hosts\n simultaneously.\n - Check disk utilization on hosts and send a warning email when disk usage exceeds a threshold. \n\n# Installation:\n\n```\n pip install pyansible\n```\n\n# Sample Usage:\nHere's a simple example of using pyAnsible library to execute operations on multiple remote hosts:\n\nImport pyansible runner and Inventory\n```\n import sys\n # 1. Imports\n import pyansible.ansirunner\n import pyansible.ansiInventory\n ```\nUsing the Inventory:\n ```\n # 2. Using inventory.\n myhostgroup = \"nova\"\n inventory = pyansible.ansiInventory.AnsibleInventory(\"./ansible_invfile\")\n if not inventory.get_hosts(myhostgroup)\n print \"No host for group %s found \" % myhostgroup\n sys.exit()\n hostlist = inventory.get_hosts(myhostgroup[0]['hostlist'])\n ```\nUsing the runner:\n ```\n # 3. Using runner: Try a simple connectivity test.\n runner = pyansible.ansirunner.AnsibleRunner()\n result, _ = runner.ansible_perform_operation(\n host_list=hostlist,\n remote_user=myusername,\n remote_pass=mypass,\n module=\"ping\")\n\n for host in result['dark'].keys():\n print \"%s: %s\" % (host, \"failed\")\n\n for host in result['contacted'].keys():\n print \"%s: %s\" % (host, \"OK\") \n\n # 4. Using runner: Execute a command. (with sudo) if required.\n \n cmd = \"grep rabbit_hosts /etc/nova/nova.conf\" \n result, _ = self.runner.ansible_perform_operation(\n host_list=hostlist,\n remote_user=username,\n remote_pass=password,\n sudo=self.sudo,\n sudo_user=self.sudo_user,\n sudo_pass=self.sudo_pass,\n module=\"shell\",\n module_args=cmd)\n \n # Display result.\n for host in result['contacted'].keys():\n try:\n print result['contacted'][host]['stdout']\n except KeyError:\n print \"No data for %s \" % host\n\n```", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/bdastur/spam", "keywords": "ansible", "license": "Apache Software License", "maintainer": "", "maintainer_email": "", "name": "pyansible", "package_url": "https://pypi.org/project/pyansible/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/pyansible/", "project_urls": { "Homepage": "https://github.com/bdastur/spam" }, "release_url": "https://pypi.org/project/pyansible/1.0.3/", "requires_dist": null, "requires_python": "", "summary": "A module for interfacing with Ansible Runner and Inventory.", "version": "1.0.3" }, "last_serial": 2031847, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "c66eb3170f51606559f491d8a3f669a9", "sha256": "49d3b2a5cdb49b19ba8c10b3206de6495cff14f03ba719e899776d40d6a76077" }, "downloads": -1, "filename": "pyansible-1.0.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "c66eb3170f51606559f491d8a3f669a9", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8434, "upload_time": "2015-12-13T21:54:06", "url": "https://files.pythonhosted.org/packages/87/f1/69a2746668c5b036a5ae585469e2ad18c67bb5bfb8a02f3c62239306f159/pyansible-1.0.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "be16791b8626e9b972dae6559244b6ec", "sha256": "6d331a1ed8a0ab6354f4ff0f66c47fc56d57e95bd504826b48f386b0c41346b2" }, "downloads": -1, "filename": "pyansible-1.0.0.tar.gz", "has_sig": false, "md5_digest": "be16791b8626e9b972dae6559244b6ec", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5338, "upload_time": "2015-12-13T21:53:50", "url": "https://files.pythonhosted.org/packages/f3/50/7bf847e248230e572e7d32f5cbf263cf4427c8a8337f3153cc34ca330d1a/pyansible-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "124bebb749b679bf1ee75cde6d2cd626", "sha256": "8c8828764506fd4ad84e3159f9f396f9781fd334932d33ee8ed6dcc84823f3ce" }, "downloads": -1, "filename": "pyansible-1.0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "124bebb749b679bf1ee75cde6d2cd626", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 8376, "upload_time": "2016-01-08T01:16:22", "url": "https://files.pythonhosted.org/packages/0e/99/9ddf1b86500289dd268eeb76f5e2e29463c352332e0c43fed815b4625e25/pyansible-1.0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cf843a4f3c32146bb51e9b4a07d8d3ce", "sha256": "bb6845274724540d1a7d52313875e8e579f957272b94f3ddc5010b140d865a46" }, "downloads": -1, "filename": "pyansible-1.0.1.tar.gz", "has_sig": false, "md5_digest": "cf843a4f3c32146bb51e9b4a07d8d3ce", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5256, "upload_time": "2016-01-08T01:16:08", "url": "https://files.pythonhosted.org/packages/4e/ed/2ab7eff738a23d708b6174c932cb0a0cc2253a93b29e9eb08251a20bd302/pyansible-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "f6082bd4e1e522e173a7805b10f879bc", "sha256": "4fde64f25b0b9c9fd613733f3e50f83a34d879cf2477d7cd507b080b68811839" }, "downloads": -1, "filename": "pyansible-1.0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f6082bd4e1e522e173a7805b10f879bc", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 13102, "upload_time": "2016-01-08T01:42:59", "url": "https://files.pythonhosted.org/packages/70/d6/e0e637ddb56dd15699d15bb3b0689a8955b34ba19fb89ca1023497f22dfc/pyansible-1.0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "316c0243d7144897e49bf4bbed99fcc4", "sha256": "0094deed44329be4ab8af15fb894a01517bce94ad77932f1a69524eae141e707" }, "downloads": -1, "filename": "pyansible-1.0.2.tar.gz", "has_sig": false, "md5_digest": "316c0243d7144897e49bf4bbed99fcc4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5250, "upload_time": "2016-01-08T01:42:39", "url": "https://files.pythonhosted.org/packages/11/2c/97c46d23666a636a7e7665916fbad3adf899fcef4b064adbdcba4dbbc983/pyansible-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "746196cc31370dfec8d64c84a9075d9b", "sha256": "8f8496ed93fc90897bd299f1f522c5a19163444a52a54ddc08e61f1c8a096874" }, "downloads": -1, "filename": "pyansible-1.0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "746196cc31370dfec8d64c84a9075d9b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10456, "upload_time": "2016-03-28T14:51:07", "url": "https://files.pythonhosted.org/packages/45/47/39316c35fa00a49ac88284a2d198f64073ab0bc121ceaad16fdd8e222f9e/pyansible-1.0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "df823b1219fbf858e1875fdaa19f8c4a", "sha256": "04d3e5f0514c1277239c240c0b3505774e08ae8c74cba146234935de9eae8fd8" }, "downloads": -1, "filename": "pyansible-1.0.3.tar.gz", "has_sig": false, "md5_digest": "df823b1219fbf858e1875fdaa19f8c4a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6333, "upload_time": "2016-03-28T14:50:29", "url": "https://files.pythonhosted.org/packages/2a/f6/81d9dcc46195c32970cd14bf6d4d1f544653795b6bf261b010ccf23046fe/pyansible-1.0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "746196cc31370dfec8d64c84a9075d9b", "sha256": "8f8496ed93fc90897bd299f1f522c5a19163444a52a54ddc08e61f1c8a096874" }, "downloads": -1, "filename": "pyansible-1.0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "746196cc31370dfec8d64c84a9075d9b", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10456, "upload_time": "2016-03-28T14:51:07", "url": "https://files.pythonhosted.org/packages/45/47/39316c35fa00a49ac88284a2d198f64073ab0bc121ceaad16fdd8e222f9e/pyansible-1.0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "df823b1219fbf858e1875fdaa19f8c4a", "sha256": "04d3e5f0514c1277239c240c0b3505774e08ae8c74cba146234935de9eae8fd8" }, "downloads": -1, "filename": "pyansible-1.0.3.tar.gz", "has_sig": false, "md5_digest": "df823b1219fbf858e1875fdaa19f8c4a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6333, "upload_time": "2016-03-28T14:50:29", "url": "https://files.pythonhosted.org/packages/2a/f6/81d9dcc46195c32970cd14bf6d4d1f544653795b6bf261b010ccf23046fe/pyansible-1.0.3.tar.gz" } ] }