Create an Inventory

post

/api/v2/inventories/

Make a POST request to this resource with the following inventory fields to create a new inventory:

  • name: Name of this inventory. (string, required)
  • description: Optional description of this inventory. (string, default="")
  • organization: Organization containing this inventory. (id, required)
  • kind: Kind of inventory being represented. (choice)
    • "": Hosts have a direct link to this inventory. (default)
    • smart: Hosts for inventory generated using the host_filter property.
  • host_filter: Filter that will be applied to the hosts of this inventory. (string, default="")
  • variables: Inventory variables in JSON or YAML format. (json, default=``)

Request

Supported Media Types
Body ()
Root Schema : schema
Example:
{
    "host_filter":"ansible_facts__ansible_distribution__exact=\"CentOS\"",
    "kind":"smart",
    "name":"smart inventory",
    "organization":"1"
}
Back to Top

Response

Supported Media Types

201 Response

Body
Example Response (application/json)
{
    "created":"2018-02-01T08:00:00.000000Z",
    "description":"",
    "has_active_failures":false,
    "has_inventory_sources":false,
    "host_filter":"ansible_facts__ansible_distribution__exact=\"CentOS\"",
    "hosts_with_active_failures":"0",
    "id":"1",
    "inventory_sources_with_failures":"0",
    "kind":"smart",
    "modified":"2018-02-01T08:00:00.000000Z",
    "name":"smart inventory",
    "organization":"1",
    "pending_deletion":false,
    "related":{
        "access_list":"/api/v2/inventories/1/access_list/",
        "activity_stream":"/api/v2/inventories/1/activity_stream/",
        "ad_hoc_commands":"/api/v2/inventories/1/ad_hoc_commands/",
        "copy":"/api/v2/inventories/1/copy/",
        "groups":"/api/v2/inventories/1/groups/",
        "hosts":"/api/v2/inventories/1/hosts/",
        "instance_groups":"/api/v2/inventories/1/instance_groups/",
        "inventory_sources":"/api/v2/inventories/1/inventory_sources/",
        "job_templates":"/api/v2/inventories/1/job_templates/",
        "object_roles":"/api/v2/inventories/1/object_roles/",
        "organization":"/api/v2/organizations/1/",
        "root_groups":"/api/v2/inventories/1/root_groups/",
        "script":"/api/v2/inventories/1/script/",
        "tree":"/api/v2/inventories/1/tree/",
        "update_inventory_sources":"/api/v2/inventories/1/update_inventory_sources/",
        "variable_data":"/api/v2/inventories/1/variable_data/"
    },
    "summary_fields":{
        "object_roles":{
            "adhoc_role":{
                "description":"May run ad hoc commands on the inventory",
                "id":"18",
                "name":"Ad Hoc"
            },
            "admin_role":{
                "description":"Can manage all aspects of the inventory",
                "id":"16",
                "name":"Admin"
            },
            "read_role":{
                "description":"May view settings for the inventory",
                "id":"20",
                "name":"Read"
            },
            "update_role":{
                "description":"May update the inventory",
                "id":"17",
                "name":"Update"
            },
            "use_role":{
                "description":"Can use the inventory in a job template",
                "id":"19",
                "name":"Use"
            }
        },
        "organization":{
            "description":"test-org-desc",
            "id":"1",
            "name":"test-org"
        },
        "user_capabilities":{
            "adhoc":true,
            "copy":true,
            "delete":true,
            "edit":true
        }
    },
    "total_groups":"0",
    "total_hosts":"0",
    "total_inventory_sources":"0",
    "type":"inventory",
    "url":"/api/v2/inventories/1/",
    "variables":""
}

400 Response

Body
Example Response (application/json)
{
    "host_filter":{
        "host_filter":[
            "ansible_facts does not support searching with __has_keys"
        ]
    }
}
Back to Top