TIL Generate sample ansible.cfg config file

I wanted to quiet Ansible's Interpreter Discovery warning in a barebones project that had no ansible.cfg file. The docs suggested:

globally, use the interpreter_python key in the [defaults] section of ansible.cfg

OK, but I don't already have that file. What exact syntax does it want for the [defaults] section? The docs on Ansible Configuration Settings provide this command for generating a sample ansible.cfg file:

ansible-config init --disabled > ansible.cfg

What do we get?

The resulting file is 675 lines:

wc -l ansible.cfg
     675 ansible.cfg

Those are mostly comments:

egrep -v "(^#|^$|^;)"  ansible.cfg | wc -l

The [defaults] section we are looking for is there. With my change:

egrep -v "(^#|^$|^;)"  ansible.cfg

ℹ️ About this TIL snippet: Created 2023-05-13T14:51:37-04:00 · View the source