Ansible Pilot

An In-Depth Guide to ansible-config Managing Ansible Configuration

A Comprehensive Guide to Managing Configuration with ansible-config and ansible.cfg files
September 9, 2023
Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons

YouTube Video


Ansible is a powerful automation tool used for configuration management, application deployment, and task automation. It simplifies the management of complex infrastructures by allowing users to define tasks in easy-to-understand YAML files. However, to harness its full potential, it’s essential to understand and manage its configuration effectively. This is where the ansible-config command comes into play. In this article, we’ll explore the ansible-config tool, its various actions, and how to use it to manage Ansible’s configuration.

What is ansible-config?

ansible-config is a command-line utility provided by Ansible that allows users to view, manipulate, and manage Ansible’s configuration settings. It provides a way to interact with Ansible’s configuration files, making it easier to customize and troubleshoot Ansible’s behavior.

Configuration Files

Ansible looks for configuration files in specific locations; their precedence determines which one is used. Here are the two main configuration files:

Environment Variables

Ansible allows you to override default configuration settings using environment variables. The primary environment variable for configuring Ansible is ANSIBLE_CONFIG. You can point Ansible to a specific configuration file by setting this variable.


export ANSIBLE_CONFIG=/path/to/my/ansible.cfg

Common Options

Before diving into the actions, let’s understand some common options available with the ansible-config command:


The ansible-config command supports various actions, each serving a specific purpose. Here are the available actions:

1. list

The list action allows you to list and output available configuration settings. You can use options like --format to specify the output format, -c to provide a path to a specific configuration file, and -t to filter down to a specific plugin type.


ansible-config list --format yaml


  default: true
  - By default Ansible will issue a warning when received from a task action (module
    or action plugin)
  - These warnings can be silenced by adjusting this setting to False.
  - key: action_warnings
    section: defaults
  name: Toggle action warnings
  type: boolean
  version_added: '2.5'
  default: true
  description: Display an agnostic become prompt instead of displaying a prompt containi>
    the command line supplied become method
  - key: agnostic_become_prompt
    section: privilege_escalation

2. dump

The dump action displays the current configuration settings and merges them with the ansible.cfg file if specified. You can also use the --only-changed option to show configurations that have changed from the default.


ansible-config dump --only-changed


CALLBACKS_ENABLED(/Users/lberton/prj/gitlab/ansible-pilot/callback/ansible.cfg) = ['ansi>
CONFIG_FILE() = /Users/lberton/prj/gitlab/ansible-pilot/callback/ansible.cfg

3. view

The view action displays the current contents of the configuration file. You can use the -c option to specify a path to a specific configuration file and -t to filter by a specific plugin type.


ansible-config view



4. init

The init action is used to create an initial configuration file. You can use the --disabled option to prefix all entries with a comment character to disable them. Additionally, you can specify the output format with --format.


ansible-config init --disabled --format ini


# (boolean) By default Ansible will issue a warning when received from a task action (mo>
# These warnings can be silenced by adjusting this setting to False.

# (list) Accept list of cowsay templates that are 'safe' to use, set to empty list if yo>
;cowsay_enabled_stencils=bud-frogs, bunny, cheese, daemon, default, dragon, elephant-in->

# (string) Specify a custom cowsay path or swap in your cowsay implementation of choice

# (string) This allows you to chose a specific cowsay stencil for the banners or use 'ra>

# (boolean) This option forces color mode even when running without a TTY or the "nocolo>

# (path) The default root path for Ansible config files on the controller.

# (boolean) This setting allows suppressing colorizing output, which is used to give a b>


The ansible-config command is a valuable tool for managing Ansible’s configuration settings, allowing users to customize their Ansible experience to suit their specific needs. Understanding its various actions and options allows you to gain greater control over Ansible’s behavior and streamline your automation tasks. Whether you need to list available configurations, view the current settings, or initialize a new configuration file, ansible-config is your go-to utility for managing Ansible’s configuration.

Subscribe to the YouTube channel, Medium, and Website, X (formerly Twitter) to not miss the next episode of the Ansible Pilot.


Learn the Ansible automation technology with some real-life examples in my

My book Ansible By Examples: 200+ Automation Examples For Linux and Windows System Administrator and DevOps

BUY the Complete PDF BOOK to easily Copy and Paste the 250+ Ansible code

Want to keep this project going? Please donate

Access the Complete Video Course and Learn Quick Ansible by 200+ Practical Lessons
Follow me

Subscribe not to miss any new releases