From 0cdd081b5343fefd3ab76a3abe508cec7c35ecea Mon Sep 17 00:00:00 2001 From: Marco Vito Moscaritolo Date: Mon, 10 Sep 2012 17:57:32 +0300 Subject: [PATCH] Add support for ./ansible.cfg file Ansible support configuration in: ``` ~/.ansible.cfg /etc/ansible/ansible.cfg ``` this patch add current user (usefull where user have some different projects) with the oreder: ``` ./ansible.cfg ~/.ansible.cfg /etc/ansible/ansible.cfg ``` --- lib/ansible/constants.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py index f38b5039492..149b25b55bd 100644 --- a/lib/ansible/constants.py +++ b/lib/ansible/constants.py @@ -35,13 +35,16 @@ def get_config(p, section, key, env_var, default): def load_config_file(): p = ConfigParser.ConfigParser() - path1 = os.path.expanduser( - os.environ.get('ANSIBLE_CONFIG', "~/.ansible.cfg")) - path2 = "/etc/ansible/ansible.cfg" + path1 = os.getcwd() + "/ansible.cfg" + path2 = os.path.expanduser(os.environ.get('ANSIBLE_CONFIG', "~/.ansible.cfg")) + path3 = "/etc/ansible/ansible.cfg" + if os.path.exists(path1): p.read(path1) elif os.path.exists(path2): p.read(path2) + elif os.path.exists(path3): + p.read(path3) else: return None return p