Skip to content

Commit

Permalink
fix(anta.cli): Use configured anta inventory as output by default in …
Browse files Browse the repository at this point in the history
…get from-ansible
  • Loading branch information
titom73 committed Nov 16, 2023
1 parent bbc384b commit 63c818c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions anta/cli/get/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,18 @@ def from_cvp(inventory_directory: str, cvp_ip: str, cvp_username: str, cvp_passw
@click.option(
"--output",
"-o",
default="inventory-ansible.yml",
help="Path to save inventory file",
required=False,
help="Path to save inventory file. If not configured, use anta inventory file",
type=click.Path(file_okay=True, dir_okay=False, exists=False, writable=True, path_type=Path),
)
def from_ansible(ctx: click.Context, output: Path, ansible_inventory: Path, ansible_group: str) -> None:
"""Build ANTA inventory from an ansible inventory YAML file"""
logger.info(f"Building inventory from ansible file {ansible_inventory}")

# Create output directory
output = output if output is not None else ctx.obj["inventory_path"]
output.parent.mkdir(parents=True, exist_ok=True)
logger.info(f"output anta inventory is: {output}")
try:
create_inventory_from_ansible(
inventory=ansible_inventory,
Expand Down

0 comments on commit 63c818c

Please sign in to comment.