From 1d8311df92d7e66d433eb8e82028abae99035a0b Mon Sep 17 00:00:00 2001 From: Antoine Le Morvan Date: Mon, 6 Dec 2021 11:38:58 +0100 Subject: [PATCH] New way to generate a config file --- docs/books/learning_ansible/01-basic.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/books/learning_ansible/01-basic.md b/docs/books/learning_ansible/01-basic.md index 91bc6814ee..22f09c094a 100644 --- a/docs/books/learning_ansible/01-basic.md +++ b/docs/books/learning_ansible/01-basic.md @@ -142,9 +142,31 @@ An example of the `ansible.cfg` [is given here](https://github.com/ansible/ansib $ sudo mkdir /etc/ansible $ sudo curl -o /etc/ansible/ansible.cfg https://raw.githubusercontent.com/ansible/ansible/devel/examples/ansible.cfg $ sudo curl -o /etc/ansible/hosts https://raw.githubusercontent.com/ansible/ansible/devel/examples/hosts +``` + +You can also use the `ansible-config` command to generate a new configuration file : + +``` +usage: ansible-config [-h] [--version] [-v] {list,dump,view,init} ... + +View ansible configuration. +positional arguments: + {list,dump,view,init} + list Print all config options + dump Dump configuration + view View configuration file + init Create initial configuration ``` +Example: + +``` +ansible-config init --disabled > /etc/ansible/ansible.cfg +``` + +The `--disabled` option allows you to comment out the set of options by prefixing them with a `;`. + ### The inventory file `/etc/ansible/hosts` As Ansible will have to work with all your equipment to be configured, it is very important to provide it with one (or more) well-structured inventory file(s), which perfectly matches your organization.