Skip to content

The ansible.cfg File

Filename Location Group Project/Repository
ansible.cfg ./ansible.cfg configuration ansible

Why?

An Ansible configuration file allows us to (re)define some of Ansible behaviours. This is useful for changing things like the path to the Python interpreter we want Ansible to use, the SSH connection settings, and more.

Breakdown

We're going to be using the configuration to configure how it handles the SSH finger prints of remote systems. Essentially we want it to ignore those fingerprints because when we execute our Ansible Playbook from our CI/CD Runners (agents) later on we're unable to (easily) configure them with the finger prints of our servers ahead of time.

Our configuration is currently quite simple. We're simply setting host_key_checking to False so that we tell Ansible to ignore remote SSH finger prints.

The Solution

1
2
[defaults]
host_key_checking = False

Committing the Code

  1. Set your working directory to the configuration/ansible repository
  2. Save the file as ansible.cfg and use git add ansible.cfg to add it to the Git staging area
  3. Use git commit -am 'ensuring ansible ignores host keys on remote hosts' to commit the file to our repository
  4. Push the code to GitLab.com: git push

Last update: August 25, 2021