{"id":15668833,"url":"https://github.com/alancoding/tower-cli-dynamic-inventory","last_synced_at":"2025-02-22T11:43:40.169Z","repository":{"id":144899874,"uuid":"52688974","full_name":"AlanCoding/tower-cli-dynamic-inventory","owner":"AlanCoding","description":"Ansible dynamic inventory source that pulls inventory from Ansible Tower","archived":false,"fork":false,"pushed_at":"2016-02-29T03:23:04.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-03T05:38:55.393Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlanCoding.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-02-27T21:11:19.000Z","updated_at":"2016-02-27T21:40:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"18c2f811-686a-4b9d-b959-1419cb61e5bc","html_url":"https://github.com/AlanCoding/tower-cli-dynamic-inventory","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlanCoding%2Ftower-cli-dynamic-inventory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlanCoding%2Ftower-cli-dynamic-inventory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlanCoding%2Ftower-cli-dynamic-inventory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlanCoding%2Ftower-cli-dynamic-inventory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlanCoding","download_url":"https://codeload.github.com/AlanCoding/tower-cli-dynamic-inventory/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240170064,"owners_count":19759143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T14:20:14.857Z","updated_at":"2025-02-22T11:43:39.918Z","avatar_url":"https://github.com/AlanCoding.png","language":"Python","readme":"# tower-cli-dynamic-inventory\n\nAnsible dynamic inventory source that pulls inventory from Ansible Tower\n\nThis operates in conjunction with the tower-cli inventory script feature.\nOrdinarily, that can be run with the following type of command:\n\n```bash\ntower-cli inventory script --name=\"QA_machines\"\n```\n\nThis produces a Ansible-compatible JSON output which can be used as the\ndynamic inventory source. The intent for this module is to link that \ncapability to Ansible core with something like the following command:\n\n```bash\nansible -i tower-inventory.py -u ubuntu us-east-1d -m ping\n```\n\nCredit to [ansible docs](http://docs.ansible.com/ansible/intro_dynamic_inventory.html)\nfor the example with the framework for that structure.\n\n## Setup\n\nFor now, testing this will have to be done straight from source, and since\nthe inventory_source feature for tower-cli still hasn't been released,\nthat will percolate into the requirements here.\n\nIt is suggested that you use a virtual environment specific to this project.\n\nYou may need to `chmod +x` the `tower-inventory.py` file in this repo.\n\n## Use Stories\n\n### I want Tower to update my Ansible inventory\n\nI have a dynamic inventory source stored in Ansible Tower. Let's say this\ncontains ec2 machines, for which I have the `.pem` file stored on my computer\nlocally, but I do not\nhave the cloud credentials too. Or someone else manages those cloud credentials.\nThis dynamic inventory would allow me to automatically launch commands\n\n## Further Reading\n\nAn canon example of using the tower-cli libraries directly in python can be\nfound at the [tower-populator](https://github.com/jsmartin/tower_populator)\nrepo. The general cadence of coding by this guideline is:\n\n```python\nimport tower_cli\n\nuser_res = tower_cli.get_resource('user')\n\nuser = user_res.create(\n  username='Sherlock', password='p4ass12986', email='email@domain.com',\n  first_name='Sherlock', last_name=\"Holmes\", \n)\n```\n\nThe inventory source command would be accessed similarly, replacing `user`\nwith `inventory` and `create` with `inventory_source`.\n\nThese will be implemented in the dynamic inventory source `.py` file in\nthis repository.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falancoding%2Ftower-cli-dynamic-inventory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falancoding%2Ftower-cli-dynamic-inventory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falancoding%2Ftower-cli-dynamic-inventory/lists"}