Ansbile loads its
configuration from multiple locations/files.
You can get the
config file options in configuration from docs.ansible.com and then
click on configuration file.
Below it the
precendence.
1. env. Variable
$ANSIBLE_CONFIG
2. from current
directory file: ./ansible.cfg
3. from home
directory hidden file: ~/.ansible.cfg
4. global config
file: / etc/ ansible/ansible.cfg
The global file
comes by default with pip and package manager but not with source
compilation, we need to create if we want to use it.
Configuration files
are not merges, ansible stops looking when it finds the first
result.It won’t merge the values from multiple files.Unlike
variable files.
We can override
setting in environment variable.
we can export the
variables at commandline on the fly using export line or using the
profile scripts.
to validate the
system to manage is valid and right path.
if we set it false,
then we don’t need to add the fingerprints to ssh keys.
Sample config file
in current directory, ansible.cfg
[defaults]
host_key_checking=False
And, as there is
nothing in ~/.ssh/known_hosts file, the above false value should
reflect and execute the ansible commands on remote machines.
ansible web1 -i
inventory_prod -m ping
Instead of skipping
the fingerprint cheking, it just clicks yes for fingerprint prompts
in the ssh prompt in the background.So, it populates the data in the
known_hosts file during command execution.
To skip the value
from config and get it from env. Variable.In the command prompt.
export
$ANSIBLE_HOST_KEY__CHECKING=True
Now, below command
will fail.
ansible web1 -i
inventory_prod -m ping
No comments:
Post a Comment