Create an Inventory Source

post

/api/v2/inventory_sources/

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

  • name: Name of this inventory source. (string, required)
  • description: Optional description of this inventory source. (string, default="")
  • source: (choice)
    • file: File, Directory or Script
    • scm: Sourced from a Project
    • ec2: Amazon EC2
    • gce: Google Compute Engine
    • azure_rm: Microsoft Azure Resource Manager
    • vmware: VMware vCenter
    • satellite6: Red Hat Satellite 6
    • openstack: OpenStack
    • rhv: Red Hat Virtualization
    • tower: Ansible Tower
    • custom: Custom Script
  • source_path: (string, default="")
  • source_script: (id, default=``)
  • source_vars: Inventory source variables in YAML or JSON format. (string, default="")
  • credential: Cloud credential to use for inventory updates. (integer, default=None)
  • enabled_var: Retrieve the enabled state from the given dict of host variables. The enabled variable may be specified as "foo.bar", in which case the lookup will traverse into nested dicts, equivalent to: from_dict.get("foo", {}).get("bar", default) (string, default="")
  • enabled_value: Only used when enabled_var is set. Value when the host is considered enabled. For example if enabled_var="status.power_state"and enabled_value="powered_on" with host variables:{ "status": { "power_state": "powered_on", "created": "2018-02-01T08:00:00.000000Z:00", "healthy": true }, "name": "foobar", "ip_address": "192.168.2.1"}The host would be marked enabled. If power_state where any value other than powered_on then the host would be disabled when imported into Tower. If the key is not found then the host will be enabled (string, default="")
  • host_filter: Regex where only matching hosts will be imported into Tower. (string, default="")
  • overwrite: Overwrite local groups and hosts from remote inventory source. (boolean, default=False)
  • overwrite_vars: Overwrite local variables from remote inventory source. (boolean, default=False)
  • custom_virtualenv: Local absolute file path containing a custom Python virtualenv to use (string, default="")
  • timeout: The amount of time (in seconds) to run before the task is canceled. (integer, default=0)
  • verbosity: (choice)

    • 0: 0 (WARNING)
    • 1: 1 (INFO) (default)
    • 2: 2 (DEBUG)
  • inventory: (id, required)

  • update_on_launch: (boolean, default=False)
  • update_cache_timeout: (integer, default=0)
  • source_project: Project containing inventory file used as source. (id, default=``)
  • update_on_project_update: (boolean, default=False)

Request

Supported Media Types
Body ()
Root Schema : schema
Example:
{
    "credential":1,
    "inventory":1,
    "name":"fobar",
    "source":"scm",
    "source_path":"",
    "source_project":1,
    "source_vars":"plugin: a.b.c"
}
Back to Top

Response

Supported Media Types

201 Response

Body
Example Response (application/json)
{
    "created":"2018-02-01T08:00:00.000000Z",
    "credential":1,
    "custom_virtualenv":null,
    "description":"",
    "enabled_value":"",
    "enabled_var":"",
    "host_filter":"",
    "id":2,
    "inventory":1,
    "last_job_failed":false,
    "last_job_run":null,
    "last_update_failed":false,
    "last_updated":null,
    "modified":"2018-02-01T08:00:00.000000Z",
    "name":"fobar",
    "next_job_run":null,
    "overwrite":false,
    "overwrite_vars":false,
    "related":{
        "activity_stream":"/api/v2/inventory_sources/2/activity_stream/",
        "credential":"/api/v2/credentials/1/",
        "credentials":"/api/v2/inventory_sources/2/credentials/",
        "groups":"/api/v2/inventory_sources/2/groups/",
        "hosts":"/api/v2/inventory_sources/2/hosts/",
        "inventory":"/api/v2/inventories/1/",
        "inventory_updates":"/api/v2/inventory_sources/2/inventory_updates/",
        "notification_templates_error":"/api/v2/inventory_sources/2/notification_templates_error/",
        "notification_templates_started":"/api/v2/inventory_sources/2/notification_templates_started/",
        "notification_templates_success":"/api/v2/inventory_sources/2/notification_templates_success/",
        "schedules":"/api/v2/inventory_sources/2/schedules/",
        "source_project":"/api/v2/projects/1/",
        "update":"/api/v2/inventory_sources/2/update/"
    },
    "source":"scm",
    "source_path":"",
    "source_project":1,
    "source_script":null,
    "source_vars":"plugin: a.b.c",
    "status":"never updated",
    "summary_fields":{
        "credential":{
            "cloud":true,
            "credential_type_id":1,
            "description":"",
            "id":1,
            "kind":"openstack",
            "name":"bar"
        },
        "credentials":[
            {
                "cloud":true,
                "credential_type_id":1,
                "description":"",
                "id":1,
                "kind":"openstack",
                "name":"bar"
            }
        ],
        "inventory":{
            "description":"",
            "has_active_failures":false,
            "has_inventory_sources":true,
            "hosts_with_active_failures":0,
            "id":1,
            "inventory_sources_with_failures":0,
            "kind":"",
            "name":"test-inv",
            "organization_id":1,
            "total_groups":0,
            "total_hosts":0,
            "total_inventory_sources":1
        },
        "organization":{
            "description":"test-org-desc",
            "id":1,
            "name":"test-org"
        },
        "source_project":{
            "description":"test-proj-desc",
            "id":1,
            "name":"test-proj",
            "scm_type":"git",
            "status":"never updated"
        },
        "user_capabilities":{
            "delete":true,
            "edit":true,
            "schedule":true,
            "start":true
        }
    },
    "timeout":0,
    "type":"inventory_source",
    "update_cache_timeout":0,
    "update_on_launch":false,
    "update_on_project_update":false,
    "url":"/api/v2/inventory_sources/2/",
    "verbosity":1
}

400 Response

Body
Example Response (application/json)
{
    "credential":[
        "Credentials of type insights and vault are disallowed for scm inventory sources."
    ]
}
Back to Top