2022-02-21 20:38:47 +00:00
---
title: Configuration
---
_ansible-doctor_ comes with default settings which should be sufficient for most users to start, but most of the settings can be adjusted.
{{< toc > }}
Configuration options can be set in different places, which are processed in the following order (last wins):
- Standard configuration (built-in)
- Global configuration file (the path depends on the operating system)
- Folder-based configuration file (`.ansibledoctor.yml|.ansibledoctor.yaml|.ansibledoctor`) in the current working directory
- Environment Variables
- CLI options
## Defaults
```YAML
---
2022-04-29 11:19:35 +00:00
# Default is the current working directory.
2023-02-12 11:57:57 +00:00
base_dir:
2022-04-29 11:19:35 +00:00
# Default is the basename of 'role_name'.
2022-02-21 20:38:47 +00:00
role_name:
# Auto-detect if the given directory is a role, can be disabled
# to parse loose files instead.
role_detection: True
2022-04-29 11:19:35 +00:00
# Don't write anything to file system
2022-02-21 20:38:47 +00:00
dry_run: False
logging:
2022-04-29 11:19:35 +00:00
# Possible options debug | info | warning | error | critical
2022-02-21 20:38:47 +00:00
level: "warning"
2022-04-29 11:19:35 +00:00
# Json logging can be enabled if a parsable output is required
2022-02-21 20:38:47 +00:00
json: False
2022-04-29 11:19:35 +00:00
# Path to write rendered template file. Default is the current working directory.
2022-02-21 20:38:47 +00:00
output_dir:
2022-04-29 11:19:35 +00:00
# Default is built-in templates directory.
2022-02-21 20:38:47 +00:00
template_dir:
template: readme
2023-06-14 11:31:01 +00:00
# By default, double spaces, spaces before and after line breaks or tab characters, etc.
# are automatically removed before the template is rendered. As a result, indenting
# with spaces does not work. If you want to use spaces to indent text, you must disable
# this option.
template_autotrim: True
2022-02-21 20:38:47 +00:00
2022-04-29 11:19:35 +00:00
# Don't ask to overwrite if output file exists.
2022-02-21 20:38:47 +00:00
force_overwrite: False
2022-04-29 11:19:35 +00:00
# Load custom header from given file and append template output to it before write.
2022-02-21 20:38:47 +00:00
custom_header: ""
exclude_files: []
# Examples
# exclude_files:
# - molecule/
# - files/**/*.py
2022-04-29 11:19:35 +00:00
# Exclude tags from automatic detection. Configured tags are only skipped
# if the tag is not used in an annotation.
exclude_tags: []
2022-02-21 20:38:47 +00:00
```
## CLI
```Shell
$ ansible-doctor --help
2023-02-12 11:57:57 +00:00
usage: ansible-doctor [-h] [-c CONFIG_FILE] [-o OUTPUT_DIR] [-r] [-f] [-d] [-n] [-v] [-q] [--version] [base_dir]
2022-02-21 20:38:47 +00:00
Generate documentation from annotated Ansible roles using templates
positional arguments:
2023-02-12 11:57:57 +00:00
base_dir base directory (default: current working directory)
2022-02-21 20:38:47 +00:00
2023-02-12 11:57:57 +00:00
options:
2022-02-21 20:38:47 +00:00
-h, --help show this help message and exit
-c CONFIG_FILE, --config CONFIG_FILE
2023-02-12 11:57:57 +00:00
path to configuration file
2022-02-21 20:38:47 +00:00
-o OUTPUT_DIR, --output OUTPUT_DIR
2023-02-12 11:57:57 +00:00
output directory
-r, --recursive run recursively over the base directory subfolders
2022-02-21 20:38:47 +00:00
-f, --force force overwrite output file
-d, --dry-run dry run without writing
-n, --no-role-detection
disable automatic role detection
-v increase log level
-q decrease log level
--version show program's version number and exit
```
## Environment Variables
```Shell
ANSIBLE_DOCTOR_CONFIG_FILE=
ANSIBLE_DOCTOR_ROLE_DETECTION=true
2023-02-12 11:57:57 +00:00
ANSIBLE_DOCTOR_BASE_DIR=
ANSIBLE_DOCTOR_RECURSIVE=false
2022-02-21 20:38:47 +00:00
ANSIBLE_DOCTOR_ROLE_NAME=
ANSIBLE_DOCTOR_DRY_RUN=false
ANSIBLE_DOCTOR_LOG_LEVEL=warning
ANSIBLE_DOCTOR_LOG_JSON=false
ANSIBLE_DOCTOR_OUTPUT_DIR=
ANSIBLE_DOCTOR_TEMPLATE_DIR=
ANSIBLE_DOCTOR_TEMPLATE=readme
2023-06-14 11:31:01 +00:00
ANSIBLE_DOCTOR_TEMPLATE_AUTOTRIM=true
2022-02-21 20:38:47 +00:00
ANSIBLE_DOCTOR_FORCE_OVERWRITE=false
ANSIBLE_DOCTOR_CUSTOM_HEADER=
ANSIBLE_DOCTOR_EXCLUDE_FILES=
ANSIBLE_DOCTOR_EXCLUDE_FILES=molecule/,files/**/*.py
```
2023-02-10 18:56:00 +00:00
## Pre-Commit setup
To use _ansible-doctor_ with the [pre-commit ](https://pre-commit.com/ ) framework, add the following to the `.pre-commit-config.yaml` file in your local repository.
<!-- prettier - ignore - start -->
<!-- markdownlint - disable -->
<!-- spellchecker - disable -->
{{< highlight yaml " linenos = table" > }}
- repo: https://github.com/thegeeklab/ansible-doctor
# change ref to the latest release from https://github.com/thegeeklab/ansible-doctor/releases
rev: v1.4.8
hooks:
- id: ansible-doctor
{{< / highlight > }}
<!-- spellchecker - enable -->
<!-- markdownlint - restore -->
<!-- prettier - ignore - end -->