{"id":20551554,"url":"https://github.com/do-community/do-ansible-inventory","last_synced_at":"2025-04-14T11:30:43.181Z","repository":{"id":55987772,"uuid":"265070557","full_name":"do-community/do-ansible-inventory","owner":"do-community","description":"📗 a tool to generate Ansible inventories of DigitalOcean Droplets","archived":false,"fork":false,"pushed_at":"2020-12-02T18:40:59.000Z","size":30,"stargazers_count":43,"open_issues_count":2,"forks_count":10,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-28T00:44:00.627Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/do-community.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-18T21:48:50.000Z","updated_at":"2025-03-26T00:23:21.000Z","dependencies_parsed_at":"2022-08-15T10:50:48.820Z","dependency_job_id":null,"html_url":"https://github.com/do-community/do-ansible-inventory","commit_stats":null,"previous_names":["kamaln7/do-ansible-inventory"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-community%2Fdo-ansible-inventory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-community%2Fdo-ansible-inventory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-community%2Fdo-ansible-inventory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/do-community%2Fdo-ansible-inventory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/do-community","download_url":"https://codeload.github.com/do-community/do-ansible-inventory/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248871657,"owners_count":21175266,"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":["hacktoberfest"],"created_at":"2024-11-16T02:32:10.054Z","updated_at":"2025-04-14T11:30:43.149Z","avatar_url":"https://github.com/do-community.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 📗 do-ansible-inventory\n\ndo-ansible-inventory is a tool that generates an [Ansible inventory](https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html) file with your DigitalOcean Droplets. It is an alternative to [dynamic inventories](https://docs.ansible.com/ansible/latest/user_guide/intro_dynamic_inventory.html#intro-dynamic-inventory) as you can run do-ansible-inventory once and receive a static inventory file that you can use anywhere, copy, or modify.\n\n## Installation\n\n1. Download the latest release from [the releases page](https://github.com/do-community/do-ansible-inventory/releases).\n2. Extract the downloaded archive and place the binary `do-ansible-inventory` wherever you like. Preferably to any directory in your `$PATH` such as `~/bin` if it exists or `/usr/local/bin` so you can easily access it.\n\n## Usage\n\nTo use do-ansible-inventory, run:\n\n```\ndo-ansible-inventory\n```\n\nBy default, without setting any options, do-ansible-inventory will attempt to look up the currently configured [doctl](https://github.com/digitalocean/doctl) access token and generate an ansible inventory with:\n\n* All of your Droplets as Ansible hosts\n* Each DigitalOcean region as an Ansible group containing any Droplets in that region\n* Each Droplet tag as a group containing any Droplets with that tag\n\nIf you do not have `doctl` installed or would like to explicitly specify the access token, run `do-ansible-inventory --access-token ACCESS_TOKEN` or use the `DIGITALOCEAN_ACCESS_TOKEN` environment variable.\n\nThe resulting inventory will be printed to the console. You can save it to a file instead by passing `--out inventory` or redirecting the output like so: `do-ansible-inventory \u003e inventory`.\n\n### Supported Options\n\n* `-t TOKEN`, `--access-token TOKEN` - DigitalOcean API Token - if unset, do-ansible-inventory attempts to use doctl's stored token of its current default context. Alternatively, use the environment variable `DIGITALOCEAN_ACCESS_TOKEN`\n* `--ssh-user USER` - sets the `ansible_user` property on the hosts (Droplets)\n* `--ssh-port PORT` - sets the `ansible_port` property on the hosts (Droplets)\n* `--tag TAG` - limits the inventory to only Droplets with the specified tag\n* `--ignore HOSTNAME` - pass a Droplet's hostname to exclude it from the inventory. **This option can be used multiple times**\n* `--group-by-region` - create groups for each DigitalOcean region. Default behavior.\n   * `--no-group-by-region` - do not create groups for each DigitalOcean region.\n* `--group-by-tag` - create groups for each Droplet tag. Default behavior.\n   * `--no-group-by-tag` - do not create groups for each Droplet tag. \n* `--group-by-project` - create groups for each Droplet projects. Default behavior.\n   * `--no-group-by-project` - do not create groups for each Droplet project. \n* `--private-ips` - use private Droplet IPs instead of public IPs\n* `--out FILE` - write the ansible inventory to this file - if unset, print to stdout\n* `--timeout=2m` - timeout for total runtime of the command, defaults to `2m`\n\n## Example\n\nRunning:\n\n```\n$ do-ansible-inventory --out ./inventory\n```\n\nwill output:\n\n```\n   • no access token provided, attempting to look up doctl's access token\n   • using doctl access token  context=default\n   • processing                droplet=speedtest-ams2.digitalocean.com\n   • processing                droplet=speedtest-nyc2.digitalocean.com\n   • processing                droplet=speedtest-sfo1.digitalocean.com\n   • processing                droplet=speedtest-ams3.digitalocean.com\n   • processing                droplet=speedtest-blr1.digitalocean.com\n   • processing                droplet=speedtest-fra1.digitalocean.com\n   • processing                droplet=speedtest-lon1.digitalocean.com\n   • processing                droplet=speedtest-nyc1.digitalocean.com\n   • processing                droplet=speedtest-nyc3.digitalocean.com\n   • processing                droplet=speedtest-sfo2.digitalocean.com\n   • processing                droplet=speedtest-sgp1.digitalocean.com\n   • processing                droplet=speedtest-tor1.digitalocean.com\n   • building region group     region=ams1\n   • building region group     region=ams2\n   • building region group     region=ams3\n   • building region group     region=blr1\n   • building region group     region=fra1\n   • building region group     region=lon1\n   • building region group     region=nyc1\n   • building region group     region=nyc2\n   • building region group     region=nyc3\n   • building region group     region=sfo1\n   • building region group     region=sfo2\n   • building region group     region=sfo3\n   • building region group     region=sgp1\n   • building region group     region=tor1\n   • building tag group        tag=speedtests\n   • done!\n```\n\nwith the resulting file `inventory` containing:\n\n```\nspeedtest-ams2.digitalocean.com ansible_host=188.226.175.227\nspeedtest-nyc2.digitalocean.com ansible_host=192.241.184.88\nspeedtest-sfo1.digitalocean.com ansible_host=107.170.223.15\nspeedtest-ams3.digitalocean.com ansible_host=178.62.216.76\nspeedtest-blr1.digitalocean.com ansible_host=139.59.80.215\nspeedtest-fra1.digitalocean.com ansible_host=46.101.218.147\nspeedtest-lon1.digitalocean.com ansible_host=46.101.44.214\nspeedtest-nyc1.digitalocean.com ansible_host=165.227.194.167\nspeedtest-nyc3.digitalocean.com ansible_host=174.138.51.137\nspeedtest-sfo2.digitalocean.com ansible_host=165.227.29.84\nspeedtest-sgp1.digitalocean.com ansible_host=159.89.192.182\nspeedtest-tor1.digitalocean.com ansible_host=159.203.57.38\n\n[ams1]\n\n[ams2]\nspeedtest-ams2.digitalocean.com\n\n[ams3]\nspeedtest-ams3.digitalocean.com\n\n[blr1]\nspeedtest-blr1.digitalocean.com\n\n[fra1]\nspeedtest-fra1.digitalocean.com\n\n[lon1]\nspeedtest-lon1.digitalocean.com\n\n[nyc1]\nspeedtest-nyc1.digitalocean.com\n\n[nyc2]\nspeedtest-nyc2.digitalocean.com\n\n[nyc3]\nspeedtest-nyc3.digitalocean.com\n\n[sfo1]\nspeedtest-sfo1.digitalocean.com\n\n[sfo2]\nspeedtest-sfo2.digitalocean.com\n\n[sfo3]\n\n[sgp1]\nspeedtest-sgp1.digitalocean.com\n\n[tor1]\n\n[speedtests]\nspeedtest-ams2.digitalocean.com\nspeedtest-nyc2.digitalocean.com\nspeedtest-sfo1.digitalocean.com\nspeedtest-ams3.digitalocean.com\nspeedtest-blr1.digitalocean.com\nspeedtest-fra1.digitalocean.com\nspeedtest-lon1.digitalocean.com\nspeedtest-nyc1.digitalocean.com\nspeedtest-nyc3.digitalocean.com\nspeedtest-sfo2.digitalocean.com\nspeedtest-sgp1.digitalocean.com\nspeedtest-tor1.digitalocean.com\n```\n\n---\n\n```\nusage: do-ansible-inventory [\u003cflags\u003e]\n\nFlags:\n  -t, --access-token=ACCESS-TOKEN  \n                           DigitalOcean API Token - if unset, attempts to use doctl's stored token of its current default context. env var:\n                           DIGITALOCEAN_ACCESS_TOKEN\n      --ssh-user=SSH-USER  default ssh user\n      --ssh-port=SSH-PORT  default ssh port\n      --tag=TAG            filter droplets by tag\n      --ignore=IGNORE ...  ignore a Droplet by name, can be specified multiple times\n      --group-by-region    group hosts by region, defaults to true\n      --group-by-tag       group hosts by their Droplet tags, defaults to true\n      --group-by-project   group hosts by their Projects, defaults to true\n      --private-ips        use private Droplet IPs instead of public IPs\n      --out=OUT            write the ansible inventory to this file - if unset, print to stdout\n      --timeout=2m         timeout for total runtime of the command, defaults to 2m\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdo-community%2Fdo-ansible-inventory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdo-community%2Fdo-ansible-inventory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdo-community%2Fdo-ansible-inventory/lists"}