Skip to content

Commit

Permalink
Add documentation for --inventory
Browse files Browse the repository at this point in the history
  • Loading branch information
Shrews committed Sep 18, 2023
1 parent de7ea91 commit f7f1bfd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions docs/standalone.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,33 @@ Ansible/Runner doesn't pollute or overwrite the playbook content you can give a
**Runner** will copy the project directory to a temporary directory created under that path, set it as the working directory, and execute from that location.
After running that temp directory will be cleaned up and removed.


Specifying an Alternate Inventory
---------------------------------

The default inventory, if not specified, will be ``<private_data_dir>/inventory/``.
All files within this subdirectory of the private data directory will be processed as
potential inventory host files. You may specify a different inventory using the ``--inventory``
option. This value may be one of:

- A file name located within ``<private_data_dir>/inventory/``.
- An absolute or relative path to an alternate inventory file or directory.
This path is not required to be inside of the private data directory.

Examples::

# Use inventory <private_data_dir>/inventory/hosts.backup
$ ansible-runner run demo -p test.yml --inventory hosts.backup

# Use inventory in the /path/to/alternate-inventory directory (outside of <private_data_dir>)
$ ansible-runner run demo -p test.yml --inventory /path/to/alternate-inventory

# Use inventory in the inventory2 subdirectory, relative to current directory
$ ansible-runner run demo -p test.yml --inventory inventory2

.. note:: This value does not work with process isolation.


Outputting json (raw event data) to the console instead of normal output
------------------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion src/ansible_runner/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def valid_inventory(private_data_dir: str, inventory: str) -> str | None:
Validate the --inventory value is an actual file or directory.
The inventory value from the CLI may only be an existing file. Validate it
exists. Supplied value may be either be relative to <private_data_dir/inventory/
exists. Supplied value may either be relative to <private_data_dir>/inventory/
or an absolute path to a file or directory (even outside of private_data_dir).
Since ansible itself accepts a file or directory for the inventory, we check
for either.
Expand Down

0 comments on commit f7f1bfd

Please sign in to comment.