Metadata-Version: 2.5
Name: ansible-vaultsearch
Version: 0.1.2
Summary: Recursively search encrypted Ansible Vault files using regular expressions.
Author: Chuck Nemeth
License-Expression: MIT
License-File: LICENSE
Keywords: ansible,ansible-vault,grep,search,vault
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: System :: Systems Administration
Classifier: Topic :: Utilities
Requires-Python: >=3.12
Requires-Dist: ansible-core<2.22,>=2.19
Description-Content-Type: text/markdown

# ansible-vaultsearch

[![CI](https://github.com/chuckn246/ansible-vaultsearch/actions/workflows/ci.yml/badge.svg)](https://github.com/chuckn246/ansible-vaultsearch/actions/workflows/ci.yml)

Search encrypted Ansible Vault files using regular expressions.

`ansible-vaultsearch` recursively discovers Ansible Vault files, decrypts them
using the configured Ansible Vault credentials, and searches their contents.

The installed command is `avs`.

## Installation

Install from PyPI:

```bash
pip install ansible-vaultsearch
```

Or install as an isolated command with uv:

```bash
uv tool install ansible-vaultsearch
```

## Usage

Search recursively from the current directory:

```bash
avs "searchterm"
```

Search a specific directory:

```bash
avs "password" group_vars
```

Search using a regular expression:

```bash
avs "password|secret|token" group_vars/all
```

Use a case-insensitive regular expression:

```bash
avs "(?i)password|secret|token"
```

Search a single vault file:

```bash
avs "password" group_vars/all/vault.yml
```

Display command help:

```bash
avs --help
```

## Color output

Color is enabled automatically when output is written to a terminal.

Color is disabled when output is redirected or piped:

```bash
avs "password" > results.txt
```

Color can also be disabled explicitly with the `NO_COLOR` environment variable:

```bash
NO_COLOR=1 avs "password"
```

## Ansible Vault credentials

`ansible-vaultsearch` uses Ansible's configured Vault identities and
credentials.

For example, credentials configured through Ansible's normal vault password
or vault identity mechanisms are used when decrypting files.

## Exit status

`avs` returns:

- `0` when one or more matches are found
- `1` when the search completes successfully but finds no matches
- `2` for command-line, configuration, or Vault setup errors
- `130` when interrupted with `Ctrl-C`

## Development

Install the project and development dependencies:

```bash
uv sync --dev
```

Run the test suite:

```bash
uv run pytest
```

Run linting:

```bash
uv run ruff check src/ tests/
```

Check formatting:

```bash
uv run ruff format --check src/ tests/
```

Run type checking:

```bash
uv run ty check
```

Build the package:

```bash
uv build --no-sources
```

## License

MIT
