Search code examples
curlansibleansible-inventoryansible-tower

Curl command to get inventory-id from ansible tower


I need to retrieve the inventory_id for a given project (project_dev is the project name) from ansible tower using curl command

curl -X GET -s -k -u "user:password" -vvv  -H 'Content-Type:application/json' -d '{"organization": 1,"name": "project-dev"}' https://ansibletower.com/api/v2/inventories/"

Solution

  • Q: I need to retrieve the inventory_id from ansible tower.

    A: Use tower-cli

    Usage: tower-cli inventory get [OPTIONS] [ID]

    Q: How to add special character password to tower-cli config?

    A: Use tower_cli.cfg

    $ cat $HOME/.tower_cli.cfg 
    [general]
    host = http://srv.example.com
    username = admin
    password = password
    verify_ssl = no