{"id":21710656,"url":"https://github.com/mbrav/ansible-inventory-diagram","last_synced_at":"2025-05-13T02:53:41.536Z","repository":{"id":179711802,"uuid":"663940539","full_name":"mbrav/ansible-inventory-diagram","owner":"mbrav","description":"Script for generating infrastructure diagrams from Ansible inventory files","archived":false,"fork":false,"pushed_at":"2023-10-14T11:05:56.000Z","size":1492,"stargazers_count":2,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-01T06:03:09.155Z","etag":null,"topics":["ansible","cli","diagram","graphviz","infrastructure-as-code","inventory","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mbrav.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-07-08T13:47:51.000Z","updated_at":"2024-11-17T15:53:35.000Z","dependencies_parsed_at":null,"dependency_job_id":"9cecb521-55d3-473b-b639-1e6c30f77bdd","html_url":"https://github.com/mbrav/ansible-inventory-diagram","commit_stats":{"total_commits":12,"total_committers":2,"mean_commits":6.0,"dds":0.08333333333333337,"last_synced_commit":"b709744f43e0e6debfa2be50c07b74621704a56f"},"previous_names":["mbrav/ansible-inventory-diagram"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbrav%2Fansible-inventory-diagram","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbrav%2Fansible-inventory-diagram/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbrav%2Fansible-inventory-diagram/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mbrav%2Fansible-inventory-diagram/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mbrav","download_url":"https://codeload.github.com/mbrav/ansible-inventory-diagram/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253862959,"owners_count":21975588,"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":["ansible","cli","diagram","graphviz","infrastructure-as-code","inventory","python"],"created_at":"2024-11-25T23:16:47.371Z","updated_at":"2025-05-13T02:53:41.514Z","avatar_url":"https://github.com/mbrav.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License](https://img.shields.io/badge/License-BSD_3--Clause-yellow.svg)](https://opensource.org/licenses/BSD-3-Clause)\n[![tokei](https://tokei.rs/b1/github/mbrav/ansible-inventory-diagram?category=lines)](https://tokei.rs/b1/github/mbrav/ansible-inventory-diagram)\n[![Hits-of-Code](https://hitsofcode.com/github/mbrav/ansible-inventory-diagram?branch=main)](https://hitsofcode.com/github/mbrav/ansible-inventory-diagram/view?branch=main)\n\n# ansible-inventory-diagram\n\nScript for generating infrastructure diagrams from Ansible inventory files\n\n![Example diagram](./ansible_inventory_diagram.png)\n\n[Link to image](https://github.com/mbrav/ansible-inventory-diagram/blob/main/ansible_inventory_diagram.png)\n\n## Prerequisites\n\n- Python 3.10, see [#1](https://github.com/mbrav/ansible-inventory-diagram/issues/1) for Python 3.9 support;\n- Before using this script you must install the [Graphviz library](https://graphviz.org/) on your system.\n\n### Inventory file preparation\n\nTo prepare the JSON necessary to feed the script you must first prepare it using `ansible-inventory` the following way (YAML, INI, and JSON formats can be used):\n\n```bash\nansible-inventory -i inventory/example.yml --list \u003e inventory/example.json\n```\n\n**Note:** The script currently is not able to parse inventories tha have many redefinitions of groups. To do so, a more intricate algorithm is necessary. Currently, a very naive one is implemented. To see what kind of inventory structure works well, see [`inventory/example.yml`](inventory/example.yml).\n\n## Usage\n\nOnce you have an outputted JSON inventory file you can run the script:\n\n```bash\npython3 diagram/main.py -i inventory/example.json\n```\n\nFor instructions run\n\n```bash\npython3 diagram/main.py -h\n```\n\nYou will see the following\n\n```text\nusage: ansible-inventory-diagram [-h] [-i INVENTORY]\n                                 [-o {png,jpg,svg,pdf,dot}] [-n NAME]\n                                 [-f FILENAME] [-s]\n\nScript for generating infrastructure diagrams from Ansible inventory files\n\noptions:\n  -h, --help            show this help message and exit\n  -i INVENTORY, --inventory INVENTORY\n                        Path to Ansible JSON inventory file\n  -o {png,jpg,svg,pdf,dot}, --outformat {png,jpg,svg,pdf,dot}\n                        Format of the output format\n  -n NAME, --name NAME  Name of the diagram\n  -f FILENAME, --filename FILENAME\n                        Name of file to output\n  -s, --show            Show file after generation using the default program\n\n2023 - mbrav https://github.com/mbrav/ansible-inventory-diagram\n```\n\n## Installation\n\nClone repo\n\n```bash\ngit clone https://github.com/mbrav/ansible-inventory-diagram.git\ncd ansible-inventory-diagram\n```\n\nInstall Python libraries\n\n```bash\npip3 install -r requirements.txt \n```\n\nRun script\n\n```bash\npython3 diagram/main.py\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbrav%2Fansible-inventory-diagram","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmbrav%2Fansible-inventory-diagram","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmbrav%2Fansible-inventory-diagram/lists"}